@@ -1140,18 +1140,65 @@ async fn test_new_class_execution_info(#[values(true, false)] use_kzg_da: bool)
11401140 // Verify that the funded account, the new account and the sequencer all have changed balances.
11411141 test_output. assert_account_balance_change ( * FUNDED_ACCOUNT_ADDRESS ) ;
11421142 test_output. assert_account_balance_change ( contract_address ! ( TEST_SEQUENCER_ADDRESS ) ) ;
1143+ }
1144+
1145+ #[ rstest]
1146+ #[ tokio:: test]
1147+ async fn test_experimental_libfuncs_contract ( #[ values( true , false ) ] use_kzg_da : bool ) {
1148+ let ( mut test_manager, [ ] ) =
1149+ TestManager :: < DictStateReader > :: new_with_default_initial_state ( [ ] ) . await ;
1150+
1151+ // Declare the experimental contract.
1152+ // Test the bootstrap variant of the V3 transaction.
1153+ let experimental_contract = FeatureContract :: Experimental ;
1154+ let experimental_contract_sierra = experimental_contract. get_sierra ( ) ;
1155+ let experimental_class_hash = experimental_contract_sierra. calculate_class_hash ( ) ;
1156+ let experimental_compiled_class_hash =
1157+ experimental_contract. get_compiled_class_hash ( & HashVersion :: V2 ) ;
1158+ let declare_tx_args = declare_tx_args ! {
1159+ signature: TransactionSignature :: default ( ) ,
1160+ sender_address: DeclareTransaction :: bootstrap_address( ) ,
1161+ resource_bounds: ValidResourceBounds :: create_for_testing_no_fee_enforcement( ) ,
1162+ nonce: Nonce ( Felt :: ZERO ) ,
1163+ class_hash: experimental_class_hash,
1164+ compiled_class_hash: experimental_compiled_class_hash,
1165+ } ;
1166+ let account_declare_tx = declare_tx ( declare_tx_args) ;
1167+ let class_info = get_class_info_of_feature_contract ( experimental_contract) ;
1168+ let tx =
1169+ DeclareTransaction :: create ( account_declare_tx, class_info, & CHAIN_ID_FOR_TESTS ) . unwrap ( ) ;
1170+ test_manager. add_cairo1_declare_tx ( tx, & experimental_contract_sierra) ;
1171+
1172+ // Deploy it.
1173+ let salt = ContractAddressSalt ( Felt :: ZERO ) ;
1174+ let ( deploy_tx, _experimental_contract_address) = get_deploy_contract_tx_and_address_with_salt (
1175+ experimental_class_hash,
1176+ Calldata :: default ( ) ,
1177+ test_manager. next_nonce ( * FUNDED_ACCOUNT_ADDRESS ) ,
1178+ * NON_TRIVIAL_RESOURCE_BOUNDS ,
1179+ salt,
1180+ ) ;
1181+ test_manager. add_invoke_tx ( deploy_tx, None ) ;
1182+
1183+ let test_output = test_manager
1184+ . execute_test_with_default_block_contexts ( & TestParameters {
1185+ use_kzg_da,
1186+ ..Default :: default ( )
1187+ } )
1188+ . await ;
1189+ test_output. perform_default_validations ( ) ;
11431190
11441191 // Validate poseidon usage.
11451192 // TODO(Meshi): Add blake opcode validations.
11461193 let poseidons = test_output. get_builtin_usage ( & BuiltinName :: poseidon) ;
11471194 if use_kzg_da {
11481195 expect ! [ [ r#"
1149- 104
1196+ 58
11501197 "# ] ]
11511198 . assert_debug_eq ( & poseidons) ;
11521199 } else {
11531200 expect ! [ [ r#"
1154- 96
1201+ 49
11551202 "# ] ]
11561203 . assert_debug_eq ( & poseidons) ;
11571204 }
@@ -1351,38 +1398,6 @@ async fn test_new_class_flow(#[case] use_kzg_da: bool, #[case] n_blocks_in_multi
13511398 create_calldata ( main_contract_address, "test_signature_verification_secp256r1" , & [ ] ) ;
13521399 test_manager. add_funded_account_invoke ( invoke_tx_args ! { calldata } ) ;
13531400
1354- // Declare the experimental contract.
1355- // Test the bootstrap variant of the V3 transaction.
1356- let experimental_contract = FeatureContract :: Experimental ;
1357- let experimental_contract_sierra = experimental_contract. get_sierra ( ) ;
1358- let experimental_class_hash = experimental_contract_sierra. calculate_class_hash ( ) ;
1359- let experimental_compiled_class_hash =
1360- experimental_contract. get_compiled_class_hash ( & HashVersion :: V2 ) ;
1361- let declare_tx_args = declare_tx_args ! {
1362- signature: TransactionSignature :: default ( ) ,
1363- sender_address: DeclareTransaction :: bootstrap_address( ) ,
1364- resource_bounds: ValidResourceBounds :: create_for_testing_no_fee_enforcement( ) ,
1365- nonce: Nonce ( Felt :: ZERO ) ,
1366- class_hash: experimental_class_hash,
1367- compiled_class_hash: experimental_compiled_class_hash,
1368- } ;
1369- let account_declare_tx = declare_tx ( declare_tx_args) ;
1370- let class_info = get_class_info_of_feature_contract ( experimental_contract) ;
1371- let tx =
1372- DeclareTransaction :: create ( account_declare_tx, class_info, & CHAIN_ID_FOR_TESTS ) . unwrap ( ) ;
1373- test_manager. add_cairo1_declare_tx ( tx, & experimental_contract_sierra) ;
1374-
1375- // Deploy it.
1376- let salt = ContractAddressSalt ( Felt :: ZERO ) ;
1377- let ( deploy_tx, _experimental_contract_address) = get_deploy_contract_tx_and_address_with_salt (
1378- experimental_class_hash,
1379- Calldata :: default ( ) ,
1380- test_manager. next_nonce ( * FUNDED_ACCOUNT_ADDRESS ) ,
1381- * NON_TRIVIAL_RESOURCE_BOUNDS ,
1382- salt,
1383- ) ;
1384- test_manager. add_invoke_tx ( deploy_tx, None ) ;
1385-
13861401 // Call test_sha256.
13871402 let calldata = create_calldata ( main_contract_address, "test_sha256" , & [ ] ) ;
13881403 test_manager. add_funded_account_invoke ( invoke_tx_args ! { calldata } ) ;
@@ -1565,19 +1580,4 @@ async fn test_new_class_flow(#[case] use_kzg_da: bool, #[case] n_blocks_in_multi
15651580 test_output. assert_account_balance_change ( * FUNDED_ACCOUNT_ADDRESS ) ;
15661581 test_output. assert_account_balance_change ( faulty_account_address) ;
15671582 test_output. assert_account_balance_change ( contract_address ! ( TEST_SEQUENCER_ADDRESS ) ) ;
1568-
1569- // Validate poseidon usage.
1570- // TODO(Meshi): Add blake opcode validations.
1571- let poseidons = test_output. get_builtin_usage ( & BuiltinName :: poseidon) ;
1572- if use_kzg_da {
1573- expect ! [ [ r#"
1574- 598
1575- "# ] ]
1576- . assert_debug_eq ( & poseidons) ;
1577- } else {
1578- expect ! [ [ r#"
1579- 490
1580- "# ] ]
1581- . assert_debug_eq ( & poseidons) ;
1582- }
15831583}
0 commit comments