From ad4f70ce4aaf0685630a40399dca4a45ea24ad16 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Wed, 18 Dec 2024 20:34:52 +0200 Subject: [PATCH] chore(starknet_integration_tests): use available ports for http server config commit-id:ecae5d24 --- crates/starknet_http_server/src/test_utils.rs | 5 +---- crates/starknet_integration_tests/src/utils.rs | 8 +++++--- .../tests/mempool_p2p_flow_test.rs | 7 ++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/starknet_http_server/src/test_utils.rs b/crates/starknet_http_server/src/test_utils.rs index 8faf1e302cf..e88c161404e 100644 --- a/crates/starknet_http_server/src/test_utils.rs +++ b/crates/starknet_http_server/src/test_utils.rs @@ -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; @@ -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() } } diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index fa8a9bab56f..1710e62416e 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -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}; @@ -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, @@ -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); @@ -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() } diff --git a/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs b/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs index ff088822d9a..371c10f5259 100644 --- a/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs +++ b/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs @@ -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, @@ -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) { @@ -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::(