Skip to content

Commit

Permalink
chore(starknet_integration_tests): use available ports for http serve…
Browse files Browse the repository at this point in the history
…r config

commit-id:ecae5d24
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 18, 2024
1 parent b108b6f commit ad4f70c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 1 addition & 4 deletions crates/starknet_http_server/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use starknet_api::rpc_transaction::RpcTransaction;
use starknet_api::test_utils::rpc_tx_to_json;
use starknet_api::transaction::TransactionHash;
use starknet_gateway_types::errors::GatewaySpecError;
use starknet_sequencer_infra::test_utils::get_available_socket;

use crate::config::HttpServerConfig;

Expand Down Expand Up @@ -48,8 +47,6 @@ impl HttpTestClient {
}
}

pub async fn create_http_server_config() -> HttpServerConfig {
// TODO(Tsabary): use ser_generated_param.
let socket = get_available_socket().await;
pub async fn create_http_server_config(socket: SocketAddr) -> HttpServerConfig {
HttpServerConfig { ip: socket.ip(), port: socket.port() }
}
8 changes: 5 additions & 3 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use starknet_gateway::config::{
StatelessTransactionValidatorConfig,
};
use starknet_http_server::config::HttpServerConfig;
use starknet_http_server::test_utils::create_http_server_config;
use starknet_mempool_p2p::config::MempoolP2pConfig;
use starknet_monitoring_endpoint::config::MonitoringEndpointConfig;
use starknet_sequencer_infra::test_utils::{get_available_socket, AvailablePorts};
Expand All @@ -49,7 +50,6 @@ pub fn create_chain_info() -> ChainInfo {
// TODO(yair, Tsabary): Create config presets for tests, then remove all the functions that modify
// the config.
#[allow(clippy::too_many_arguments)]
#[allow(unused_variables)]
pub async fn create_config(
available_ports: &mut AvailablePorts,
sequencer_index: usize,
Expand All @@ -64,7 +64,8 @@ pub async fn create_config(
let fee_token_addresses = chain_info.fee_token_addresses.clone();
let batcher_config = create_batcher_config(batcher_storage_config, chain_info.clone());
let gateway_config = create_gateway_config(chain_info.clone()).await;
let http_server_config = create_http_server_config().await;
let http_server_config =
create_http_server_config(available_ports.get_next_local_host_socket()).await;
let rpc_state_reader_config = test_rpc_state_reader_config(rpc_server_addr);
let monitoring_endpoint_config = create_monitoring_endpoint_config(sequencer_index);
let state_sync_config = create_state_sync_config(state_sync_storage_config, sequencer_index);
Expand Down Expand Up @@ -248,7 +249,8 @@ pub async fn create_gateway_config(chain_info: ChainInfo) -> GatewayConfig {
GatewayConfig { stateless_tx_validator_config, stateful_tx_validator_config, chain_info }
}

pub async fn create_http_server_config() -> HttpServerConfig {
// TODO(Tsabary): deprecate this function.
pub async fn create_http_server_config_to_be_deprecated() -> HttpServerConfig {
// TODO(Tsabary): use ser_generated_param.
let socket = get_available_socket().await;
HttpServerConfig { ip: socket.ip(), port: socket.port() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use starknet_integration_tests::utils::{
create_batcher_config,
create_chain_info,
create_gateway_config,
create_http_server_config,
create_http_server_config_to_be_deprecated,
create_integration_test_tx_generator,
run_integration_test_scenario,
test_rpc_state_reader_config,
Expand All @@ -47,7 +47,8 @@ fn tx_generator() -> MultiAccountTransactionGenerator {
create_integration_test_tx_generator()
}

// TODO: remove code duplication with FlowTestSetup
// TODO(Shahak/AlonLukatch): add available_ports to the setup function.
// TODO(Shahak/AlonLukatch): remove code duplication with FlowTestSetup.
async fn setup(
tx_generator: &MultiAccountTransactionGenerator,
) -> (SequencerNodeConfig, BroadcastTopicChannels<RpcTransactionWrapper>) {
Expand Down Expand Up @@ -81,7 +82,7 @@ async fn setup(
let batcher_config =
create_batcher_config(storage_for_test.batcher_storage_config, chain_info.clone());
let gateway_config = create_gateway_config(chain_info).await;
let http_server_config = create_http_server_config().await;
let http_server_config = create_http_server_config_to_be_deprecated().await;
let rpc_state_reader_config = test_rpc_state_reader_config(rpc_server_addr);
let (mut network_configs, broadcast_channels) =
create_network_configs_connected_to_broadcast_channels::<RpcTransactionWrapper>(
Expand Down

0 comments on commit ad4f70c

Please sign in to comment.