Skip to content

Commit

Permalink
chore(starknet_integration_tests): add available ports to setup fn, s…
Browse files Browse the repository at this point in the history
…till unused

commit-id:bcd73021
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 18, 2024
1 parent c8fd138 commit 75d09c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion crates/starknet_integration_tests/src/integration_test_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 75d09c9

Please sign in to comment.