Skip to content

Commit 661a886

Browse files
committed
test: add a test reproducing chat assignment bug
1 parent 67f00fb commit 661a886

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/receive_imf/receive_imf_tests.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5194,3 +5194,55 @@ async fn test_partial_download_key_contact_lookup() -> Result<()> {
51945194

51955195
Ok(())
51965196
}
5197+
5198+
/// Tests that outgoing unencrypted message
5199+
/// is assigned to a chat with email-contact.
5200+
///
5201+
/// Previously such message got assigned to Saved Messages
5202+
/// if it had In-Reply-To due to a bug resulting
5203+
/// in attempt to lookup key-contacts in the existing
5204+
/// chat pointed to by In-Reply-To.
5205+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
5206+
async fn test_outgoing_unencrypted_chat_assignment() {
5207+
let mut tcm = TestContextManager::new();
5208+
let alice = &tcm.alice().await;
5209+
let bob = &tcm.bob().await;
5210+
5211+
tcm.section("Alice receives unencrypted message from Bob");
5212+
receive_imf(
5213+
alice,
5214+
b"From: bob@example.net\n\
5215+
To: alice@example.org\n\
5216+
Subject: Message from Bob\n\
5217+
Message-ID: <message@example.net>\n\
5218+
Chat-Version: 1.0\n\
5219+
Date: Sun, 22 Mar 2020 22:37:57 +0000\n\
5220+
\n\
5221+
Hello, Alice!\n",
5222+
false,
5223+
)
5224+
.await
5225+
.unwrap()
5226+
.unwrap();
5227+
5228+
tcm.section("Alice sends unencrypted reply to Bob from another device");
5229+
let received = receive_imf(
5230+
alice,
5231+
b"From: alice@example.org\n\
5232+
To: bob@example.net\n\
5233+
Subject: Message from Alice\n\
5234+
Message-ID: <message@example.org>\n\
5235+
Chat-Version: 1.0\n\
5236+
In-Reply-To: <message@example.net>\n\
5237+
Date: Sun, 22 Mar 2020 22:37:57 +0000\n\
5238+
\n\
5239+
Hello, Bob!\n",
5240+
false,
5241+
)
5242+
.await
5243+
.unwrap()
5244+
.unwrap();
5245+
5246+
let chat = alice.create_email_chat(bob).await;
5247+
assert_eq!(received.chat_id, chat.id);
5248+
}

0 commit comments

Comments
 (0)