Skip to content

Commit 81bdc42

Browse files
authored
notifications/tests: Fix flaky libp2p_disconnects_libp2p_substream test (paritytech#10886)
Under load, 5 seconds might not be enough for the CI to capture all events generated by the net backend. In this PR, the timeout is increased to 60s after which a hard panic occurs. Discovered during: - paritytech#10846 Signed-off-by: Alexandru Vasile <[email protected]>
1 parent 8807c22 commit 81bdc42

File tree

1 file changed

+14
-3
lines changed
  • substrate/client/network/src/protocol/notifications/tests

1 file changed

+14
-3
lines changed

substrate/client/network/src/protocol/notifications/tests/conformance.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ async fn libp2p_disconnects_libp2p_substream() {
371371

372372
libp2p_rhs.dial(libp2p_lhs_address).unwrap();
373373

374-
// Disarm first timer interval that fires immediately.
375-
let mut timer = tokio::time::interval(std::time::Duration::from_secs(5));
374+
// Timeout as a safety guard in case the test hangs.
375+
let mut timer = tokio::time::interval(std::time::Duration::from_secs(60));
376376
timer.tick().await;
377377

378378
let mut sink = None;
@@ -388,7 +388,7 @@ async fn libp2p_disconnects_libp2p_substream() {
388388
loop {
389389
tokio::select! {
390390
_ = timer.tick() => {
391-
break;
391+
panic!("Test timed out waiting for expected events");
392392
}
393393

394394
event = libp2p_lhs.select_next_some() => {
@@ -488,6 +488,17 @@ async fn libp2p_disconnects_libp2p_substream() {
488488

489489
},
490490
}
491+
492+
// Check if all expected events have occurred
493+
if open_times == 2 &&
494+
notification_count == 4 &&
495+
recv_1111 == 2 &&
496+
recv_2222 == 2 &&
497+
recv_3333 == 2 &&
498+
recv_4444 == 2
499+
{
500+
break;
501+
}
491502
}
492503

493504
assert_eq!(open_times, 2);

0 commit comments

Comments
 (0)