From b9ff40c6b5407d328b17040f0afccbee94a974ef Mon Sep 17 00:00:00 2001 From: iequidoo Date: Wed, 3 Sep 2025 07:18:25 -0300 Subject: [PATCH] test: Message is OutFailed if all keys are missing (#6849) Follow-up to 143ba6d5e7c48e41bc62eb1e2a26230cd7761c8c before which a message remained in `OutPending` indefinitely in such a case. --- src/chat/chat_tests.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index b2124f941..0bf5ebe6a 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -3173,6 +3173,30 @@ async fn test_chat_get_encryption_info() -> Result<()> { Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_out_failed_on_all_keys_missing() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = &tcm.alice().await; + let bob = &tcm.bob().await; + let fiona = &tcm.fiona().await; + + let bob_chat_id = bob + .create_group_with_members(ProtectionStatus::Unprotected, "", &[alice, fiona]) + .await; + bob.send_text(bob_chat_id, "Gossiping Fiona's key").await; + alice + .recv_msg(&bob.send_text(bob_chat_id, "No key gossip").await) + .await; + SystemTime::shift(Duration::from_secs(60)); + remove_contact_from_chat(bob, bob_chat_id, ContactId::SELF).await?; + let alice_chat_id = alice.recv_msg(&bob.pop_sent_msg().await).await.chat_id; + alice_chat_id.accept(alice).await?; + let mut msg = Message::new_text("Hi".to_string()); + send_msg(alice, alice_chat_id, &mut msg).await.ok(); + assert_eq!(msg.id.get_state(alice).await?, MessageState::OutFailed); + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_chat_media() -> Result<()> { let t = TestContext::new_alice().await;