From 28fcaecef8f4786312cd346b5d4077c956a6b48c Mon Sep 17 00:00:00 2001 From: Aviv Greenburg Date: Mon, 28 Oct 2024 17:43:27 +0200 Subject: [PATCH] refactor(blockifier): impl .into() from api executable tx to blockifier AccountTransaction --- crates/blockifier/src/test_utils/declare.rs | 3 ++- .../src/test_utils/deploy_account.rs | 3 ++- crates/blockifier/src/test_utils/invoke.rs | 2 +- .../transaction/account_transactions_test.rs | 21 +++++++++---------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/blockifier/src/test_utils/declare.rs b/crates/blockifier/src/test_utils/declare.rs index d78f3ff06c..798c73f244 100644 --- a/crates/blockifier/src/test_utils/declare.rs +++ b/crates/blockifier/src/test_utils/declare.rs @@ -7,6 +7,7 @@ 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); + 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 b48ae6a320..480762c3fb 100644 --- a/crates/blockifier/src/test_utils/deploy_account.rs +++ b/crates/blockifier/src/test_utils/deploy_account.rs @@ -24,5 +24,6 @@ pub fn deploy_account_tx( ); let executable_deploy_account_tx = DeployAccountTransaction::new(deploy_account_tx, tx_hash, contract_address); - 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..40218f1a51 100644 --- a/crates/blockifier/src/test_utils/invoke.rs +++ b/crates/blockifier/src/test_utils/invoke.rs @@ -27,5 +27,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 abe7d11f30..3af8e29812 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -759,17 +759,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();