From eb1a72455f767cccd8262d0242230e2ac643453f Mon Sep 17 00:00:00 2001 From: avivg-starkware Date: Mon, 11 Nov 2024 14:14:30 +0200 Subject: [PATCH] refactor(blockifier): impl .into() from api executable tx to blockifier AccountTransaction (#1868) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …tx to account_transaction --- crates/blockifier/src/test_utils/declare.rs | 5 ++++- .../src/test_utils/deploy_account.rs | 3 ++- crates/blockifier/src/test_utils/invoke.rs | 4 +++- .../transaction/account_transactions_test.rs | 21 +++++++++---------- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/crates/blockifier/src/test_utils/declare.rs b/crates/blockifier/src/test_utils/declare.rs index d78f3ff06c..ecd48cf6be 100644 --- a/crates/blockifier/src/test_utils/declare.rs +++ b/crates/blockifier/src/test_utils/declare.rs @@ -7,6 +7,9 @@ use crate::transaction::transactions::DeclareTransaction; pub fn declare_tx(declare_tx_args: DeclareTxArgs, class_info: ClassInfo) -> AccountTransaction { let tx_hash = declare_tx_args.tx_hash; let declare_tx = starknet_api::test_utils::declare::declare_tx(declare_tx_args); + // TODO(AvivG): use starknet_api::test_utils::declare::executable_declare_tx to + // create executable_declare. + let executable_declare = DeclareTransaction::new(declare_tx, tx_hash, class_info).unwrap(); - AccountTransaction::Declare(DeclareTransaction::new(declare_tx, tx_hash, class_info).unwrap()) + executable_declare.into() } diff --git a/crates/blockifier/src/test_utils/deploy_account.rs b/crates/blockifier/src/test_utils/deploy_account.rs index 51fd5a59f1..e7f018930c 100644 --- a/crates/blockifier/src/test_utils/deploy_account.rs +++ b/crates/blockifier/src/test_utils/deploy_account.rs @@ -16,5 +16,6 @@ pub fn deploy_account_tx( // TODO(AvivG): use the "new" method. let executable_deploy_account_tx = DeployAccountTransaction { tx: deploy_account_tx, only_query: false }; - AccountTransaction::DeployAccount(executable_deploy_account_tx) + + executable_deploy_account_tx.into() } diff --git a/crates/blockifier/src/test_utils/invoke.rs b/crates/blockifier/src/test_utils/invoke.rs index d4fff4923b..2baf0877a2 100644 --- a/crates/blockifier/src/test_utils/invoke.rs +++ b/crates/blockifier/src/test_utils/invoke.rs @@ -20,6 +20,8 @@ pub fn invoke_tx(invoke_args: InvokeTxArgs) -> AccountTransaction { entry_point_selector: selector_from_name(EXECUTE_ENTRY_POINT_NAME), }) } else { + // TODO(AvivG): Have test util 'invoke_tx' support creation of TransactionVersion::ZERO + // invoke transactions. starknet_api::test_utils::invoke::invoke_tx(invoke_args) }; @@ -27,5 +29,5 @@ pub fn invoke_tx(invoke_args: InvokeTxArgs) -> AccountTransaction { true => InvokeTransaction::new_for_query(invoke_tx, tx_hash), false => InvokeTransaction::new(invoke_tx, tx_hash), }; - AccountTransaction::Invoke(invoke_tx) + invoke_tx.into() } diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index a910ae11e2..333d79c8e5 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -757,17 +757,16 @@ fn test_fail_declare(block_context: BlockContext, max_fee: Fee) { state.set_contract_class(class_hash, contract_class.clone().try_into().unwrap()).unwrap(); state.set_compiled_class_hash(class_hash, declare_tx.compiled_class_hash).unwrap(); let class_info = calculate_class_info_for_testing(contract_class); - let declare_account_tx = AccountTransaction::Declare( - DeclareTransaction::new( - starknet_api::transaction::DeclareTransaction::V2(DeclareTransactionV2 { - nonce: next_nonce, - ..declare_tx - }), - TransactionHash::default(), - class_info, - ) - .unwrap(), - ); + let declare_account_tx: AccountTransaction = DeclareTransaction::new( + starknet_api::transaction::DeclareTransaction::V2(DeclareTransactionV2 { + nonce: next_nonce, + ..declare_tx + }), + TransactionHash::default(), + class_info, + ) + .unwrap() + .into(); // Fail execution, assert nonce and balance are unchanged. let tx_info = declare_account_tx.create_tx_info();