diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index 5f50db758..be41a4eb0 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -13,9 +13,10 @@ use crate::constants::DC_GCL_FOR_FORWARDING; use crate::contact; use crate::imap::prefetch_should_download; use crate::imex::{ImexMode, imex}; +use crate::key; use crate::securejoin::get_securejoin_qr; use crate::test_utils::{ - E2EE_INFO_MSGS, TestContext, TestContextManager, get_chat_msg, mark_as_verified, + E2EE_INFO_MSGS, TestContext, TestContextManager, alice_keypair, get_chat_msg, mark_as_verified, }; use crate::tools::{SystemTime, time}; @@ -5562,43 +5563,26 @@ async fn test_calendar_alternative() -> Result<()> { Ok(()) } -/// Test that self-sent encrypted messages are detected as outgoing -/// via signature fingerprint, independently from From address. - +/// Tests that outgoing encrypted messages are detected +/// by verifying own signature, completely ignoring From address. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_outgoing_by_signature_unknown_self_addr() -> Result<()> { +async fn test_outgoing_determined_by_signature() -> Result<()> { let mut tcm = TestContextManager::new(); - let export_dir = tempfile::tempdir().unwrap(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let msg = tcm.send_recv_accept(alice, bob, "hi bob").await; - msg.chat_id.accept(bob).await?; - tcm.send_recv(bob, alice, "hi alice").await; - - imex(alice, ImexMode::ExportSelfKeys, export_dir.path(), None).await?; - // alice_dev2: same key, different address. let different_from = "very@different.from"; assert!(!alice.is_self_addr(different_from).await?); - - let alice_dev2 = &TestContext::new().await; + let alice_dev2 = &tcm.unconfigured().await; alice_dev2.configure_addr(different_from).await; - imex( - alice_dev2, - ImexMode::ImportSelfKeys, - export_dir.path(), - None, - ) - .await?; + key::store_self_keypair(alice_dev2, &alice_keypair()).await?; assert!(alice.get_config(Config::Addr).await?.unwrap() != different_from); - let msg = tcm.send_recv_accept(bob, alice_dev2, "hi alice_dev2").await; - let sent_msg = alice_dev2 - .send_text(msg.chat_id, "hello from new device") - .await; + // Sent message from alice_dev2 and check alice sees it as outgoing + let chat_id = alice_dev2.create_chat_id(bob).await; + let sent_msg = alice_dev2.send_text(chat_id, "hello from new device").await; let msg = alice.recv_msg(&sent_msg).await; - // despite different from it's still recognized as an outgoing message assert_eq!(msg.state, MessageState::OutDelivered); Ok(())