@@ -1003,10 +1003,8 @@ async fn test_v1_bound_accounts_cairo1() {
10031003}
10041004
10051005#[ rstest]
1006- #[ case:: use_kzg( true , 5 ) ]
1007- #[ case:: not_use_kzg( false , 1 ) ]
10081006#[ tokio:: test]
1009- async fn test_new_class_flow ( #[ case ] use_kzg_da : bool , # [ case ] n_blocks_in_multi_block : usize ) {
1007+ async fn test_new_class_execution_info ( #[ values ( true , false ) ] use_kzg_da : bool ) {
10101008 let test_contract = FeatureContract :: TestContract ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
10111009 let test_class_hash = get_class_hash_of_feature_contract ( test_contract) ;
10121010 let ( mut test_manager, [ main_contract_address] ) =
@@ -1022,27 +1020,6 @@ async fn test_new_class_flow(#[case] use_kzg_da: bool, #[case] n_blocks_in_multi
10221020 "Current block number must be greater than STORED_BLOCK_HASH_BUFFER for the test to work."
10231021 ) ;
10241022
1025- // Prepare expected storage updates.
1026- let mut expected_messages_to_l1 = Vec :: new ( ) ;
1027- let mut expected_storage_updates = HashMap :: new ( ) ;
1028-
1029- // Call test_increment twice.
1030- let n_calls: u8 = 2 ;
1031- for _ in 0 ..n_calls {
1032- let calldata = create_calldata (
1033- main_contract_address,
1034- "test_increment" ,
1035- & [ felt ! ( 5u8 ) , felt ! ( 6u8 ) , felt ! ( 7u8 ) ] ,
1036- ) ;
1037- test_manager. add_funded_account_invoke ( invoke_tx_args ! { calldata } ) ;
1038- }
1039- update_expected_storage (
1040- & mut expected_storage_updates,
1041- main_contract_address,
1042- * * get_storage_var_address ( "my_storage_var" , & [ ] ) ,
1043- Felt :: from ( n_calls) ,
1044- ) ;
1045-
10461023 // Test get_execution_info; invoke a function that gets the expected execution info and compares
10471024 // it to the actual.
10481025 let test_execution_info_selector_name = "test_get_execution_info" ;
@@ -1149,7 +1126,80 @@ async fn test_new_class_flow(#[case] use_kzg_da: bool, #[case] n_blocks_in_multi
11491126 None ,
11501127 ) ;
11511128
1129+ // Run the test.
1130+ let test_output = test_manager
1131+ . execute_test_with_default_block_contexts ( & TestParameters {
1132+ use_kzg_da,
1133+ ..Default :: default ( )
1134+ } )
1135+ . await ;
1136+
1137+ // Perform general validations and storage update validations.
1138+ test_output. perform_default_validations ( ) ;
1139+
1140+ // Verify that the funded account, the new account and the sequencer all have changed balances.
1141+ test_output. assert_account_balance_change ( * FUNDED_ACCOUNT_ADDRESS ) ;
1142+ test_output. assert_account_balance_change ( contract_address ! ( TEST_SEQUENCER_ADDRESS ) ) ;
1143+
1144+ // Validate poseidon usage.
1145+ // TODO(Meshi): Add blake opcode validations.
1146+ let poseidons = test_output. get_builtin_usage ( & BuiltinName :: poseidon) ;
1147+ if use_kzg_da {
1148+ expect ! [ [ r#"
1149+ 104
1150+ "# ] ]
1151+ . assert_debug_eq ( & poseidons) ;
1152+ } else {
1153+ expect ! [ [ r#"
1154+ 96
1155+ "# ] ]
1156+ . assert_debug_eq ( & poseidons) ;
1157+ }
1158+ }
1159+
1160+ #[ rstest]
1161+ #[ case:: use_kzg( true , 5 ) ]
1162+ #[ case:: not_use_kzg( false , 1 ) ]
1163+ #[ tokio:: test]
1164+ async fn test_new_class_flow ( #[ case] use_kzg_da : bool , #[ case] n_blocks_in_multi_block : usize ) {
1165+ let test_contract = FeatureContract :: TestContract ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
1166+ let test_class_hash = get_class_hash_of_feature_contract ( test_contract) ;
1167+ let ( mut test_manager, [ main_contract_address, contract_address2] ) =
1168+ TestManager :: < DictStateReader > :: new_with_default_initial_state ( [
1169+ ( test_contract, calldata ! [ Felt :: ZERO , Felt :: ZERO ] ) ,
1170+ ( test_contract, calldata ! [ Felt :: ZERO , Felt :: ZERO ] ) ,
1171+ ] )
1172+ . await ;
1173+ let current_block_number = test_manager. initial_state . next_block_number ;
1174+
1175+ assert ! (
1176+ current_block_number. 0 > STORED_BLOCK_HASH_BUFFER ,
1177+ "Current block number must be greater than STORED_BLOCK_HASH_BUFFER for the test to work."
1178+ ) ;
1179+
1180+ // Prepare expected storage updates.
1181+ let mut expected_messages_to_l1 = Vec :: new ( ) ;
1182+ let mut expected_storage_updates = HashMap :: new ( ) ;
1183+
1184+ // Call test_increment twice.
1185+ let n_calls: u8 = 2 ;
1186+ for _ in 0 ..n_calls {
1187+ let calldata = create_calldata (
1188+ main_contract_address,
1189+ "test_increment" ,
1190+ & [ felt ! ( 5u8 ) , felt ! ( 6u8 ) , felt ! ( 7u8 ) ] ,
1191+ ) ;
1192+ test_manager. add_funded_account_invoke ( invoke_tx_args ! { calldata } ) ;
1193+ }
1194+ update_expected_storage (
1195+ & mut expected_storage_updates,
1196+ main_contract_address,
1197+ * * get_storage_var_address ( "my_storage_var" , & [ ] ) ,
1198+ Felt :: from ( n_calls) ,
1199+ ) ;
1200+
11521201 // Test calling test_storage_read_write.
1202+ let test_call_contract_selector_name = "test_call_contract" ;
11531203 let test_call_contract_key = Felt :: from ( 1948 ) ;
11541204 let test_call_contract_value = Felt :: from ( 1967 ) ;
11551205 let calldata = create_calldata (
@@ -1518,12 +1568,12 @@ async fn test_new_class_flow(#[case] use_kzg_da: bool, #[case] n_blocks_in_multi
15181568 let poseidons = test_output. get_builtin_usage ( & BuiltinName :: poseidon) ;
15191569 if use_kzg_da {
15201570 expect ! [ [ r#"
1521- 679
1571+ 598
15221572 "# ] ]
15231573 . assert_debug_eq ( & poseidons) ;
15241574 } else {
15251575 expect ! [ [ r#"
1526- 562
1576+ 490
15271577 "# ] ]
15281578 . assert_debug_eq ( & poseidons) ;
15291579 }
0 commit comments