diff --git a/packages/account/src/tests/extensions/test_src9.cairo b/packages/account/src/tests/extensions/test_src9.cairo index 9547ce586..20fe1c9fc 100644 --- a/packages/account/src/tests/extensions/test_src9.cairo +++ b/packages/account/src/tests/extensions/test_src9.cairo @@ -10,10 +10,8 @@ use openzeppelin_testing::constants::{RECIPIENT, OWNER, OTHER, FELT_VALUE}; use openzeppelin_utils::cryptography::snip12::OffchainMessageHash; use snforge_std::signature::KeyPairTrait; use snforge_std::signature::stark_curve::{StarkCurveKeyPairImpl, StarkCurveSignerImpl}; -use snforge_std::{ - start_cheat_caller_address, cheat_caller_address, start_cheat_block_timestamp_global -}; -use snforge_std::{test_address, load, CheatSpan}; +use snforge_std::{start_cheat_block_timestamp_global, test_address, load, CheatSpan}; +use snforge_std::{start_cheat_caller_address, cheat_caller_address}; use starknet::account::Call; use starknet::storage::StorageMapWriteAccess; use starknet::{ContractAddress, contract_address_const}; @@ -124,7 +122,7 @@ fn test_execute_from_outside_v2_uses_nonce() { } #[test] -#[should_panic(expected: ('SRC9: invalid caller',))] +#[should_panic(expected: 'SRC9: invalid caller')] fn test_execute_from_outside_v2_caller_mismatch() { let mut state = setup(); let mut outside_execution = setup_outside_execution(RECIPIENT(), false); @@ -136,7 +134,7 @@ fn test_execute_from_outside_v2_caller_mismatch() { } #[test] -#[should_panic(expected: ('SRC9: now >= execute_before',))] +#[should_panic(expected: 'SRC9: now >= execute_before')] fn test_execute_from_outside_v2_call_after_execute_before() { let mut state = setup(); let outside_execution = setup_outside_execution(RECIPIENT(), false); @@ -147,7 +145,7 @@ fn test_execute_from_outside_v2_call_after_execute_before() { } #[test] -#[should_panic(expected: ('SRC9: now >= execute_before',))] +#[should_panic(expected: 'SRC9: now >= execute_before')] fn test_execute_from_outside_v2_call_equal_to_execute_before() { let mut state = setup(); let outside_execution = setup_outside_execution(RECIPIENT(), false); @@ -158,7 +156,7 @@ fn test_execute_from_outside_v2_call_equal_to_execute_before() { } #[test] -#[should_panic(expected: ('SRC9: now <= execute_after',))] +#[should_panic(expected: 'SRC9: now <= execute_after')] fn test_execute_from_outside_v2_call_before_execute_after() { let mut state = setup(); let outside_execution = setup_outside_execution(RECIPIENT(), false); @@ -169,7 +167,7 @@ fn test_execute_from_outside_v2_call_before_execute_after() { } #[test] -#[should_panic(expected: ('SRC9: now <= execute_after',))] +#[should_panic(expected: 'SRC9: now <= execute_after')] fn test_execute_from_outside_v2_call_equal_to_execute_after() { let mut state = setup(); let outside_execution = setup_outside_execution(RECIPIENT(), false); @@ -180,7 +178,7 @@ fn test_execute_from_outside_v2_call_equal_to_execute_after() { } #[test] -#[should_panic(expected: ('SRC9: duplicated nonce',))] +#[should_panic(expected: 'SRC9: duplicated nonce')] fn test_execute_from_outside_v2_invalid_nonce() { let mut state = setup(); let outside_execution = setup_outside_execution(RECIPIENT(), false); @@ -191,7 +189,7 @@ fn test_execute_from_outside_v2_invalid_nonce() { } #[test] -#[should_panic(expected: ('SRC9: invalid signature',))] +#[should_panic(expected: 'SRC9: invalid signature')] fn test_execute_from_outside_v2_invalid_signature() { let key_pair = KeyPairTrait::generate(); let account = setup_account(key_pair.public_key); diff --git a/packages/account/src/tests/test_account.cairo b/packages/account/src/tests/test_account.cairo index 4924f3ab4..dae79c71f 100644 --- a/packages/account/src/tests/test_account.cairo +++ b/packages/account/src/tests/test_account.cairo @@ -11,15 +11,11 @@ use openzeppelin_test_common::mocks::account::DualCaseAccountMock; use openzeppelin_test_common::mocks::simple::{ISimpleMockDispatcher, ISimpleMockDispatcherTrait}; use openzeppelin_testing as utils; use openzeppelin_testing::constants::stark::{KEY_PAIR, KEY_PAIR_2}; -use openzeppelin_testing::constants::{ - SALT, ZERO, OTHER, CALLER, QUERY_OFFSET, QUERY_VERSION, MIN_TRANSACTION_VERSION -}; +use openzeppelin_testing::constants::{SALT, QUERY_OFFSET, QUERY_VERSION, MIN_TRANSACTION_VERSION}; +use openzeppelin_testing::constants::{ZERO, OTHER, CALLER}; use openzeppelin_testing::signing::StarkKeyPair; -use snforge_std::{ - start_cheat_signature_global, start_cheat_transaction_version_global, - start_cheat_transaction_hash_global -}; -use snforge_std::{spy_events, test_address, start_cheat_caller_address}; +use snforge_std::{spy_events, start_cheat_signature_global, start_cheat_transaction_hash_global}; +use snforge_std::{test_address, start_cheat_caller_address, start_cheat_transaction_version_global}; use starknet::account::Call; // @@ -48,13 +44,13 @@ fn setup_dispatcher( let contract_class = utils::declare_class("DualCaseAccountMock"); let calldata = array![key_pair.public_key]; - let address = utils::deploy(contract_class, calldata); - let dispatcher = AccountABIDispatcher { contract_address: address }; + let contract_address = utils::deploy(contract_class, calldata); + let dispatcher = AccountABIDispatcher { contract_address }; start_cheat_signature_global(array![data.r, data.s].span()); start_cheat_transaction_hash_global(data.tx_hash); start_cheat_transaction_version_global(MIN_TRANSACTION_VERSION); - start_cheat_caller_address(address, ZERO()); + start_cheat_caller_address(contract_address, ZERO()); (dispatcher, contract_class.class_hash.into()) } @@ -114,7 +110,7 @@ fn test_validate_deploy() { } #[test] -#[should_panic(expected: ('Account: invalid signature',))] +#[should_panic(expected: 'Account: invalid signature')] fn test_validate_deploy_invalid_signature_data() { let key_pair = KEY_PAIR(); let mut data = SIGNED_TX_DATA(key_pair); @@ -125,7 +121,7 @@ fn test_validate_deploy_invalid_signature_data() { } #[test] -#[should_panic(expected: ('Account: invalid signature',))] +#[should_panic(expected: 'Account: invalid signature')] fn test_validate_deploy_invalid_signature_length() { let key_pair = KEY_PAIR(); let (account, class_hash) = setup_dispatcher(key_pair, SIGNED_TX_DATA(key_pair)); @@ -136,7 +132,7 @@ fn test_validate_deploy_invalid_signature_length() { } #[test] -#[should_panic(expected: ('Account: invalid signature',))] +#[should_panic(expected: 'Account: invalid signature')] fn test_validate_deploy_empty_signature() { let key_pair = KEY_PAIR(); let (account, class_hash) = setup_dispatcher(key_pair, SIGNED_TX_DATA(key_pair)); @@ -159,7 +155,7 @@ fn test_validate_declare() { } #[test] -#[should_panic(expected: ('Account: invalid signature',))] +#[should_panic(expected: 'Account: invalid signature')] fn test_validate_declare_invalid_signature_data() { let key_pair = KEY_PAIR(); let mut data = SIGNED_TX_DATA(key_pair); @@ -170,7 +166,7 @@ fn test_validate_declare_invalid_signature_data() { } #[test] -#[should_panic(expected: ('Account: invalid signature',))] +#[should_panic(expected: 'Account: invalid signature')] fn test_validate_declare_invalid_signature_length() { let key_pair = KEY_PAIR(); let (account, class_hash) = setup_dispatcher(key_pair, SIGNED_TX_DATA(key_pair)); @@ -181,7 +177,7 @@ fn test_validate_declare_invalid_signature_length() { } #[test] -#[should_panic(expected: ('Account: invalid signature',))] +#[should_panic(expected: 'Account: invalid signature')] fn test_validate_declare_empty_signature() { let key_pair = KEY_PAIR(); let (account, class_hash) = setup_dispatcher(key_pair, SIGNED_TX_DATA(key_pair)); @@ -197,16 +193,14 @@ fn test_execute_with_version(version: Option) { // Deploy target contract let calldata = array![]; - let address = utils::declare_and_deploy("SimpleMock", calldata); - let simple_mock = ISimpleMockDispatcher { contract_address: address }; + let contract_address = utils::declare_and_deploy("SimpleMock", calldata); + let simple_mock = ISimpleMockDispatcher { contract_address }; // Craft call and add to calls array let amount = 200; let calldata = array![amount]; let call = Call { - to: simple_mock.contract_address, - selector: selector!("increase_balance"), - calldata: calldata.span() + to: contract_address, selector: selector!("increase_balance"), calldata: calldata.span() }; let calls = array![call]; @@ -243,7 +237,7 @@ fn test_execute_query_version() { } #[test] -#[should_panic(expected: ('Account: invalid tx version',))] +#[should_panic(expected: 'Account: invalid tx version')] fn test_execute_invalid_query_version() { test_execute_with_version(Option::Some(QUERY_OFFSET)); } @@ -254,7 +248,7 @@ fn test_execute_future_query_version() { } #[test] -#[should_panic(expected: ('Account: invalid tx version',))] +#[should_panic(expected: 'Account: invalid tx version')] fn test_execute_invalid_version() { test_execute_with_version(Option::Some(MIN_TRANSACTION_VERSION - 1)); } @@ -270,7 +264,7 @@ fn test_validate() { } #[test] -#[should_panic(expected: ('Account: invalid signature',))] +#[should_panic(expected: 'Account: invalid signature')] fn test_validate_invalid() { let key_pair = KEY_PAIR(); let mut data = SIGNED_TX_DATA(key_pair); @@ -288,25 +282,21 @@ fn test_multicall() { // Deploy target contract let calldata = array![]; - let address = utils::declare_and_deploy("SimpleMock", calldata); - let simple_mock = ISimpleMockDispatcher { contract_address: address }; + let contract_address = utils::declare_and_deploy("SimpleMock", calldata); + let simple_mock = ISimpleMockDispatcher { contract_address }; // Craft 1st call let amount1 = 300; let calldata1 = array![amount1]; let call1 = Call { - to: simple_mock.contract_address, - selector: selector!("increase_balance"), - calldata: calldata1.span() + to: contract_address, selector: selector!("increase_balance"), calldata: calldata1.span() }; // Craft 2nd call let amount2 = 500; let calldata2 = array![amount2]; let call2 = Call { - to: simple_mock.contract_address, - selector: selector!("increase_balance"), - calldata: calldata2.span() + to: contract_address, selector: selector!("increase_balance"), calldata: calldata2.span() }; // Bundle calls and execute @@ -339,7 +329,7 @@ fn test_multicall_zero_calls() { } #[test] -#[should_panic(expected: ('Account: invalid caller',))] +#[should_panic(expected: 'Account: invalid caller')] fn test_account_called_from_contract() { let state = setup(KEY_PAIR()); let account_address = test_address(); @@ -379,7 +369,7 @@ fn test_public_key_setter_and_getter() { } #[test] -#[should_panic(expected: ('Account: unauthorized',))] +#[should_panic(expected: 'Account: unauthorized')] fn test_public_key_setter_different_account() { let mut state = COMPONENT_STATE(); let account_address = test_address(); @@ -418,7 +408,7 @@ fn test_public_key_setter_and_getter_camel() { } #[test] -#[should_panic(expected: ('Account: unauthorized',))] +#[should_panic(expected: 'Account: unauthorized')] fn test_public_key_setter_different_account_camel() { let mut state = COMPONENT_STATE(); let account_address = test_address(); @@ -462,7 +452,7 @@ fn test_assert_only_self_true() { } #[test] -#[should_panic(expected: ('Account: unauthorized',))] +#[should_panic(expected: 'Account: unauthorized')] fn test_assert_only_self_false() { let mut state = COMPONENT_STATE(); let account_address = test_address(); @@ -487,7 +477,7 @@ fn test_assert_valid_new_owner() { #[test] -#[should_panic(expected: ('Account: invalid signature',))] +#[should_panic(expected: 'Account: invalid signature')] fn test_assert_valid_new_owner_invalid_signature() { let key_pair = KEY_PAIR(); let state = setup(key_pair); diff --git a/packages/account/src/tests/test_eth_account.cairo b/packages/account/src/tests/test_eth_account.cairo index 7c844a075..49ae89e2a 100644 --- a/packages/account/src/tests/test_eth_account.cairo +++ b/packages/account/src/tests/test_eth_account.cairo @@ -14,16 +14,12 @@ use openzeppelin_test_common::mocks::account::DualCaseEthAccountMock; use openzeppelin_test_common::mocks::simple::{ISimpleMockDispatcher, ISimpleMockDispatcherTrait}; use openzeppelin_testing as utils; use openzeppelin_testing::constants::secp256k1::{KEY_PAIR, KEY_PAIR_2}; -use openzeppelin_testing::constants::{ - SALT, ZERO, OTHER, CALLER, QUERY_VERSION, MIN_TRANSACTION_VERSION -}; +use openzeppelin_testing::constants::{SALT, QUERY_VERSION, MIN_TRANSACTION_VERSION}; +use openzeppelin_testing::constants::{ZERO, OTHER, CALLER}; use openzeppelin_testing::signing::Secp256k1KeyPair; use openzeppelin_utils::serde::SerializedAppend; -use snforge_std::{ - start_cheat_signature_global, start_cheat_transaction_version_global, - start_cheat_transaction_hash_global, start_cheat_caller_address -}; -use snforge_std::{spy_events, test_address}; +use snforge_std::{spy_events, start_cheat_signature_global, start_cheat_transaction_hash_global}; +use snforge_std::{test_address, start_cheat_caller_address, start_cheat_transaction_version_global}; use starknet::account::Call; // @@ -135,7 +131,7 @@ fn test_validate_deploy() { } #[test] -#[should_panic(expected: ('EthAccount: invalid signature',))] +#[should_panic(expected: 'EthAccount: invalid signature')] fn test_validate_deploy_invalid_signature_data() { let key_pair = KEY_PAIR(); let mut data = SIGNED_TX_DATA(key_pair); @@ -146,7 +142,7 @@ fn test_validate_deploy_invalid_signature_data() { } #[test] -#[should_panic(expected: ('Signature: Invalid format.',))] +#[should_panic(expected: 'Signature: Invalid format.')] fn test_validate_deploy_invalid_signature_length() { let key_pair = KEY_PAIR(); let (account, class_hash) = setup_dispatcher(key_pair, SIGNED_TX_DATA(key_pair)); @@ -158,7 +154,7 @@ fn test_validate_deploy_invalid_signature_length() { } #[test] -#[should_panic(expected: ('Signature: Invalid format.',))] +#[should_panic(expected: 'Signature: Invalid format.')] fn test_validate_deploy_empty_signature() { let key_pair = KEY_PAIR(); let (account, class_hash) = setup_dispatcher(key_pair, SIGNED_TX_DATA(key_pair)); @@ -181,7 +177,7 @@ fn test_validate_declare() { } #[test] -#[should_panic(expected: ('EthAccount: invalid signature',))] +#[should_panic(expected: 'EthAccount: invalid signature')] fn test_validate_declare_invalid_signature_data() { let key_pair = KEY_PAIR(); let mut data = SIGNED_TX_DATA(key_pair); @@ -192,7 +188,7 @@ fn test_validate_declare_invalid_signature_data() { } #[test] -#[should_panic(expected: ('Signature: Invalid format.',))] +#[should_panic(expected: 'Signature: Invalid format.')] fn test_validate_declare_invalid_signature_length() { let key_pair = KEY_PAIR(); let (account, class_hash) = setup_dispatcher(key_pair, SIGNED_TX_DATA(key_pair)); @@ -204,7 +200,7 @@ fn test_validate_declare_invalid_signature_length() { } #[test] -#[should_panic(expected: ('Signature: Invalid format.',))] +#[should_panic(expected: 'Signature: Invalid format.')] fn test_validate_declare_empty_signature() { let key_pair = KEY_PAIR(); let (account, class_hash) = setup_dispatcher(key_pair, SIGNED_TX_DATA(key_pair)); @@ -222,16 +218,14 @@ fn test_execute_with_version(version: Option) { // Deploy target contract let calldata = array![]; - let address = utils::declare_and_deploy("SimpleMock", calldata); - let simple_mock = ISimpleMockDispatcher { contract_address: address }; + let contract_address = utils::declare_and_deploy("SimpleMock", calldata); + let simple_mock = ISimpleMockDispatcher { contract_address }; // Craft call and add to calls array let amount = 200; let calldata = array![amount]; let call = Call { - to: simple_mock.contract_address, - selector: selector!("increase_balance"), - calldata: calldata.span() + to: contract_address, selector: selector!("increase_balance"), calldata: calldata.span() }; let calls = array![call]; @@ -297,25 +291,21 @@ fn test_multicall() { // Deploy target contract let calldata = array![]; - let address = utils::declare_and_deploy("SimpleMock", calldata); - let simple_mock = ISimpleMockDispatcher { contract_address: address }; + let contract_address = utils::declare_and_deploy("SimpleMock", calldata); + let simple_mock = ISimpleMockDispatcher { contract_address }; // Craft 1st call let amount1 = 300; let calldata1 = array![amount1]; let call1 = Call { - to: simple_mock.contract_address, - selector: selector!("increase_balance"), - calldata: calldata1.span() + to: contract_address, selector: selector!("increase_balance"), calldata: calldata1.span() }; // Craft 2nd call let amount2 = 500; let calldata2 = array![amount2]; let call2 = Call { - to: simple_mock.contract_address, - selector: selector!("increase_balance"), - calldata: calldata2.span() + to: contract_address, selector: selector!("increase_balance"), calldata: calldata2.span() }; // Bundle calls and execute @@ -407,7 +397,7 @@ fn test_public_key_setter_and_getter() { } #[test] -#[should_panic(expected: ('EthAccount: unauthorized',))] +#[should_panic(expected: 'EthAccount: unauthorized')] fn test_public_key_setter_different_account() { let mut state = COMPONENT_STATE(); let key_pair = KEY_PAIR(); @@ -451,7 +441,7 @@ fn test_public_key_setter_and_getter_camel() { } #[test] -#[should_panic(expected: ('EthAccount: unauthorized',))] +#[should_panic(expected: 'EthAccount: unauthorized')] fn test_public_key_setter_different_account_camel() { let mut state = COMPONENT_STATE(); let key_pair = KEY_PAIR(); @@ -499,7 +489,7 @@ fn test_assert_only_self_true() { } #[test] -#[should_panic(expected: ('EthAccount: unauthorized',))] +#[should_panic(expected: 'EthAccount: unauthorized')] fn test_assert_only_self_false() { let state = COMPONENT_STATE(); @@ -522,7 +512,7 @@ fn test_assert_valid_new_owner() { } #[test] -#[should_panic(expected: ('EthAccount: invalid signature',))] +#[should_panic(expected: 'EthAccount: invalid signature')] fn test_assert_valid_new_owner_invalid_signature() { let key_pair = KEY_PAIR(); let state = setup(key_pair); diff --git a/packages/account/src/tests/test_signature.cairo b/packages/account/src/tests/test_signature.cairo index f7841b2b3..0d6e9d648 100644 --- a/packages/account/src/tests/test_signature.cairo +++ b/packages/account/src/tests/test_signature.cairo @@ -83,7 +83,7 @@ fn test_is_valid_eth_signature_bad_sig() { } #[test] -#[should_panic(expected: ('Signature: Invalid format.',))] +#[should_panic(expected: 'Signature: Invalid format.')] fn test_is_valid_eth_signature_invalid_format_sig() { let key_pair = secp256k1::KEY_PAIR(); let data = eth_signature_data(key_pair);