diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs index f3517e1f9d..c61ea66120 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs @@ -14,8 +14,8 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{calldata_for_deploy_test, trivial_external_entry_point_new, CairoVersion}; -#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1);"VM")] -fn no_constructor(deployer_contract: FeatureContract) { +#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), 204260;"VM")] +fn no_constructor(deployer_contract: FeatureContract, expected_gas: u64) { // TODO(Yoni): share the init code of the tests in this file. let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); @@ -33,6 +33,17 @@ fn no_constructor(deployer_contract: FeatureContract) { calldata, ..trivial_external_entry_point_new(deployer_contract) }; + + let deploy_call = &entry_point_call.execute_directly(&mut state).unwrap(); + assert_eq!( + deploy_call.execution, + CallExecution { + retdata: retdata![], + gas_consumed: expected_gas, + ..CallExecution::default() + } + ); + let deployed_contract_address = calculate_contract_address( ContractAddressSalt::default(), class_hash, @@ -41,11 +52,11 @@ fn no_constructor(deployer_contract: FeatureContract) { ) .unwrap(); - let deploy_call = &entry_point_call.execute_directly(&mut state).unwrap().inner_calls[0]; + let constructor_call = &deploy_call.inner_calls[0]; - assert_eq!(deploy_call.call.storage_address, deployed_contract_address); + assert_eq!(constructor_call.call.storage_address, deployed_contract_address); assert_eq!( - deploy_call.execution, + constructor_call.execution, CallExecution { retdata: retdata![], gas_consumed: 0, ..CallExecution::default() } ); assert_eq!(state.get_class_hash_at(deployed_contract_address).unwrap(), class_hash); @@ -77,8 +88,12 @@ fn no_constructor_nonempty_calldata(deployer_contract: FeatureContract) { )); } -#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), 5210;"VM")] -fn with_constructor(deployer_contract: FeatureContract, expected_gas: u64) { +#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1),214210, 5210;"VM")] +fn with_constructor( + deployer_contract: FeatureContract, + expected_gas: u64, + expected_constructor_gas: u64, +) { let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); let mut state = test_state( &ChainInfo::create_for_testing(), @@ -108,17 +123,27 @@ fn with_constructor(deployer_contract: FeatureContract, expected_gas: u64) { deployer_contract.get_instance_address(0), ) .unwrap(); - // Note, this is the call info of the constructor call (inner call). - let deploy_call = &entry_point_call.execute_directly(&mut state).unwrap().inner_calls[0]; - assert_eq!(deploy_call.call.storage_address, contract_address); + let deploy_call = &entry_point_call.execute_directly(&mut state).unwrap(); assert_eq!( deploy_call.execution, + CallExecution { + retdata: retdata![], + gas_consumed: expected_gas, + ..CallExecution::default() + } + ); + + let constructor_call = &deploy_call.inner_calls[0]; + + assert_eq!(constructor_call.call.storage_address, contract_address); + assert_eq!( + constructor_call.execution, CallExecution { // The test contract constructor returns its first argument. retdata: retdata![constructor_calldata[0]], // This reflects the gas cost of storage write syscall. - gas_consumed: expected_gas, + gas_consumed: expected_constructor_gas, ..CallExecution::default() } );