Skip to content

Commit

Permalink
chore(starknet_integration_tests): add support for specifying a costu…
Browse files Browse the repository at this point in the history
…m config dir path

commit-id:f520149e
  • Loading branch information
nadin-Starkware committed Feb 10, 2025
1 parent df04ca7 commit b348182
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
10 changes: 7 additions & 3 deletions crates/starknet_integration_tests/src/end_to_end_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ pub async fn end_to_end_integration() {
const N_DISTRIBUTED_SEQUENCERS: usize = 2;

// Get the sequencer configurations.
let mut integration_test_manager =
IntegrationTestManager::new(N_CONSOLIDATED_SEQUENCERS, N_DISTRIBUTED_SEQUENCERS, None)
.await;
let mut integration_test_manager = IntegrationTestManager::new(
N_CONSOLIDATED_SEQUENCERS,
N_DISTRIBUTED_SEQUENCERS,
None,
None,
)
.await;

let node_indices = integration_test_manager.get_node_indices();
// Run the nodes.
Expand Down
21 changes: 14 additions & 7 deletions crates/starknet_integration_tests/src/integration_test_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::test_utils::node_runner::NodeRunner;
use starknet_state_sync::config::StateSyncConfig;
use tempfile::{tempdir, TempDir};
use tokio::fs::create_dir_all;
use tracing::instrument;

use crate::config_utils::dump_config_file_changes;
Expand Down Expand Up @@ -77,7 +78,7 @@ pub struct ExecutableSetup {
#[allow(dead_code)]
batcher_storage_handle: Option<TempDir>,
#[allow(dead_code)]
node_config_dir_handle: TempDir,
node_config_dir_handle: Option<TempDir>,
#[allow(dead_code)]
state_sync_storage_handle: Option<TempDir>,
#[allow(dead_code)]
Expand All @@ -98,6 +99,7 @@ impl ExecutableSetup {
mut available_ports: AvailablePorts,
component_config: ComponentConfig,
db_path_dir: Option<PathBuf>,
config_path_dir: Option<PathBuf>,
) -> Self {
// TODO(Nadin): pass the test storage as an argument.
// Creating the storage for the test.
Expand Down Expand Up @@ -136,12 +138,17 @@ impl ExecutableSetup {
component_config,
);

let node_config_dir_handle = tempdir().unwrap();
let node_config_path = dump_config_file_changes(
&config,
required_params,
node_config_dir_handle.path().to_path_buf(),
);
let (node_config_dir, node_config_dir_handle) = match config_path_dir {
Some(config_path_dir) => {
create_dir_all(&config_path_dir).await.unwrap();
(config_path_dir, None)
}
None => {
let node_config_dir_handle = tempdir().unwrap();
(node_config_dir_handle.path().to_path_buf(), Some(node_config_dir_handle))
}
};
let node_config_path = dump_config_file_changes(&config, required_params, node_config_dir);

// Wait for the node to start.
let MonitoringEndpointConfig { ip, port, .. } = config.monitoring_endpoint_config;
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_integration_tests/src/node_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub async fn node_setup(
N_CONSOLIDATED_SEQUENCERS,
N_DISTRIBUTED_SEQUENCERS,
Some(base_db_path_dir),
None,
)
.await;

Expand Down
6 changes: 6 additions & 0 deletions crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ impl IntegrationTestManager {
num_of_consolidated_nodes: usize,
num_of_distributed_nodes: usize,
path_to_db_base_dir: Option<PathBuf>,
path_to_config_base_dir: Option<PathBuf>,
) -> Self {
info!("Checking that the sequencer node executable is present.");
get_node_executable_path();
Expand All @@ -187,6 +188,7 @@ impl IntegrationTestManager {
num_of_consolidated_nodes,
num_of_distributed_nodes,
path_to_db_base_dir,
path_to_config_base_dir,
)
.await;

Expand Down Expand Up @@ -339,6 +341,7 @@ pub(crate) async fn get_sequencer_setup_configs(
num_of_consolidated_nodes: usize,
num_of_distributed_nodes: usize,
path_to_db_base_dir: Option<PathBuf>,
path_to_config_base_dir: Option<PathBuf>,
) -> (Vec<NodeSetup>, HashSet<usize>) {
let test_unique_id = TestIdentifier::EndToEndIntegrationTest;

Expand Down Expand Up @@ -407,6 +410,8 @@ pub(crate) async fn get_sequencer_setup_configs(
let chain_info = chain_info.clone();
let exec_db_path =
path_to_db_base_dir.as_ref().map(|p| node_execution_id.build_path(p));
let exec_config_path =
path_to_config_base_dir.as_ref().map(|p| node_execution_id.build_path(p));

executables.push(
ExecutableSetup::new(
Expand All @@ -419,6 +424,7 @@ pub(crate) async fn get_sequencer_setup_configs(
AvailablePorts::new(test_unique_id.into(), global_index.try_into().unwrap()),
executable_component_config.clone(),
exec_db_path,
exec_config_path,
)
.await,
);
Expand Down

0 comments on commit b348182

Please sign in to comment.