Compare commits

...

2 Commits

Author SHA1 Message Date
Sebastian Klähn
2a4dab9ade fixes 2025-01-15 10:13:34 +01:00
Sebastian Klähn
4479000b71 start test 2025-01-08 10:39:51 +01:00

View File

@@ -4660,6 +4660,7 @@ mod tests {
use crate::headerdef::HeaderDef;
use crate::message::delete_msgs;
use crate::receive_imf::receive_imf;
use crate::securejoin::{get_securejoin_qr, join_securejoin};
use crate::test_utils::{sync, TestContext, TestContextManager, TimeShiftFalsePositiveNote};
use strum::IntoEnumIterator;
use tokio::fs;
@@ -7718,4 +7719,63 @@ 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, &group_editor).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;
group_editor_chat_id.accept(&group_editor).await?;
let webxdc = group_editor
.send_text(group_editor_chat_id, "<Webxdc>")
.await;
alice.recv_msg(&webxdc).await;
tcm.section("bob scans alice' QR code");
let join_qr = get_securejoin_qr(&alice, Some(alice_chat_id)).await?;
join_securejoin(&bob, &join_qr).await.unwrap();
loop {
if let Some(sent) = bob.pop_sent_msg_opt(Duration::ZERO).await {
alice.recv_msg_opt(&sent).await;
} else if let Some(sent) = alice.pop_sent_msg_opt(Duration::ZERO).await {
bob.recv_msg_opt(&sent).await;
} else {
break;
}
}
let chatlist = Chatlist::try_load(&bob, 0, None, None).await?;
println!(
"{:?}",
get_chat_contacts(&bob, chatlist.iter().last().unwrap().0).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(())
}
}