diff --git a/crates/starknet_http_server/src/test_utils.rs b/crates/starknet_http_server/src/test_utils.rs index 8faf1e302c..e88c161404 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 fa8a9bab56..1710e62416 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 ff088822d9..371c10f525 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::(