Skip to content

Commit 02b5fa8

Browse files
committed
test: member added in channel has display name
1 parent e30d833 commit 02b5fa8

1 file changed

Lines changed: 69 additions & 1 deletion

File tree

src/securejoin/securejoin_tests.rs

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use deltachat_contact_tools::EmailAddress;
44
use regex::Regex;
55

66
use super::*;
7-
use crate::chat::{CantSendReason, add_contact_to_chat, remove_contact_from_chat};
7+
use crate::chat::{CantSendReason, ChatItem, add_contact_to_chat, remove_contact_from_chat};
88
use crate::chatlist::Chatlist;
99
use crate::constants::Chattype;
1010
use crate::constants::DC_CHAT_ID_TRASH;
@@ -1584,3 +1584,71 @@ async fn test_auth_token_is_synchronized() -> Result<()> {
15841584

15851585
Ok(())
15861586
}
1587+
1588+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
1589+
async fn test_channel_sync_message_reorder() -> Result<()> {
1590+
let mut tcm = TestContextManager::new();
1591+
let alice = &tcm.alice().await;
1592+
let alice2 = &tcm.alice().await;
1593+
let bob = &tcm.bob().await;
1594+
bob.set_config(Config::Displayname, Some("Bob"))
1595+
.await
1596+
.unwrap();
1597+
1598+
alice.set_config_bool(Config::SyncMsgs, true).await?;
1599+
alice2.set_config_bool(Config::SyncMsgs, true).await?;
1600+
1601+
let alice_chat_id = chat::create_broadcast(alice, "Channel".to_string()).await?;
1602+
let qr = get_securejoin_qr(alice, Some(alice_chat_id)).await?;
1603+
alice.send_sync_msg().await.unwrap();
1604+
let sync_msg = alice.pop_sent_msg().await;
1605+
alice2.recv_msg_trash(&sync_msg).await;
1606+
1607+
tcm.section("Bob scans the QR code");
1608+
join_securejoin(&bob, &qr).await?;
1609+
1610+
// vc-request-pubkey
1611+
let sent = bob.pop_sent_msg().await;
1612+
alice.recv_msg_trash(&sent).await;
1613+
1614+
// vc-pubkey
1615+
let sent = alice.pop_sent_msg().await;
1616+
bob.recv_msg_trash(&sent).await;
1617+
1618+
// vc-request-with-auth
1619+
let sent = bob.pop_sent_msg().await;
1620+
alice.recv_msg_trash(&sent).await;
1621+
1622+
// Alice sends to self a sync message about member addition.
1623+
alice.send_sync_msg().await.unwrap();
1624+
let sync_msg = alice.pop_sent_msg().await;
1625+
alice2.recv_msg_trash(&sync_msg).await;
1626+
1627+
// Member added.
1628+
let sent = alice.pop_sent_msg().await;
1629+
bob.recv_msg(&sent).await;
1630+
1631+
// Bob addition is already synced.
1632+
alice2.recv_msg_trash(&sent).await;
1633+
1634+
let alice2_chatlist = Chatlist::try_load(alice2, 0, None, None).await?;
1635+
assert_eq!(alice2_chatlist.len(), 1);
1636+
1637+
let alice2_chat_id = alice2_chatlist.get_chat_id(0)?;
1638+
//let alice2_chat = Chat::load_from_db(alice2, alice2_chat_id).await?;
1639+
let alice2_msgs = crate::chat::get_chat_msgs(alice2, alice2_chat_id).await?;
1640+
1641+
assert_eq!(alice2_msgs.len(), 2);
1642+
let ChatItem::Message { msg_id } = alice2_msgs[0] else {
1643+
panic!("Wrong item type");
1644+
};
1645+
let msg1 = Message::load_from_db(alice2, msg_id).await?;
1646+
assert_eq!(msg1.text, "Messages are end-to-end encrypted.");
1647+
let ChatItem::Message { msg_id } = alice2_msgs[1] else {
1648+
panic!("Wrong item type");
1649+
};
1650+
let msg2 = Message::load_from_db(alice2, msg_id).await?;
1651+
assert_eq!(msg2.text, "Member Bob added.");
1652+
1653+
Ok(())
1654+
}

0 commit comments

Comments
 (0)