Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix flaky test and error reporting #7282

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions node/network/availability-recovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ async fn overseer_signal(
.send(FromOrchestra::Signal(signal))
.timeout(TIMEOUT)
.await
.expect("10ms is more than enough for sending signals.");
.unwrap_or_else(|| {
panic!("{}ms is more than enough for sending signals.", TIMEOUT.as_millis())
});
}

async fn overseer_send(
Expand All @@ -184,7 +186,9 @@ async fn overseer_send(
.send(FromOrchestra::Communication { msg })
.timeout(TIMEOUT)
.await
.expect("10ms is more than enough for sending messages.");
.unwrap_or_else(|| {
panic!("{}ms is more than enough for sending messages.", TIMEOUT.as_millis())
});
}

async fn overseer_recv(
Expand Down
11 changes: 6 additions & 5 deletions node/network/bitfield-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr};

use std::{iter::FromIterator as _, sync::Arc, time::Duration};

const TIMEOUT: Duration = Duration::from_millis(50);
macro_rules! launch {
($fut:expr) => {
$fut.timeout(Duration::from_millis(10))
.await
.expect("10ms is more than enough for sending messages.")
$fut.timeout(TIMEOUT).await.unwrap_or_else(|| {
panic!("{}ms is more than enough for sending messages.", TIMEOUT.as_millis())
});
};
}

Expand Down Expand Up @@ -220,7 +221,7 @@ fn receive_invalid_signature() {
));

// reputation doesn't change due to one_job_per_validator check
assert!(handle.recv().timeout(Duration::from_millis(10)).await.is_none());
assert!(handle.recv().timeout(TIMEOUT).await.is_none());

launch!(handle_network_msg(
&mut ctx,
Expand Down Expand Up @@ -523,7 +524,7 @@ fn do_not_relay_message_twice() {
);

// There shouldn't be any other message
assert!(handle.recv().timeout(Duration::from_millis(10)).await.is_none());
assert!(handle.recv().timeout(TIMEOUT).await.is_none());
});
}

Expand Down