diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index 4f85490f19..90b25444c2 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -184,21 +184,14 @@ fn create_txs_for_integration_test( vec![account0_invoke_nonce1, account0_invoke_nonce2, account1_invoke_nonce1] } -// TODO(Tsabary): Pass the contract address as a function parameter. Also rename the function to -// better reflect its purpose. Then, rename 'run_transaction_generator_test_scenario' accordingly. -fn create_txs_for_tx_generator_test_scenario( +fn create_account_txs( mut tx_generator: MultiAccountTransactionGenerator, + account_id: AccountId, n_txs: usize, -) -> (Vec, ContractAddress) { - const ACCOUNT_ID_0: AccountId = 0; - let contract_address = tx_generator.account_with_id(ACCOUNT_ID_0).sender_address(); - - ( - (0..n_txs) - .map(|_| tx_generator.account_with_id(ACCOUNT_ID_0).generate_invoke_with_tip(1)) - .collect(), - contract_address, - ) +) -> Vec { + (0..n_txs) + .map(|_| tx_generator.account_with_id(account_id).generate_invoke_with_tip(1)) + .collect() } async fn send_rpc_txs<'a, Fut>( @@ -239,20 +232,18 @@ where vec![tx_hashes[2], tx_hashes[0], tx_hashes[1]] } -/// Creates and runs the many txs test scenario for the sequencer integration test. Returns -/// a list of transaction hashes, in the order they are expected to be in the mempool. -pub async fn run_transaction_generator_test_scenario<'a, Fut>( +/// Returns a list of the transaction hashes, in the order they are expected to be in the mempool. +pub async fn send_account_txs<'a, Fut>( tx_generator: MultiAccountTransactionGenerator, + account_id: AccountId, n_txs: usize, send_rpc_tx_fn: &'a mut dyn FnMut(RpcTransaction) -> Fut, -) -> (Vec, ContractAddress) +) -> Vec where Fut: Future + 'a, { - let (rpc_txs, contract_address) = - create_txs_for_tx_generator_test_scenario(tx_generator, n_txs); - let tx_hashes = send_rpc_txs(rpc_txs, send_rpc_tx_fn).await; - (tx_hashes, contract_address) + let rpc_txs = create_account_txs(tx_generator, n_txs, account_id); + send_rpc_txs(rpc_txs, send_rpc_tx_fn).await } pub async fn create_gateway_config(chain_info: ChainInfo) -> GatewayConfig { diff --git a/crates/starknet_integration_tests/tests/end_to_end_integration_test.rs b/crates/starknet_integration_tests/tests/end_to_end_integration_test.rs index b225022bd2..1602e1f87c 100644 --- a/crates/starknet_integration_tests/tests/end_to_end_integration_test.rs +++ b/crates/starknet_integration_tests/tests/end_to_end_integration_test.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use std::process::Stdio; use std::time::Duration; -use mempool_test_utils::starknet_api_test_utils::MultiAccountTransactionGenerator; +use mempool_test_utils::starknet_api_test_utils::{AccountId, MultiAccountTransactionGenerator}; use papyrus_execution::execution_utils::get_nonce_at; use papyrus_storage::state::StateStorageReader; use papyrus_storage::StorageReader; @@ -12,10 +12,7 @@ use starknet_api::block::BlockNumber; use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::state::StateNumber; use starknet_integration_tests::integration_test_setup::IntegrationTestSetup; -use starknet_integration_tests::utils::{ - create_integration_test_tx_generator, - run_transaction_generator_test_scenario, -}; +use starknet_integration_tests::utils::{create_integration_test_tx_generator, send_account_txs}; use starknet_sequencer_infra::trace_util::configure_tracing; use starknet_types_core::felt::Felt; use tokio::process::{Child, Command}; @@ -122,7 +119,7 @@ async fn await_block( #[rstest] #[tokio::test] -async fn test_end_to_end_integration(tx_generator: MultiAccountTransactionGenerator) { +async fn test_end_to_end_integration(mut tx_generator: MultiAccountTransactionGenerator) { const EXPECTED_BLOCK_NUMBER: BlockNumber = BlockNumber(15); configure_tracing(); @@ -147,10 +144,11 @@ async fn test_end_to_end_integration(tx_generator: MultiAccountTransactionGenera let send_rpc_tx_fn = &mut |rpc_tx| integration_test_setup.add_tx_http_client.assert_add_tx_success(rpc_tx); + const ACCOUNT_ID_0: AccountId = 0; let n_txs = 50; + let sender_address = tx_generator.account_with_id(ACCOUNT_ID_0).sender_address(); info!("Sending {n_txs} txs."); - let (tx_hashes, sender_address) = - run_transaction_generator_test_scenario(tx_generator, n_txs, send_rpc_tx_fn).await; + let tx_hashes = send_account_txs(tx_generator, ACCOUNT_ID_0, n_txs, send_rpc_tx_fn).await; info!("Awaiting until {EXPECTED_BLOCK_NUMBER} blocks have been created.");