diff --git a/crates/blockifier/src/test_utils/struct_impls.rs b/crates/blockifier/src/test_utils/struct_impls.rs index 60c722fcd7..664041671c 100644 --- a/crates/blockifier/src/test_utils/struct_impls.rs +++ b/crates/blockifier/src/test_utils/struct_impls.rs @@ -3,11 +3,13 @@ use std::sync::Arc; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use serde_json::Value; use starknet_api::block::{BlockNumber, BlockTimestamp}; -use starknet_api::core::{ChainId, ContractAddress, PatriciaKey}; -use starknet_api::transaction::Fee; -use starknet_api::{contract_address, felt, patricia_key}; +use starknet_api::core::{ChainId, ContractAddress, Nonce, PatriciaKey}; +use starknet_api::transaction::{Calldata, Fee, TransactionHash, TransactionVersion}; +use starknet_api::{calldata, contract_address, felt, patricia_key}; +use starknet_types_core::felt::Felt; use super::update_json_value; +use crate::abi::abi_utils::selector_from_name; use crate::blockifier::block::{BlockInfo, GasPrices}; use crate::bouncer::{BouncerConfig, BouncerWeights}; use crate::context::{BlockContext, ChainInfo, FeeTokenAddresses, TransactionContext}; @@ -40,6 +42,7 @@ use crate::transaction::objects::{ TransactionInfo, TransactionResources, }; +use crate::transaction::transactions::L1HandlerTransaction; use crate::versioned_constants::{ GasCosts, OsConstants, @@ -230,3 +233,22 @@ impl ContractClassV1 { Self::try_from_json_string(&raw_contract_class).unwrap() } } + +impl L1HandlerTransaction { + pub fn create_for_testing(l1_fee: Fee, contract_address: ContractAddress) -> Self { + let calldata = calldata![ + Felt::from(0x123), // from_address. + Felt::from(0x876), // key. + Felt::from(0x44) // value. + ]; + let tx = starknet_api::transaction::L1HandlerTransaction { + version: TransactionVersion::ZERO, + nonce: Nonce::default(), + contract_address, + entry_point_selector: selector_from_name("l1_handler_set_value"), + calldata, + }; + let tx_hash = TransactionHash::default(); + Self { tx, tx_hash, paid_fee_on_l1: l1_fee } + } +} diff --git a/crates/blockifier/src/transaction/transactions.rs b/crates/blockifier/src/transaction/transactions.rs index 9a7f39865b..834660c740 100644 --- a/crates/blockifier/src/transaction/transactions.rs +++ b/crates/blockifier/src/transaction/transactions.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; -use starknet_api::calldata; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::transaction::{ @@ -15,7 +14,6 @@ use starknet_api::transaction::{ TransactionSignature, TransactionVersion, }; -use starknet_types_core::felt::Felt; use crate::abi::abi_utils::selector_from_name; use crate::context::{BlockContext, TransactionContext}; @@ -507,23 +505,6 @@ impl L1HandlerTransaction { // The calldata includes the "from" field, which is not a part of the payload. self.tx.calldata.0.len() - 1 } - - pub fn create_for_testing(l1_fee: Fee, contract_address: ContractAddress) -> Self { - let calldata = calldata![ - Felt::from(0x123), // from_address. - Felt::from(0x876), // key. - Felt::from(0x44) // value. - ]; - let tx = starknet_api::transaction::L1HandlerTransaction { - version: TransactionVersion::ZERO, - nonce: Nonce::default(), - contract_address, - entry_point_selector: selector_from_name("l1_handler_set_value"), - calldata, - }; - let tx_hash = TransactionHash::default(); - Self { tx, tx_hash, paid_fee_on_l1: l1_fee } - } } impl HasRelatedFeeType for L1HandlerTransaction { diff --git a/crates/gateway/src/config.rs b/crates/gateway/src/config.rs index 49970fa7a0..5afb8eb18a 100644 --- a/crates/gateway/src/config.rs +++ b/crates/gateway/src/config.rs @@ -209,6 +209,7 @@ impl Default for ChainInfoConfig { } impl ChainInfoConfig { + #[cfg(any(test, feature = "testing"))] pub fn create_for_testing() -> Self { BlockContext::create_for_testing().chain_info().clone().into() } @@ -286,6 +287,7 @@ impl SerializeConfig for StatefulTransactionValidatorConfig { } impl StatefulTransactionValidatorConfig { + #[cfg(any(test, feature = "testing"))] pub fn create_for_testing() -> Self { StatefulTransactionValidatorConfig { max_nonce_for_validation_skip: Default::default(),