@@ -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,
@@ -841,19 +842,9 @@ async fn test_make_data() {
841842 let mut blob_factory = BlobFactory :: new ( ) ;
842843 let chain_info = OsChainInfo :: from ( & blob_factory. chain_info ) . to_hex_map ( ) ;
843844
844- // Create the list of transactions to be included in the blobs:
845- // 1. bootstrap declare of an ERC20 contract.
846- // 2. bootstrap declare of an account with real validate.
847- // 3. deploy account (with zero fees).
848- // 4. deploy ERC20 contract from the account (with zero fees), while minting some tokens to the
849- // sender account.
850- // (from this point - all txs include non-zero fees, and no more bootstrap declares)
851- // 5. declare the test contract.
852- // 6. deploy the test contract.
853- // 7. deploy another instance of the test contract.
854- // TODO(Dori): the rest of the txs.
855- // 8. invoke the test contract: something with a state change.
856- // 9. invoke the test contract: test syscalls.
845+ // Create the list of transactions to be included in the blobs.
846+ // Block closing point is arbitrary, although it is preferable not to close after the last tx
847+ // (to ensure the preconfirmed block is not empty).
857848 let erc20_contract = FeatureContract :: ERC20 ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
858849 let account_with_real_validate = FeatureContract :: AccountWithRealValidate ( RunnableCairo1 :: Casm ) ;
859850 let test_contract = FeatureContract :: TestContract ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
@@ -883,17 +874,79 @@ async fn test_make_data() {
883874 blob_factory. close_block ( ) . await ;
884875 blob_factory. make_declare_tx ( test_contract, Some ( * OPERATOR_ADDRESS ) ) ;
885876 blob_factory. close_block ( ) . await ;
886- let _test_contract_address_0 = blob_factory. make_operator_deploy_tx (
877+ let test_contract_address_0 = blob_factory. make_operator_deploy_tx (
887878 test_contract,
888879 calldata ! [ Felt :: ZERO , Felt :: ZERO ] ,
889880 true , // charge fee
890881 ) ;
891882 blob_factory. close_block ( ) . await ;
892- let _test_contract_address_1 = blob_factory. make_operator_deploy_tx (
883+ let test_contract_address_1 = blob_factory. make_operator_deploy_tx (
893884 test_contract,
894885 calldata ! [ Felt :: ONE , Felt :: ONE ] ,
895886 true , // charge fee
896887 ) ;
888+ blob_factory. close_block ( ) . await ;
889+ blob_factory. make_operator_invoke_tx (
890+ test_contract_address_0,
891+ "test_increment" ,
892+ & [ Felt :: ZERO ; 3 ] ,
893+ true , // charge fee
894+ false , // should not revert
895+ ) ;
896+ blob_factory. close_block ( ) . await ;
897+ blob_factory. make_operator_invoke_tx (
898+ test_contract_address_1,
899+ "test_storage_read_write" ,
900+ & [ Felt :: ONE , Felt :: TWO ] ,
901+ true , // charge fee
902+ false , // should not revert
903+ ) ;
904+ blob_factory. close_block ( ) . await ;
905+ blob_factory. make_operator_invoke_tx (
906+ test_contract_address_1,
907+ "test_storage_write" ,
908+ & [ Felt :: THREE , Felt :: ONE ] ,
909+ true , // charge fee
910+ false , // should not revert
911+ ) ;
912+ blob_factory. close_block ( ) . await ;
913+ blob_factory. make_operator_invoke_tx (
914+ test_contract_address_0,
915+ "write_and_revert" ,
916+ & [ Felt :: from ( 7u8 ) , Felt :: ONE ] ,
917+ true , // charge fee
918+ true , // should revert
919+ ) ;
920+ blob_factory. close_block ( ) . await ;
921+ blob_factory. make_operator_invoke_tx (
922+ test_contract_address_1,
923+ "test_call_contract" ,
924+ & [
925+ * * test_contract_address_0,
926+ selector_from_name ( "test_storage_read_write" ) . 0 ,
927+ Felt :: TWO ,
928+ Felt :: from ( 0x1000 ) ,
929+ Felt :: from ( 0x1000 ) ,
930+ ] ,
931+ true , // charge fee
932+ false , // should not revert
933+ ) ;
934+ blob_factory. close_block ( ) . await ;
935+ blob_factory. make_operator_invoke_tx (
936+ test_contract_address_1,
937+ "write_1" ,
938+ & [ Felt :: TWO ] ,
939+ true , // charge fee
940+ false , // should not revert
941+ ) ;
942+ blob_factory. close_block ( ) . await ;
943+ blob_factory. make_operator_invoke_tx (
944+ test_contract_address_0,
945+ "catch_write_revert_panic" ,
946+ & [ * * test_contract_address_1, Felt :: from ( 0x2000 ) ] ,
947+ true , // charge fee
948+ false , // should not revert (inner error is caught)
949+ ) ;
897950
898951 let ( blobs, preconfirmed_block) = blob_factory. finalize ( ) . await ;
899952 expect_file ! [ CHAIN_INFO_PATH ] . assert_eq ( & serde_json:: to_string_pretty ( & chain_info) . unwrap ( ) ) ;
0 commit comments