diff options
Diffstat (limited to 'src/transport')
| -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(); |
