diff --git a/crates/starknet_integration_tests/src/end_to_end_integration.rs b/crates/starknet_integration_tests/src/end_to_end_integration.rs index 6a1b263cac..2b2be162c0 100644 --- a/crates/starknet_integration_tests/src/end_to_end_integration.rs +++ b/crates/starknet_integration_tests/src/end_to_end_integration.rs @@ -14,6 +14,9 @@ use tracing::info; use crate::integration_test_setup::IntegrationTestSetup; use crate::utils::send_account_txs; +// TODO(Tsabary): create an enum that maps test names to unique indices, replace constants. +const TEST_UNIQUE_INDEX: u16 = 0; + /// Reads the latest block number from the storage. fn get_latest_block_number(storage_reader: &StorageReader) -> BlockNumber { let txn = storage_reader.begin_ro_txn().unwrap(); @@ -62,7 +65,8 @@ pub async fn end_to_end_integration(mut tx_generator: MultiAccountTransactionGen info!("Running integration test setup."); // Creating the storage for the test. - let integration_test_setup = IntegrationTestSetup::new_from_tx_generator(&tx_generator).await; + let integration_test_setup = + IntegrationTestSetup::new_from_tx_generator(&tx_generator, TEST_UNIQUE_INDEX).await; info!("Running sequencer node."); let node_run_handle = spawn_run_node(integration_test_setup.node_config_path).await; diff --git a/crates/starknet_integration_tests/src/integration_test_setup.rs b/crates/starknet_integration_tests/src/integration_test_setup.rs index 8ea1f40e67..673f3b6152 100644 --- a/crates/starknet_integration_tests/src/integration_test_setup.rs +++ b/crates/starknet_integration_tests/src/integration_test_setup.rs @@ -7,6 +7,7 @@ use starknet_http_server::config::HttpServerConfig; use starknet_http_server::test_utils::HttpTestClient; use starknet_monitoring_endpoint::config::MonitoringEndpointConfig; use starknet_monitoring_endpoint::test_utils::IsAliveClient; +use starknet_sequencer_infra::test_utils::AvailablePorts; use tempfile::{tempdir, TempDir}; use crate::config_utils::dump_config_file_changes; @@ -32,6 +33,8 @@ pub struct IntegrationTestSetup { pub batcher_storage_config: StorageConfig, // Storage reader for the state sync. pub state_sync_storage_config: StorageConfig, + // Available ports for the test. + pub available_ports: AvailablePorts, // Handlers for the storage and config files, maintained so the files are not deleted. Since // these are only maintained to avoid dropping the handlers, private visibility suffices, and // as such, the '#[allow(dead_code)]' attributes are used to suppress the warning. @@ -46,7 +49,12 @@ pub struct IntegrationTestSetup { } impl IntegrationTestSetup { - pub async fn new_from_tx_generator(tx_generator: &MultiAccountTransactionGenerator) -> Self { + pub async fn new_from_tx_generator( + tx_generator: &MultiAccountTransactionGenerator, + test_unique_index: u16, + ) -> Self { + let available_ports = AvailablePorts::new(test_unique_index, 0); + let chain_info = create_chain_info(); // Creating the storage for the test. let storage_for_test = StorageTestSetup::new(tx_generator.accounts(), &chain_info); @@ -95,6 +103,7 @@ impl IntegrationTestSetup { batcher_storage_handle: storage_for_test.batcher_storage_handle, batcher_storage_config: config.batcher_config.storage, rpc_storage_handle: storage_for_test.rpc_storage_handle, + available_ports, node_config_dir_handle, node_config_path, state_sync_storage_handle: storage_for_test.state_sync_storage_handle,