From 496a8e3810c42e661619793363c81f9f26cf1178 Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 25 Apr 2024 09:25:03 +0000 Subject: [PATCH] test: test that member is added even if "Member added" is lost This is similar to `test_modify_chat_disordered`, but tests that recovery works in the simplest case where next message is not modifying group membership. --- src/chat.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/chat.rs b/src/chat.rs index f6a7a2b8b..3af6f94c0 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -5038,6 +5038,32 @@ mod tests { Ok(()) } + /// Tests that if member added message is completely lost, + /// member is eventually added. + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_lost_member_added() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = &tcm.alice().await; + let bob = &tcm.bob().await; + let alice_chat_id = alice + .create_group_with_members(ProtectionStatus::Unprotected, "Group", &[bob]) + .await; + let alice_sent = alice.send_text(alice_chat_id, "Hi!").await; + let bob_chat_id = bob.recv_msg(&alice_sent).await.chat_id; + assert_eq!(get_chat_contacts(bob, bob_chat_id).await?.len(), 2); + + // Attempt to add member, but message is lost. + let claire_id = Contact::create(alice, "", "claire@foo.de").await?; + add_contact_to_chat(alice, alice_chat_id, claire_id).await?; + alice.pop_sent_msg().await; + + let alice_sent = alice.send_text(alice_chat_id, "Hi again!").await; + bob.recv_msg(&alice_sent).await; + assert_eq!(get_chat_contacts(bob, bob_chat_id).await?.len(), 3); + + Ok(()) + } + /// Test that group updates are robust to lost messages and eventual out of order arrival. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_modify_chat_lost() -> Result<()> {