Skip to content
Snippets Groups Projects
Commit 6e069eb4 authored by Max Inden's avatar Max Inden Committed by Gavin Wood
Browse files

client/authority-discovery: Increase margins for interval test (#4297)

`interval_at_is_queuing_ticks` test shows to be flaky. This commit
increases the time margins while also reducing the amount of necessary
time ticks.
parent 2414f947
Branches
Tags
No related merge requests found
......@@ -547,24 +547,26 @@ mod tests {
}
#[test]
fn interval_at_is_queuing_events() {
fn interval_at_is_queuing_ticks() {
let start = Instant::now();
let interval = interval_at(
std::time::Instant::now(),
std::time::Duration::from_millis(10),
start,
std::time::Duration::from_millis(100),
);
// Let's wait for 100ms, thus 10 elements should be queued up.
std::thread::sleep(Duration::from_millis(100));
// Let's wait for 200ms, thus 3 elements should be queued up (1st at 0ms, 2nd at 100ms, 3rd
// at 200ms).
std::thread::sleep(Duration::from_millis(200));
futures::executor::block_on(async {
interval.take(10).collect::<Vec<()>>().await;
interval.take(3).collect::<Vec<()>>().await;
});
// Make sure we did not just wait for yet another 100ms (10 elements).
// Make sure we did not wait for more than 300 ms, which would imply that `at_interval` is
// not queuing ticks.
assert!(
Instant::now().saturating_duration_since(start) < Duration::from_millis(150),
Instant::now().saturating_duration_since(start) < Duration::from_millis(300),
"Expect interval to /queue/ events when not polled for a while.",
);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment