Skip to content

Commit

Permalink
chore(starknet_integration_tests): in mempool_p2p_flow_test check ali…
Browse files Browse the repository at this point in the history
…ve instead of timeout

commit-id:0c33575d
  • Loading branch information
lev-starkware committed Dec 17, 2024
1 parent d5fae3d commit 2d78adc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ use starknet_integration_tests::utils::{
};
use starknet_mempool_p2p::config::MempoolP2pConfig;
use starknet_mempool_p2p::MEMPOOL_TOPIC;
use starknet_monitoring_endpoint::config::MonitoringEndpointConfig;
use starknet_monitoring_endpoint::test_utils::IsAliveClient;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::config::component_execution_config::{
ActiveComponentExecutionConfig,
Expand Down Expand Up @@ -100,6 +102,13 @@ async fn setup(
(config, broadcast_channels)
}

async fn wait_for_sequencer_node(config: &SequencerNodeConfig) {
let MonitoringEndpointConfig { ip, port, .. } = config.monitoring_endpoint_config;
let is_alive_test_client = IsAliveClient::new(SocketAddr::from((ip, port)));

is_alive_test_client.await_alive(5000, 50).await.expect("Node should be alive.");
}

#[rstest]
#[tokio::test]
async fn test_mempool_sends_tx_to_other_peer(mut tx_generator: MultiAccountTransactionGenerator) {
Expand All @@ -114,9 +123,7 @@ async fn test_mempool_sends_tx_to_other_peer(mut tx_generator: MultiAccountTrans
let _sequencer_node_handle = tokio::spawn(sequencer_node_future);

// Wait for server to spin up and for p2p to discover other peer.
// TODO(Gilad): Replace with a persistent Client with a built-in retry to protect against CI
// flakiness.
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
wait_for_sequencer_node(&config).await;

let mut expected_txs = HashSet::new();

Expand Down Expand Up @@ -150,9 +157,7 @@ async fn test_mempool_receives_tx_from_other_peer(
let sequencer_node_future = run_component_servers(servers);
let _sequencer_node_handle = tokio::spawn(sequencer_node_future);
// Wait for server to spin up and for p2p to discover other peer.
// TODO(Gilad): Replace with a persistent Client with a built-in retry to protect against CI
// flakiness.
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
wait_for_sequencer_node(&config).await;

let mut expected_txs = HashSet::new();

Expand Down

0 comments on commit 2d78adc

Please sign in to comment.