From 1ea864701852f27a71a923ae73ab64daa75d5985 Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 16 Apr 2025 11:47:51 +0000 Subject: [PATCH] test: test that key of the recipient is gossiped in 1:1 chats It is needed for multi-device setups. --- src/chat/chat_tests.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index be3d206d9..0bb4ecd20 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -4050,3 +4050,35 @@ async fn test_send_delete_request_no_encryption() -> Result<()> { assert_eq!(alice_chat.id.get_msg_cnt(alice).await?, 1); Ok(()) } + +/// Tests that in multi-device setup +/// second device learns the key of a contact +/// via Autocrypt-Gossip in 1:1 chats. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_oneone_gossip() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = &tcm.alice().await; + let alice2 = &tcm.alice().await; + let bob = &tcm.bob().await; + + tcm.section("Alice imports Bob's vCard and sends a message from the first device"); + let alice_chat = alice.create_chat(bob).await; + let sent_msg = alice.send_text(alice_chat.id, "Hello Bob!").await; + + tcm.section("Alice receives a copy on second device"); + let rcvd_msg = alice2.recv_msg(&sent_msg).await; + assert_eq!(rcvd_msg.get_showpadlock(), true); + + tcm.section("Alice sends a message from the second device"); + let alice2_chat_id = rcvd_msg.chat_id; + let sent_msg2 = alice2 + .send_text(alice2_chat_id, "Hello from second device!") + .await; + + tcm.section("Bob receives a message from the second device"); + let rcvd_msg2 = bob.recv_msg(&sent_msg2).await; + assert_eq!(rcvd_msg2.get_showpadlock(), true); + assert_eq!(rcvd_msg2.text, "Hello from second device!"); + + Ok(()) +}