@@ -7711,6 +7711,53 @@ mod tests {
7711
7711
self_chat. set_draft ( & alice, Some ( & mut msg) ) . await . unwrap ( ) ;
7712
7712
let draft2 = self_chat. get_draft ( & alice) . await ?. unwrap ( ) ;
7713
7713
assert_eq ! ( draft1. timestamp_sort, draft2. timestamp_sort) ;
7714
+
7715
+ Ok ( ( ) )
7716
+ }
7717
+
7718
+ /// Test group consistency.
7719
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
7720
+ async fn test_add_member_bug ( ) -> Result < ( ) > {
7721
+ let mut tcm = TestContextManager :: new ( ) ;
7722
+
7723
+ let alice = & tcm. alice ( ) . await ;
7724
+ let bob = & tcm. bob ( ) . await ;
7725
+
7726
+ let alice_bob_contact_id =
Contact :: create ( alice
, "Bob" , "[email protected] " ) . await ?
;
7727
+ let alice_fiona_contact_id =
Contact :: create ( alice
, "Fiona" , "[email protected] " ) . await ?
;
7728
+
7729
+ // Create a group.
7730
+ let alice_chat_id =
7731
+ create_group_chat ( alice, ProtectionStatus :: Unprotected , "Group chat" ) . await ?;
7732
+ add_contact_to_chat ( alice, alice_chat_id, alice_bob_contact_id) . await ?;
7733
+ add_contact_to_chat ( alice, alice_chat_id, alice_fiona_contact_id) . await ?;
7734
+
7735
+ // Promote the group.
7736
+ let alice_sent_msg = alice
7737
+ . send_text ( alice_chat_id, "Hi! I created a group." )
7738
+ . await ;
7739
+ let bob_received_msg = bob. recv_msg ( & alice_sent_msg) . await ;
7740
+
7741
+ let bob_chat_id = bob_received_msg. get_chat_id ( ) ;
7742
+ bob_chat_id. accept ( & bob) . await ?;
7743
+
7744
+ // Alice removes Fiona from the chat.
7745
+ remove_contact_from_chat ( alice, alice_chat_id, alice_fiona_contact_id) . await ?;
7746
+ let _alice_sent_add_msg = alice. pop_sent_msg ( ) . await ;
7747
+
7748
+ SystemTime :: shift ( Duration :: from_secs ( 3600 ) ) ;
7749
+
7750
+ // Bob sends a message
7751
+ // to Alice and Fiona because he still has not received
7752
+ // a message about Fiona being removed.
7753
+ let bob_sent_msg = bob. send_text ( bob_chat_id, "Hi Alice!" ) . await ;
7754
+
7755
+ // Alice receives a message.
7756
+ // This should not add Fiona back.
7757
+ let _alice_received_msg = alice. recv_msg ( & bob_sent_msg) . await ;
7758
+
7759
+ assert_eq ! ( get_chat_contacts( alice, alice_chat_id) . await ?. len( ) , 2 ) ;
7760
+
7714
7761
Ok ( ( ) )
7715
7762
}
7716
7763
}
0 commit comments