From 08c9deee042063e6fef3e1afb182f172787fa8d7 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 24 Feb 2023 15:37:03 +0100 Subject: [PATCH] add test for Context::update_contacts_timestamp(), esp. the condition and the update was not covered before --- src/receive_imf/tests.rs | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/receive_imf/tests.rs b/src/receive_imf/tests.rs index 50aa285ce..2fec63df4 100644 --- a/src/receive_imf/tests.rs +++ b/src/receive_imf/tests.rs @@ -2133,6 +2133,76 @@ Original signature updated", Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_ignore_old_status_updates() -> Result<()> { + let t = TestContext::new_alice().await; + let bob_id = Contact::add_or_lookup( + &t, + "", + ContactAddress::new("bob@example.net")?, + Origin::AddressBook, + ) + .await? + .0; + + receive_imf( + &t, + b"From: Bob +To: Alice +Message-ID: <2@example.org> +Date: Wed, 22 Feb 2023 20:00:00 +0000 + +body + +-- +sig wednesday", + false, + ) + .await?; + let chat_id = t.get_last_msg().await.chat_id; + let bob = Contact::load_from_db(&t, bob_id).await?; + assert_eq!(bob.get_status(), "sig wednesday"); + assert_eq!(get_chat_msgs(&t, chat_id).await?.len(), 1); + + receive_imf( + &t, + b"From: Bob +To: Alice +Message-ID: <1@example.org> +Date: Tue, 21 Feb 2023 20:00:00 +0000 + +body + +-- +sig tuesday", + false, + ) + .await?; + let bob = Contact::load_from_db(&t, bob_id).await?; + assert_eq!(bob.get_status(), "sig wednesday"); + assert_eq!(get_chat_msgs(&t, chat_id).await?.len(), 2); + + receive_imf( + &t, + b"From: Bob +To: Alice +Message-ID: <3@example.org> +Date: Thu, 23 Feb 2023 20:00:00 +0000 + +body + +-- +sig thursday", + false, + ) + .await?; + let bob = Contact::load_from_db(&t, bob_id).await?; + assert_eq!(bob.get_status(), "sig thursday"); + assert_eq!(get_chat_msgs(&t, chat_id).await?.len(), 3); + + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_chat_assignment_private_classical_reply() { for outgoing_is_classical in &[true, false] {