diff --git a/iroh/src/magicsock/transports/relay/actor.rs b/iroh/src/magicsock/transports/relay/actor.rs index f26b3d7333..ea463da376 100644 --- a/iroh/src/magicsock/transports/relay/actor.rs +++ b/iroh/src/magicsock/transports/relay/actor.rs @@ -1459,7 +1459,6 @@ mod tests { #[tokio::test] #[traced_test] - #[ignore = "flaky"] async fn test_active_relay_inactive() -> Result { let (_relay_map, relay_url, _server) = test_utils::run_relay_server().await?; @@ -1481,11 +1480,11 @@ mod tests { ); // Wait until the actor is connected to the relay server. - tokio::time::timeout(Duration::from_millis(200), async { + tokio::time::timeout(Duration::from_secs(5), async { loop { let (tx, rx) = oneshot::channel(); inbox_tx.send(ActiveRelayMessage::PingServer(tx)).await.ok(); - if tokio::time::timeout(Duration::from_millis(100), rx) + if tokio::time::timeout(Duration::from_millis(200), rx) .await .map(|resp| resp.is_ok()) .unwrap_or_default() @@ -1497,12 +1496,12 @@ mod tests { .await .std_context("timeout")?; - // From now on, we pause time - tokio::time::pause(); // We now have an idling ActiveRelayActor. If we advance time just a little it // should stay alive. info!("Stepping time forwards by RELAY_INACTIVE_CLEANUP_TIME / 2"); + tokio::time::pause(); tokio::time::advance(RELAY_INACTIVE_CLEANUP_TIME / 2).await; + tokio::time::resume(); assert!( tokio::time::timeout(Duration::from_millis(100), &mut task) @@ -1513,15 +1512,20 @@ mod tests { // If we advance time a lot it should finish. info!("Stepping time forwards by RELAY_INACTIVE_CLEANUP_TIME"); + tokio::time::pause(); tokio::time::advance(RELAY_INACTIVE_CLEANUP_TIME).await; + tokio::time::resume(); + + // We resume time for these timeouts, as there's actual I/O happening, + // for example closing the TCP stream, so we actually need the tokio + // runtime to idle a bit while the kernel is doing its thing. assert!( - tokio::time::timeout(Duration::from_millis(1000), task) + tokio::time::timeout(Duration::from_secs(1), task) .await .is_ok(), "actor task still running" ); - tokio::time::resume(); cancel_token.cancel(); Ok(()) }