Skip to content

Commit

Permalink
feat: add config functions for remote flow test
Browse files Browse the repository at this point in the history
commit-id:e9855990
  • Loading branch information
nadin-Starkware committed Dec 8, 2024
1 parent 3aa7275 commit 183c942
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions crates/starknet_integration_tests/src/config_utils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
use std::fs::File;
use std::io::Write;
use std::net::SocketAddr;
use std::path::PathBuf;

use serde_json::{json, Value};
use starknet_sequencer_infra::component_definitions::{
LocalServerConfig,
RemoteClientConfig,
RemoteServerConfig,
};
use starknet_sequencer_infra::test_utils::get_available_socket;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::config::component_execution_config::{
ComponentExecutionConfig,
ComponentExecutionMode,
};
use starknet_sequencer_node::config::node_config::SequencerNodeConfig;
use starknet_sequencer_node::config::test_utils::RequiredParams;
use tracing::info;
Expand Down Expand Up @@ -80,3 +92,68 @@ fn strip_config_prefix(input: &str) -> &str {
.or_else(|| input.strip_prefix("required_params."))
.unwrap_or(input)
}

pub fn get_disabled_component_config() -> ComponentExecutionConfig {
ComponentExecutionConfig {
execution_mode: ComponentExecutionMode::Disabled,
local_server_config: None,
remote_client_config: None,
remote_server_config: None,
}
}

pub fn get_remote_component_config(socket: SocketAddr) -> ComponentExecutionConfig {
ComponentExecutionConfig {
execution_mode: ComponentExecutionMode::Remote,
local_server_config: None,
remote_client_config: Some(RemoteClientConfig { socket, ..RemoteClientConfig::default() }),
remote_server_config: None,
}
}

pub fn get_local_with_remote_enabled_component_config(
socket: SocketAddr,
) -> ComponentExecutionConfig {
ComponentExecutionConfig {
execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteEnabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
remote_server_config: Some(RemoteServerConfig { socket }),
}
}

pub async fn get_http_only_component_config(gateway_socket: SocketAddr) -> ComponentConfig {
let monitoring_endpoint_socket = get_available_socket().await;
ComponentConfig {
http_server: ComponentExecutionConfig::http_server_default_config(),
gateway: get_remote_component_config(gateway_socket),
monitoring_endpoint: get_local_with_remote_enabled_component_config(
monitoring_endpoint_socket,
),
batcher: get_disabled_component_config(),
consensus_manager: get_disabled_component_config(),
mempool: get_disabled_component_config(),
mempool_p2p: get_disabled_component_config(),
state_sync: get_disabled_component_config(),
}
}

pub async fn get_non_http_component_config(gateway_socket: SocketAddr) -> ComponentConfig {
let monitoring_endpoint_socket = get_available_socket().await;
ComponentConfig {
http_server: get_disabled_component_config(),
monitoring_endpoint: get_local_with_remote_enabled_component_config(
monitoring_endpoint_socket,
),
gateway: get_local_with_remote_enabled_component_config(gateway_socket),
..ComponentConfig::default()
}
}

pub async fn get_remote_flow_test_config() -> Vec<ComponentConfig> {
let gateway_socket = get_available_socket().await;
vec![
get_http_only_component_config(gateway_socket).await,
get_non_http_component_config(gateway_socket).await,
]
}

0 comments on commit 183c942

Please sign in to comment.