From 4269d4546274430b6fcff12ee1ffb79ee5a5da4c Mon Sep 17 00:00:00 2001 From: Meshi Peled <141231558+meship-starkware@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:48:36 +0200 Subject: [PATCH] chore(blockifier): set syscall tests to get runnable version (#2543) --- .../syscalls/syscall_tests/call_contract.rs | 10 +++--- .../syscalls/syscall_tests/deploy.rs | 36 +++++++++---------- .../syscalls/syscall_tests/emit_event.rs | 32 ++++++++--------- .../syscalls/syscall_tests/get_block_hash.rs | 24 ++++++------- .../syscall_tests/get_class_hash_at.rs | 8 ++--- .../syscalls/syscall_tests/keccak.rs | 8 ++--- .../syscalls/syscall_tests/library_call.rs | 30 ++++++++-------- .../syscalls/syscall_tests/out_of_gas.rs | 8 ++--- .../syscalls/syscall_tests/replace_class.rs | 26 +++++++------- .../execution/syscalls/syscall_tests/secp.rs | 16 ++++----- .../syscall_tests/send_message_to_l1.rs | 8 ++--- .../syscalls/syscall_tests/sha256.rs | 8 ++--- .../syscall_tests/storage_read_write.rs | 8 ++--- 13 files changed, 111 insertions(+), 111 deletions(-) diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs index ab6bd202d0..dc5daa41a3 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs @@ -28,11 +28,11 @@ use crate::test_utils::{ BALANCE, }; -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native); "Native"))] -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -fn test_call_contract_that_panics(cairo_version: CairoVersion) { - let test_contract = FeatureContract::TestContract(cairo_version); - let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)); +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native; "Native"))] +#[test_case(RunnableCairo1::Casm;"VM")] +fn test_call_contract_that_panics(runnable_version: RunnableCairo1) { + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); + let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(runnable_version)); let chain_info = &ChainInfo::create_for_testing(); let mut state = test_state(chain_info, BALANCE, &[(test_contract, 1), (empty_contract, 0)]); diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs index 5fc6876ced..c2428bfeaf 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs @@ -19,12 +19,12 @@ use crate::test_utils::{ RunnableCairo1, }; -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] -fn no_constructor(cairo_version: CairoVersion) { +#[test_case(RunnableCairo1::Casm;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native;"Native"))] +fn no_constructor(runnable_version: RunnableCairo1) { // TODO(Yoni): share the init code of the tests in this file. - let deployer_contract = FeatureContract::TestContract(cairo_version); - let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)); + let deployer_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); + let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(runnable_version)); let class_hash = empty_contract.get_class_hash(); let mut state = test_state( @@ -64,11 +64,11 @@ fn no_constructor(cairo_version: CairoVersion) { assert_eq!(state.get_class_hash_at(deployed_contract_address).unwrap(), class_hash); } -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] -fn no_constructor_nonempty_calldata(cairo_version: CairoVersion) { - let deployer_contract = FeatureContract::TestContract(cairo_version); - let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)); +#[test_case(RunnableCairo1::Casm;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native;"Native"))] +fn no_constructor_nonempty_calldata(runnable_version: RunnableCairo1) { + let deployer_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); + let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(runnable_version)); let class_hash = empty_contract.get_class_hash(); let mut state = test_state( @@ -92,10 +92,10 @@ fn no_constructor_nonempty_calldata(cairo_version: CairoVersion) { )); } -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] -fn with_constructor(cairo_version: CairoVersion) { - let deployer_contract = FeatureContract::TestContract(cairo_version); +#[test_case(RunnableCairo1::Casm;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native;"Native"))] +fn with_constructor(runnable_version: RunnableCairo1) { + let deployer_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); let mut state = test_state(&ChainInfo::create_for_testing(), Fee(0), &[(deployer_contract, 1)]); let class_hash = deployer_contract.get_class_hash(); @@ -143,10 +143,10 @@ fn with_constructor(cairo_version: CairoVersion) { assert_eq!(state.get_class_hash_at(contract_address).unwrap(), class_hash); } -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] -fn to_unavailable_address(cairo_version: CairoVersion) { - let deployer_contract = FeatureContract::TestContract(cairo_version); +#[test_case(RunnableCairo1::Casm;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native;"Native"))] +fn to_unavailable_address(runnable_version: RunnableCairo1) { + let deployer_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); let mut state = test_state(&ChainInfo::create_for_testing(), Fee(0), &[(deployer_contract, 1)]); let class_hash = deployer_contract.get_class_hash(); diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs index 78e2bad691..f45e9aa257 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs @@ -26,10 +26,10 @@ const DATA: [Felt; 3] = [ ]; const N_EMITTED_EVENTS: [Felt; 1] = [Felt::from_hex_unchecked("0x1")]; -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -fn positive_flow(cairo_version: CairoVersion) { - let test_contract = FeatureContract::TestContract(cairo_version); +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native;"Native"))] +#[test_case(RunnableCairo1::Casm;"VM")] +fn positive_flow(runnable_version: RunnableCairo1) { + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); let call_info = emit_events(test_contract, &N_EMITTED_EVENTS, &KEYS, &DATA) .expect("emit_events failed with valued parameters"); let event = EventContent { @@ -47,10 +47,10 @@ fn positive_flow(cairo_version: CairoVersion) { ); } -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -fn data_length_exceeds_limit(cairo_version: CairoVersion) { - let test_contract = FeatureContract::TestContract(cairo_version); +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native;"Native"))] +#[test_case(RunnableCairo1::Casm;"VM")] +fn data_length_exceeds_limit(runnable_version: RunnableCairo1) { + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); let versioned_constants = VersionedConstants::create_for_testing(); let max_event_data_length = versioned_constants.tx_event_limits.max_data_length; @@ -67,10 +67,10 @@ fn data_length_exceeds_limit(cairo_version: CairoVersion) { assert!(error_message.contains(&expected_error.to_string())); } -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -fn keys_length_exceeds_limit(cairo_version: CairoVersion) { - let test_contract = FeatureContract::TestContract(cairo_version); +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native;"Native"))] +#[test_case(RunnableCairo1::Casm;"VM")] +fn keys_length_exceeds_limit(runnable_version: RunnableCairo1) { + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); let versioned_constants = VersionedConstants::create_for_testing(); let max_event_keys_length = versioned_constants.tx_event_limits.max_keys_length; @@ -88,10 +88,10 @@ fn keys_length_exceeds_limit(cairo_version: CairoVersion) { assert!(error_message.contains(&expected_error.to_string())); } -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] -#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] -fn event_number_exceeds_limit(cairo_version: CairoVersion) { - let test_contract = FeatureContract::TestContract(cairo_version); +#[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native;"Native"))] +#[test_case(RunnableCairo1::Casm;"VM")] +fn event_number_exceeds_limit(runnable_version: RunnableCairo1) { + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(runnable_version)); let versioned_constants = VersionedConstants::create_for_testing(); let max_n_emitted_events = versioned_constants.tx_event_limits.max_n_emitted_events; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs index 54a8eee18f..09ffe2619b 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs @@ -43,10 +43,10 @@ fn initialize_state(test_contract: FeatureContract) -> (CachedState