From 4479000b71c6e1fda44d907a6bffc05f200d2563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kl=C3=A4hn?= Date: Wed, 8 Jan 2025 10:39:51 +0100 Subject: [PATCH] start test --- src/chat.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/chat.rs b/src/chat.rs index 99769fbcf..a4875274e 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -7718,4 +7718,50 @@ mod tests { assert_eq!(draft1.timestamp_sort, draft2.timestamp_sort); Ok(()) } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + /// Test for issue https://github.com/deltachat/deltachat-core-rust/issues/6408 + async fn test_race_condition() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = tcm.alice().await; + let bob = tcm.bob().await; + let group_editor = tcm.fiona().await; + + // alice creates verified group with group editor bot + tcm.execute_securejoin(&alice, &bob).await; + let alice_chat_id = alice + .create_group_with_members( + ProtectionStatus::Protected, + "Group with everyone", + &[&group_editor], + ) + .await; + let msg = alice.send_text(alice_chat_id, "hi").await; + let recv = group_editor.recv_msg(&msg).await; + + // group editor bot sends a message + let group_editor_chat_id = recv.chat_id; + let webxdc = group_editor + .send_text(group_editor_chat_id, "") + .await; + alice.recv_msg(&webxdc).await; + + // Alice adds bob + let bob_contact = alice.add_or_lookup_contact_id(&bob).await; + add_contact_to_chat(&alice, alice_chat_id, bob_contact).await?; + let msg = alice.pop_sent_msg().await; + + // group editor bot resends webxdc + group_editor.recv_msg(&msg).await; + resend_msgs(&group_editor, &[webxdc.sender_msg_id]).await?; + let resent = group_editor.pop_sent_msg().await; + + // Bob receives webxdc before joining the group + bob.recv_msg(&resent).await; + bob.recv_msg(&msg).await; + + // + + Ok(()) + } }