diff options
| author | tv <tv@krebsco.de> | 2026-11-21 22:42:30 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-21 23:46:25 +0100 |
| commit | 3507e96d8402ea681343a4b3d63aa87bdceb022f (patch) | |
| tree | 8fe8cd5d3fad2cfe813087e1f86648b6a81e438d /src/transport/mycelium | |
| parent | 37a521169f703f5f412ea6dd52684b03289c350d (diff) | |
mycelium: the fake daemon's tests wait for its first poll, not one more
They waited for one more request for the inbox than the daemon had had
when they looked, after the transport had started: where its first
request was in by then, they waited for a second, which an idle
transport never makes (its first waits in the daemon), and failed after
2 s. Each test's daemon is new: its first request is the one meant.
Diffstat (limited to 'src/transport/mycelium')
| -rw-r--r-- | src/transport/mycelium/fake_daemon.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/transport/mycelium/fake_daemon.rs b/src/transport/mycelium/fake_daemon.rs index de3e7e3..1032606 100644 --- a/src/transport/mycelium/fake_daemon.rs +++ b/src/transport/mycelium/fake_daemon.rs @@ -151,10 +151,11 @@ async fn taking( (transport, rx) } -/// Waits until `daemon` has had more requests for its inbox than `than`. -async fn polled_since(daemon: &Daemon, than: usize) { +/// Waits until `daemon` has had a request for its inbox: the transport's first, which +/// waits there while nothing comes in. +async fn polled(daemon: &Daemon) { tokio::time::timeout(SOON, async { - while daemon.polls() <= than { + while daemon.polls() == 0 { tokio::time::sleep(Duration::from_millis(10)).await; } }) @@ -188,7 +189,7 @@ async fn a_node_with_nothing_coming_in_sends_at_once() { let (daemon, url) = started().await; let (transport, _taken) = taking(url).await; // The inbox is waited for in the daemon by now. - polled_since(&daemon, daemon.polls()).await; + polled(&daemon).await; tokio::time::sleep(Duration::from_millis(100)).await; let message = encode_message(THEIRS, &a_message(), wire::VERSION).expect("encoded"); for n in 1..=3 { @@ -206,7 +207,7 @@ async fn a_node_with_nothing_coming_in_sends_at_once() { async fn a_message_is_taken_as_it_comes() { let (daemon, url) = started().await; let (_transport, mut taken) = taking(url).await; - polled_since(&daemon, daemon.polls()).await; + polled(&daemon).await; for _ in 0..3 { tokio::time::sleep(Duration::from_millis(100)).await; daemon.comes(inbound(&a_message())); @@ -236,7 +237,7 @@ async fn messages_coming_while_the_node_sends_all_come_in() { const MESSAGES: usize = 50; let (daemon, url) = started().await; let (transport, mut taken) = taking(url).await; - polled_since(&daemon, daemon.polls()).await; + polled(&daemon).await; let message = encode_message(THEIRS, &a_message(), wire::VERSION).expect("encoded"); let sending = tokio::spawn({ let transport = transport.clone(); |
