@@ -44,6 +44,7 @@ use google_cloud_storage::http::objects::get::GetObjectRequest;
4444use google_cloud_storage:: http:: objects:: upload:: { Media , UploadObjectRequest , UploadType } ;
4545use google_cloud_storage:: http:: Error as GcsError ;
4646use mockall:: predicate:: eq;
47+ use starknet_api:: abi:: abi_utils:: selector_from_name;
4748use starknet_api:: block:: { BlockHash , BlockHashAndNumber , BlockInfo , BlockNumber , BlockTimestamp } ;
4849use starknet_api:: block_hash:: block_hash_calculator:: {
4950 calculate_block_commitments,
@@ -858,19 +859,9 @@ async fn test_make_data() {
858859 let mut blob_factory = BlobFactory :: new ( ) ;
859860 let chain_info = OsChainInfo :: from ( & blob_factory. chain_info ) . to_hex_map ( ) ;
860861
861- // Create the list of transactions to be included in the blobs:
862- // 1. bootstrap declare of an ERC20 contract.
863- // 2. bootstrap declare of an account with real validate.
864- // 3. deploy account (with zero fees).
865- // 4. deploy ERC20 contract from the account (with zero fees), while minting some tokens to the
866- // sender account.
867- // (from this point - all txs include non-zero fees, and no more bootstrap declares)
868- // 5. declare the test contract.
869- // 6. deploy the test contract.
870- // 7. deploy another instance of the test contract.
871- // TODO(Dori): the rest of the txs.
872- // 8. invoke the test contract: something with a state change.
873- // 9. invoke the test contract: test syscalls.
862+ // Create the list of transactions to be included in the blobs.
863+ // Block closing point is arbitrary, although it is preferable not to close after the last tx
864+ // (to ensure the preconfirmed block is not empty).
874865 let erc20_contract = FeatureContract :: ERC20 ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
875866 let account_with_real_validate = FeatureContract :: AccountWithRealValidate ( RunnableCairo1 :: Casm ) ;
876867 let test_contract = FeatureContract :: TestContract ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
@@ -900,17 +891,79 @@ async fn test_make_data() {
900891 blob_factory. close_block ( ) . await ;
901892 blob_factory. make_declare_tx ( test_contract, Some ( * OPERATOR_ADDRESS ) ) ;
902893 blob_factory. close_block ( ) . await ;
903- let _test_contract_address_0 = blob_factory. make_operator_deploy_tx (
894+ let test_contract_address_0 = blob_factory. make_operator_deploy_tx (
904895 test_contract,
905896 calldata ! [ Felt :: ZERO , Felt :: ZERO ] ,
906897 true , // charge fee
907898 ) ;
908899 blob_factory. close_block ( ) . await ;
909- let _test_contract_address_1 = blob_factory. make_operator_deploy_tx (
900+ let test_contract_address_1 = blob_factory. make_operator_deploy_tx (
910901 test_contract,
911902 calldata ! [ Felt :: ONE , Felt :: ONE ] ,
912903 true , // charge fee
913904 ) ;
905+ blob_factory. close_block ( ) . await ;
906+ blob_factory. make_operator_invoke_tx (
907+ test_contract_address_0,
908+ "test_increment" ,
909+ & [ Felt :: ZERO ; 3 ] ,
910+ true , // charge fee
911+ false , // should not revert
912+ ) ;
913+ blob_factory. close_block ( ) . await ;
914+ blob_factory. make_operator_invoke_tx (
915+ test_contract_address_1,
916+ "test_storage_read_write" ,
917+ & [ Felt :: ONE , Felt :: TWO ] ,
918+ true , // charge fee
919+ false , // should not revert
920+ ) ;
921+ blob_factory. close_block ( ) . await ;
922+ blob_factory. make_operator_invoke_tx (
923+ test_contract_address_1,
924+ "test_storage_write" ,
925+ & [ Felt :: THREE , Felt :: ONE ] ,
926+ true , // charge fee
927+ false , // should not revert
928+ ) ;
929+ blob_factory. close_block ( ) . await ;
930+ blob_factory. make_operator_invoke_tx (
931+ test_contract_address_0,
932+ "write_and_revert" ,
933+ & [ Felt :: from ( 7u8 ) , Felt :: ONE ] ,
934+ true , // charge fee
935+ true , // should revert
936+ ) ;
937+ blob_factory. close_block ( ) . await ;
938+ blob_factory. make_operator_invoke_tx (
939+ test_contract_address_1,
940+ "test_call_contract" ,
941+ & [
942+ * * test_contract_address_0,
943+ selector_from_name ( "test_storage_read_write" ) . 0 ,
944+ Felt :: TWO ,
945+ Felt :: from ( 0x1000 ) ,
946+ Felt :: from ( 0x1000 ) ,
947+ ] ,
948+ true , // charge fee
949+ false , // should not revert
950+ ) ;
951+ blob_factory. close_block ( ) . await ;
952+ blob_factory. make_operator_invoke_tx (
953+ test_contract_address_1,
954+ "write_1" ,
955+ & [ Felt :: TWO ] ,
956+ true , // charge fee
957+ false , // should not revert
958+ ) ;
959+ blob_factory. close_block ( ) . await ;
960+ blob_factory. make_operator_invoke_tx (
961+ test_contract_address_0,
962+ "catch_write_revert_panic" ,
963+ & [ * * test_contract_address_1, Felt :: from ( 0x2000 ) ] ,
964+ true , // charge fee
965+ false , // should not revert (inner error is caught)
966+ ) ;
914967
915968 let ( blobs, preconfirmed_block) = blob_factory. finalize ( ) . await ;
916969 expect_file ! [ CHAIN_INFO_PATH ] . assert_eq ( & serde_json:: to_string_pretty ( & chain_info) . unwrap ( ) ) ;
0 commit comments