summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-18 11:43:41 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-18 16:35:48 +0100
commit1ff0d68c37eaa20af77e15cd64d5625b1c4ef830 (patch)
treec02d57070d94fb8c9628f537307afe52df7cf25c
parent61c2b8d99e8e86e8d4b769488f745a801f041f6f (diff)
Fix test: Reactor should be running during test, not only during communcation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/src/reactor/gossip/mod.rs39
1 files 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
}
}