Skip to content

Commit e837ced

Browse files
committed
test: add group consistency bug test
1 parent fa9bd7f commit e837ced

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/chat.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7681,4 +7681,50 @@ mod tests {
76817681

76827682
Ok(())
76837683
}
7684+
7685+
/// Tests that info message is not picked as a parent.
7686+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
7687+
async fn test_add_member_bug() -> Result<()> {
7688+
let mut tcm = TestContextManager::new();
7689+
7690+
let alice = &tcm.alice().await;
7691+
let bob = &tcm.bob().await;
7692+
7693+
let alice_bob_contact_id = Contact::create(alice, "Bob", "bob@example.net").await?;
7694+
let alice_fiona_contact_id = Contact::create(alice, "Fiona", "fiona@example.net").await?;
7695+
7696+
// Create a group.
7697+
let alice_chat_id =
7698+
create_group_chat(alice, ProtectionStatus::Unprotected, "Group chat").await?;
7699+
add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?;
7700+
add_contact_to_chat(alice, alice_chat_id, alice_fiona_contact_id).await?;
7701+
7702+
// Promote the group.
7703+
let alice_sent_msg = alice
7704+
.send_text(alice_chat_id, "Hi! I created a group.")
7705+
.await;
7706+
let bob_received_msg = bob.recv_msg(&alice_sent_msg).await;
7707+
7708+
let bob_chat_id = bob_received_msg.get_chat_id();
7709+
bob_chat_id.accept(&bob).await?;
7710+
7711+
// Alice removes Fiona from the chat.
7712+
remove_contact_from_chat(alice, alice_chat_id, alice_fiona_contact_id).await?;
7713+
let _alice_sent_add_msg = alice.pop_sent_msg().await;
7714+
7715+
SystemTime::shift(Duration::from_secs(3600));
7716+
7717+
// Bob sends a message
7718+
// to Alice and Fiona because he still has not received
7719+
// a message about Fiona being removed.
7720+
let bob_sent_msg = bob.send_text(bob_chat_id, "Hi Alice!").await;
7721+
7722+
// Alice receives a message.
7723+
// This should not add Fiona back.
7724+
let _alice_received_msg = alice.recv_msg(&bob_sent_msg).await;
7725+
7726+
assert_eq!(get_chat_contacts(alice, alice_chat_id).await?.len(), 2);
7727+
7728+
Ok(())
7729+
}
76847730
}

0 commit comments

Comments
 (0)