Skip to content

Commit c5dbce4

Browse files
committed
Turn test_msg_with_implicit_member_add into test_msg_with_implicit_member_removed
1 parent 04dfe98 commit c5dbce4

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/chat.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5122,9 +5122,9 @@ mod tests {
51225122
Ok(())
51235123
}
51245124

5125-
/// Test that if a message implicitly adds a member, both messages appear.
5125+
/// Test that member removal is synchronized eventually even if the message is lost.
51265126
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
5127-
async fn test_msg_with_implicit_member_add() -> Result<()> {
5127+
async fn test_msg_with_implicit_member_removed() -> Result<()> {
51285128
let mut tcm = TestContextManager::new();
51295129
let alice = tcm.alice().await;
51305130
let bob = tcm.bob().await;
@@ -5140,22 +5140,35 @@ mod tests {
51405140
let bob_received_msg = bob.recv_msg(&sent_msg).await;
51415141
let bob_chat_id = bob_received_msg.get_chat_id();
51425142
bob_chat_id.accept(&bob).await?;
5143+
assert_eq!(get_chat_contacts(&bob, bob_chat_id).await?.len(), 2);
51435144

51445145
add_contact_to_chat(&alice, alice_chat_id, alice_fiona_contact_id).await?;
51455146
let sent_msg = alice.pop_sent_msg().await;
51465147
bob.recv_msg(&sent_msg).await;
5148+
5149+
// Bob removed Fiona, but the message is lost.
51475150
remove_contact_from_chat(&bob, bob_chat_id, bob_fiona_contact_id).await?;
51485151
bob.pop_sent_msg().await;
51495152

51505153
// This doesn't add Fiona back because Bob just removed them.
51515154
let sent_msg = alice.send_text(alice_chat_id, "Welcome, Fiona!").await;
51525155
bob.recv_msg(&sent_msg).await;
5156+
assert_eq!(get_chat_contacts(&bob, bob_chat_id).await?.len(), 2);
51535157

5158+
// Even after some time Fiona is not added back.
51545159
SystemTime::shift(Duration::from_secs(3600));
51555160
let sent_msg = alice.send_text(alice_chat_id, "Welcome back, Fiona!").await;
51565161
bob.recv_msg(&sent_msg).await;
5157-
bob.golden_test_chat(bob_chat_id, "chat_test_msg_with_implicit_member_add")
5162+
assert_eq!(get_chat_contacts(&bob, bob_chat_id).await?.len(), 2);
5163+
5164+
// If Bob sends a message to Alice now, Fiona is removed.
5165+
assert_eq!(get_chat_contacts(&alice, alice_chat_id).await?.len(), 3);
5166+
let sent_msg = bob
5167+
.send_text(alice_chat_id, "I have removed Fiona some time ago.")
51585168
.await;
5169+
alice.recv_msg(&sent_msg).await;
5170+
assert_eq!(get_chat_contacts(&alice, alice_chat_id).await?.len(), 2);
5171+
51595172
Ok(())
51605173
}
51615174

test-data/golden/chat_test_msg_with_implicit_member_add

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)