Skip to content

Commit 2814b23

Browse files
committed
loop
1 parent 5b50969 commit 2814b23

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

src/receive_imf/receive_imf_tests.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,33 +2734,31 @@ async fn test_incoming_contact_request() -> Result<()> {
27342734
}
27352735

27362736
// Bob ignores contact request.
2737-
// The second message does not result in notification.
2738-
let msg2 = tcm.send_recv(alice, bob, "Hello!!??").await;
2739-
let event = bob
2740-
.evtracker
2741-
.get_matching(|evt| matches!(evt, EventType::MsgsChanged { .. }))
2742-
.await;
2743-
match event {
2744-
EventType::MsgsChanged { chat_id, msg_id } => {
2745-
assert_eq!(msg2.chat_id, chat_id);
2746-
assert_eq!(msg2.id, msg_id);
2747-
}
2748-
_ => unreachable!(),
2749-
}
2750-
2751-
// Third message also does not result in the notification
2752-
// and there is no IncomingMsg event in between.
2753-
let msg3 = tcm.send_recv(alice, bob, "Hello!!!!????").await;
2754-
let event = bob
2755-
.evtracker
2756-
.get_matching(|evt| matches!(evt, EventType::MsgsChanged { .. }))
2757-
.await;
2758-
match event {
2759-
EventType::MsgsChanged { chat_id, msg_id } => {
2760-
assert_eq!(msg3.chat_id, chat_id);
2761-
assert_eq!(msg3.id, msg_id);
2737+
// The second and third message does not result in notification.
2738+
for text in ["Hello!!??", "Hello!!!!????"] {
2739+
let msg = tcm.send_recv(alice, bob, "Hello!!??").await;
2740+
2741+
// There are only `MsgsChanged` events for each message,
2742+
// but no `IncomingMsg` before or after.
2743+
let event = bob
2744+
.evtracker
2745+
.get_matching(|evt| {
2746+
matches!(
2747+
evt,
2748+
EventType::MsgsChanged { .. } | EventType::IncomingMsg { .. }
2749+
)
2750+
})
2751+
.await;
2752+
match event {
2753+
EventType::MsgsChanged { chat_id, msg_id } => {
2754+
assert_eq!(msg.chat_id, chat_id);
2755+
assert_eq!(msg.id, msg_id);
2756+
2757+
let msg = Message::load_from_db(bob, msg_id).await?;
2758+
assert_eq!(msg.text, text);
2759+
}
2760+
_ => unreachable!(),
27622761
}
2763-
_ => unreachable!(),
27642762
}
27652763

27662764
Ok(())

0 commit comments

Comments
 (0)