From 1ff0d68c37eaa20af77e15cd64d5625b1c4ef830 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 18 Dec 2021 11:43:41 +0100 Subject: Fix test: Reactor should be running during test, not only during communcation Signed-off-by: Matthias Beyer --- lib/src/reactor/gossip/mod.rs | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/lib/src/reactor/gossip/mod.rs b/lib/src/reactor/gossip/mod.rs index 8676659..9567ccf 100644 --- a/lib/src/reactor/gossip/mod.rs +++ b/lib/src/reactor/gossip/mod.rs @@ -229,31 +229,22 @@ mod tests { rx.send((GossipRequest::Ping, reply_sender)).unwrap(); let mut pong_received = false; - tokio::select! { - reply = reply_receiver.recv() => { - match reply { - Some(GossipReply::Pong) => { - pong_received = true; - let (reply_sender, mut reply_receiver) = tokio::sync::mpsc::unbounded_channel(); - rx.send((GossipRequest::Exit, reply_sender)).unwrap(); - } - Some(r) => { - assert!(false, "Expected ReactorReply::Pong, got: {:?}", r); - } - None => { - // nothing - } - } - }, - - reactor_res = reactor.run() => { - match reactor_res { - Ok(()) => assert!(false, "Reactor finished before pong was received"), + let _ = tokio::spawn(async move { + reactor.run().await + }); - Err(e) => { - assert!(false, "Reactor errored: {:?}", e); - } - } + match reply_receiver.recv().await { + Some(GossipReply::Pong) => { + pong_received = true; + log::trace!("Pong received!"); + let (reply_sender, mut reply_receiver) = tokio::sync::mpsc::unbounded_channel(); + rx.send((GossipRequest::Exit, reply_sender)).unwrap(); + } + Some(r) => { + assert!(false, "Expected ReactorReply::Pong, got: {:?}", r); + } + None => { + // nothing } } -- cgit v1.2.3