diff --git a/zenoh/tests/interceptors.rs b/zenoh/tests/interceptors.rs index 6dfd1b8b7a..595d2602a6 100644 --- a/zenoh/tests/interceptors.rs +++ b/zenoh/tests/interceptors.rs @@ -61,7 +61,8 @@ fn downsampling() { .unwrap(); let interval = std::time::Duration::from_millis(10); - let mut last_send_time = std::time::Instant::now(); + let start_time = std::time::Instant::now(); + let mut last_send_time = start_time; for i in 0..100 { let start_time = last_send_time; println!("message {}", i); @@ -81,6 +82,13 @@ fn downsampling() { } // check result count of queries - assert_eq!(*count_r100.lock().unwrap(), 10); - assert_eq!(*count_r50.lock().unwrap(), 20); + let full_elapsed_time = std::time::Instant::now() - start_time; + assert_eq!( + *count_r100.lock().unwrap(), + full_elapsed_time.as_millis() / 100 + ); + assert_eq!( + *count_r50.lock().unwrap(), + full_elapsed_time.as_millis() / 50 + ); }