Skip to content

Commit

Permalink
chore: use the imports inside the macro in mempool test utils (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware authored Oct 13, 2024
1 parent 881c4b0 commit b602259
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
11 changes: 0 additions & 11 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
use std::cmp::Reverse;

use mempool_test_utils::starknet_api_test_utils::VALID_L2_GAS_MAX_PRICE_PER_UNIT;
use pretty_assertions::assert_eq;
use rstest::{fixture, rstest};
use starknet_api::block::GasPrice;
use starknet_api::core::{ContractAddress, PatriciaKey};
use starknet_api::executable_transaction::Transaction;
use starknet_api::hash::StarkHash;
use starknet_api::test_utils::invoke::executable_invoke_tx;
use starknet_api::transaction::{
AllResourceBounds,
ResourceBounds,
Tip,
TransactionHash,
ValidResourceBounds,
};
use starknet_api::{contract_address, felt, invoke_tx_args, nonce, patricia_key};
use starknet_mempool_types::errors::MempoolError;
use starknet_mempool_types::mempool_types::{AccountState, AddTransactionArgs};

use crate::mempool::{Mempool, TransactionReference};
use crate::test_utils::{add_tx, add_tx_expect_error, commit_block, get_txs_and_assert_expected};
Expand Down
21 changes: 19 additions & 2 deletions crates/mempool/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ use crate::mempool::Mempool;
macro_rules! tx {
(tip: $tip:expr, tx_hash: $tx_hash:expr, sender_address: $sender_address:expr,
tx_nonce: $tx_nonce:expr, max_l2_gas_price: $max_l2_gas_price:expr) => {{
use starknet_api::block::GasPrice;
use starknet_api::executable_transaction::Transaction;
use starknet_api::hash::StarkHash;
use starknet_api::test_utils::invoke::executable_invoke_tx;
use starknet_api::transaction::{
AllResourceBounds,
ResourceBounds,
Tip,
TransactionHash,
ValidResourceBounds,
};
use mempool_test_utils::starknet_api_test_utils::VALID_L2_GAS_MAX_PRICE_PER_UNIT;


let resource_bounds = ValidResourceBounds::AllResources(AllResourceBounds {
l2_gas: ResourceBounds {
max_price_per_unit: $max_l2_gas_price.into(),
Expand Down Expand Up @@ -59,10 +73,13 @@ macro_rules! tx {
macro_rules! add_tx_input {
(tip: $tip:expr, tx_hash: $tx_hash:expr, sender_address: $sender_address:expr,
tx_nonce: $tx_nonce:expr, account_nonce: $account_nonce:expr, max_l2_gas_price: $max_l2_gas_price:expr) => {{
let tx = tx!(tip: $tip, tx_hash: $tx_hash, sender_address: $sender_address, tx_nonce: $tx_nonce, max_l2_gas_price: $max_l2_gas_price);
use starknet_api::{contract_address, nonce};
use starknet_mempool_types::mempool_types::{AccountState, AddTransactionArgs};

let tx = $crate::tx!(tip: $tip, tx_hash: $tx_hash, sender_address: $sender_address, tx_nonce: $tx_nonce, max_l2_gas_price: $max_l2_gas_price);
let address = contract_address!($sender_address);
let account_nonce = nonce!($account_nonce);
let account_state = AccountState { address, nonce: account_nonce};
let account_state = AccountState {address, nonce: account_nonce};

AddTransactionArgs { tx, account_state }
}};
Expand Down
14 changes: 1 addition & 13 deletions crates/mempool/tests/flow_test.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
use mempool_test_utils::starknet_api_test_utils::VALID_L2_GAS_MAX_PRICE_PER_UNIT;
use rstest::{fixture, rstest};
use starknet_api::core::{ContractAddress, PatriciaKey};
use starknet_api::executable_transaction::Transaction;
use starknet_api::hash::StarkHash;
use starknet_api::test_utils::invoke::executable_invoke_tx;
use starknet_api::transaction::{
AllResourceBounds,
ResourceBounds,
Tip,
TransactionHash,
ValidResourceBounds,
};
use starknet_api::{contract_address, felt, invoke_tx_args, nonce, patricia_key};
use starknet_mempool::add_tx_input;
use starknet_mempool::mempool::Mempool;
use starknet_mempool::test_utils::{
add_tx,
add_tx_expect_error,
commit_block,
get_txs_and_assert_expected,
};
use starknet_mempool::{add_tx_input, tx};
use starknet_mempool_types::errors::MempoolError;
use starknet_mempool_types::mempool_types::{AccountState, AddTransactionArgs};

// Fixtures.

Expand Down

0 comments on commit b602259

Please sign in to comment.