@@ -5122,9 +5122,9 @@ mod tests {
5122
5122
Ok ( ( ) )
5123
5123
}
5124
5124
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 .
5126
5126
#[ 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 < ( ) > {
5128
5128
let mut tcm = TestContextManager :: new ( ) ;
5129
5129
let alice = tcm. alice ( ) . await ;
5130
5130
let bob = tcm. bob ( ) . await ;
@@ -5140,22 +5140,35 @@ mod tests {
5140
5140
let bob_received_msg = bob. recv_msg ( & sent_msg) . await ;
5141
5141
let bob_chat_id = bob_received_msg. get_chat_id ( ) ;
5142
5142
bob_chat_id. accept ( & bob) . await ?;
5143
+ assert_eq ! ( get_chat_contacts( & bob, bob_chat_id) . await ?. len( ) , 2 ) ;
5143
5144
5144
5145
add_contact_to_chat ( & alice, alice_chat_id, alice_fiona_contact_id) . await ?;
5145
5146
let sent_msg = alice. pop_sent_msg ( ) . await ;
5146
5147
bob. recv_msg ( & sent_msg) . await ;
5148
+
5149
+ // Bob removed Fiona, but the message is lost.
5147
5150
remove_contact_from_chat ( & bob, bob_chat_id, bob_fiona_contact_id) . await ?;
5148
5151
bob. pop_sent_msg ( ) . await ;
5149
5152
5150
5153
// This doesn't add Fiona back because Bob just removed them.
5151
5154
let sent_msg = alice. send_text ( alice_chat_id, "Welcome, Fiona!" ) . await ;
5152
5155
bob. recv_msg ( & sent_msg) . await ;
5156
+ assert_eq ! ( get_chat_contacts( & bob, bob_chat_id) . await ?. len( ) , 2 ) ;
5153
5157
5158
+ // Even after some time Fiona is not added back.
5154
5159
SystemTime :: shift ( Duration :: from_secs ( 3600 ) ) ;
5155
5160
let sent_msg = alice. send_text ( alice_chat_id, "Welcome back, Fiona!" ) . await ;
5156
5161
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." )
5158
5168
. await ;
5169
+ alice. recv_msg ( & sent_msg) . await ;
5170
+ assert_eq ! ( get_chat_contacts( & alice, alice_chat_id) . await ?. len( ) , 2 ) ;
5171
+
5159
5172
Ok ( ( ) )
5160
5173
}
5161
5174
0 commit comments