From 2716e575e4c930c3537c75753f764c3981f298ad Mon Sep 17 00:00:00 2001 From: Egor Ivkov Date: Wed, 11 Aug 2021 21:04:56 +0300 Subject: [PATCH] Broker bug - test showcase Signed-off-by: Egor Ivkov --- iroha_actor/src/broker.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/iroha_actor/src/broker.rs b/iroha_actor/src/broker.rs index d6db9108494..e00ecb9086f 100644 --- a/iroha_actor/src/broker.rs +++ b/iroha_actor/src/broker.rs @@ -157,3 +157,27 @@ impl Broker { pub trait BrokerMessage: Message + Clone + 'static + Send {} impl + Clone + 'static + Send> BrokerMessage for M {} + +#[tokio::test] +async fn two_channels_subscribe_to_same_message() { + #[derive(Clone, Debug)] + struct Message1; + + impl Message for Message1 { + type Result = (); + } + + let broker = Broker::new(); + let mut receiver1 = broker.subscribe_with_channel::(); + let mut receiver2 = broker.subscribe_with_channel::(); + + broker.issue_send(Message1).await; + let Message1: Message1 = tokio::time::timeout(Duration::from_millis(100), receiver1.recv()) + .await + .unwrap() + .unwrap(); + let Message1: Message1 = tokio::time::timeout(Duration::from_millis(100), receiver2.recv()) + .await + .unwrap() + .unwrap(); +}