From 4ea6d9d85d2ff761b1ccdc61be624481b8573013 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Mon, 29 Jul 2024 19:29:23 -0300 Subject: [PATCH] test: Order of messages if Sentbox is synced before Inbox --- src/receive_imf/tests.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/receive_imf/tests.rs b/src/receive_imf/tests.rs index 68181be2cf..622a0ccb84 100644 --- a/src/receive_imf/tests.rs +++ b/src/receive_imf/tests.rs @@ -4691,6 +4691,40 @@ async fn test_protected_group_add_remove_member_missing_key() -> Result<()> { Ok(()) } +/// Alice is offline for some time. +/// When she comes online, first her sentbox is synced and then her inbox. +/// This tests that the messages are still in the right order. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_sync_sentbox_then_inbox() -> Result<()> { + let alice = &TestContext::new_alice().await; + let msg_sent = receive_imf( + alice, + b"From: alice@example.org\n\ + To: Bob \n\ + Message-ID: <1234-2-4@example.org>\n\ + Date: Sat, 09 Dec 2019 19:00:27 +0000\n\ + \n\ + Thanks, Bob!\n", + true, + ) + .await? + .unwrap(); + let msg_incoming = receive_imf( + alice, + b"From: Bob \n\ + To: alice@example.org\n\ + Message-ID: <1234-2-3@example.org>\n\ + Date: Sun, 08 Dec 2019 19:00:27 +0000\n\ + \n\ + Happy birthday, Alice!\n", + true, + ) + .await? + .unwrap(); + assert!(msg_incoming.sort_timestamp < msg_sent.sort_timestamp); + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_dont_create_adhoc_group_on_member_removal() -> Result<()> { let mut tcm = TestContextManager::new();