From 3f82a9f7352cd031dac20e45931f7cbf54ebb5b3 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Mon, 18 Nov 2024 11:34:29 +0200 Subject: [PATCH] chore(blockifier): dedup test util l1 handler creator --- crates/blockifier/src/test_utils/l1_handler.rs | 15 ++++++++------- .../src/transaction/transactions_test.rs | 2 ++ crates/starknet_api/src/test_utils/l1_handler.rs | 7 ++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/blockifier/src/test_utils/l1_handler.rs b/crates/blockifier/src/test_utils/l1_handler.rs index 0886536173..a57d08b8b6 100644 --- a/crates/blockifier/src/test_utils/l1_handler.rs +++ b/crates/blockifier/src/test_utils/l1_handler.rs @@ -1,9 +1,10 @@ use starknet_api::abi::abi_utils::selector_from_name; use starknet_api::calldata; -use starknet_api::core::{ContractAddress, Nonce}; +use starknet_api::core::ContractAddress; use starknet_api::executable_transaction::L1HandlerTransaction; +use starknet_api::test_utils::l1_handler::{executable_l1_handler_tx, L1HandlerTxArgs}; use starknet_api::transaction::fields::Fee; -use starknet_api::transaction::{TransactionHash, TransactionVersion}; +use starknet_api::transaction::TransactionVersion; use starknet_types_core::felt::Felt; pub fn l1handler_tx(l1_fee: Fee, contract_address: ContractAddress) -> L1HandlerTransaction { @@ -12,13 +13,13 @@ pub fn l1handler_tx(l1_fee: Fee, contract_address: ContractAddress) -> L1Handler Felt::from(0x876), // key. Felt::from(0x44) // value. ]; - let tx = starknet_api::transaction::L1HandlerTransaction { + + executable_l1_handler_tx(L1HandlerTxArgs { version: TransactionVersion::ZERO, - nonce: Nonce::default(), contract_address, entry_point_selector: selector_from_name("l1_handler_set_value"), calldata, - }; - let tx_hash = TransactionHash::default(); - L1HandlerTransaction { tx, tx_hash, paid_fee_on_l1: l1_fee } + paid_fee_on_l1: l1_fee, + ..Default::default() + }) } diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index f4cbb74e05..7ee175ec79 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -2341,6 +2341,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { ..Default::default() }, }; + assert_eq!(actual_execution_info.receipt.resources, expected_tx_resources); assert_eq!( expected_gas, @@ -2390,6 +2391,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { // Today, we check that the paid_fee is positive, no matter what was the actual fee. let expected_actual_fee = get_fee_by_gas_vector(&block_context.block_info, total_gas, &FeeType::Eth); + assert_matches!( error, TransactionExecutionError::TransactionFeeError( diff --git a/crates/starknet_api/src/test_utils/l1_handler.rs b/crates/starknet_api/src/test_utils/l1_handler.rs index 597e850024..e977469b11 100644 --- a/crates/starknet_api/src/test_utils/l1_handler.rs +++ b/crates/starknet_api/src/test_utils/l1_handler.rs @@ -49,9 +49,10 @@ pub fn executable_l1_handler_tx( l1_handler_tx_args: L1HandlerTxArgs, ) -> ExecutableL1HandlerTransaction { let tx_version = l1_handler_tx_args.version; - if tx_version != TransactionVersion::THREE { - panic!("Unsupported transaction version: {:?}.", l1_handler_tx_args.version); - } + // TODO(Arni): Re-enable this validation. + // if tx_version != TransactionVersion::THREE { + // panic!("Unsupported transaction version: {:?}.", l1_handler_tx_args.version); + // } ExecutableL1HandlerTransaction { tx: L1HandlerTransaction {