Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(blockifier): dedup test util l1 handler creator #2131

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions crates/blockifier/src/test_utils/l1_handler.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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()
})
}
2 changes: 2 additions & 0 deletions crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 1 addition & 6 deletions crates/starknet_api/src/test_utils/l1_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,9 @@ macro_rules! l1_handler_tx_args {
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);
}

ExecutableL1HandlerTransaction {
tx: L1HandlerTransaction {
version: tx_version,
version: l1_handler_tx_args.version,
nonce: l1_handler_tx_args.nonce,
contract_address: l1_handler_tx_args.contract_address,
entry_point_selector: l1_handler_tx_args.entry_point_selector,
Expand Down
Loading