From 9e0decb6cb4d3bffd88731157ece128a525e7851 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Wed, 1 Jun 2022 11:23:30 +0200 Subject: [PATCH] test that bcc_self-updates are not triggered twice bcc_self-updates are not received due to the normal prevention of not even downloading these messages. there is no extra defense of that on webxdc-level; status-updates do not even have a "global-unique" id (they have a local id and the message where they're wrappted into have the "global-unique" Message-Id) --- src/webxdc.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/webxdc.rs b/src/webxdc.rs index fb95a2dd4..866ae4098 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -624,6 +624,7 @@ mod tests { ProtectionStatus, }; use crate::chatlist::Chatlist; + use crate::config::Config; use crate::contact::Contact; use crate::dc_receive_imf::dc_receive_imf; use crate::test_utils::TestContext; @@ -1065,6 +1066,7 @@ mod tests { #[async_std::test] async fn test_send_webxdc_status_update() -> Result<()> { let alice = TestContext::new_alice().await; + alice.set_config_bool(Config::BccSelf, true).await?; let bob = TestContext::new_bob().await; // Alice sends an webxdc instance and a status update @@ -1146,6 +1148,19 @@ mod tests { assert_eq!(alice2_instance.viewtype, Viewtype::Webxdc); assert_eq!(alice2_chat_id.get_msg_cnt(&alice2).await?, 1); + // To support the second device, Alice has enabled bcc_self and will receive their own messages; + // these messages, however, should be ignored + alice.recv_msg_opt(sent1).await; + alice.recv_msg_opt(sent2).await; + assert_eq!(alice_chat.id.get_msg_cnt(&alice).await?, 1); + assert_eq!( + alice + .get_webxdc_status_updates(alice_instance.id, StatusUpdateSerial(0)) + .await?, + r#"[{"payload":{"foo":"bar"},"serial":1,"max_serial":2}, +{"payload":{"snipp":"snapp"},"serial":2,"max_serial":2}]"# + ); + Ok(()) }