diff --git a/src/receive_imf.rs b/src/receive_imf.rs index dc48c5d66..d1fe9c18b 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -3149,6 +3149,7 @@ Hello mailinglist!\r\n" .unwrap(); receive_imf(&t.ctx, DC_MAILINGLIST, false).await.unwrap(); + t.evtracker.wait_next_incoming_message().await; let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap(); assert_eq!(chats.len(), 1); let chat_id = chats.get_chat_id(0).unwrap(); @@ -3161,7 +3162,6 @@ Hello mailinglist!\r\n" let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap(); assert_eq!(chats.len(), 0); // Test that the message disappeared - t.evtracker.consume_events(); receive_imf(&t.ctx, DC_MAILINGLIST2, false).await.unwrap(); // Check that no notification is displayed for blocked mailing list message. diff --git a/src/test_utils.rs b/src/test_utils.rs index e1070f163..243edf325 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -876,9 +876,10 @@ impl EventTracker { .await } - /// Consumes all pending events. - pub fn consume_events(&self) { - while self.try_recv().is_ok() {} + /// Wait for the next IncomingMsg event. + pub async fn wait_next_incoming_message(&self) { + self.get_matching(|evt| matches!(evt, EventType::IncomingMsg { .. })) + .await; } }