From bde97b20e928af5f05a2a7c33c0b79d3e4fdcbdf Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 10 Jun 2020 15:27:20 +0200 Subject: [PATCH] Repair getting x-failed-recipients header, all tests passing now --- src/dc_receive_imf.rs | 35 +++++------------------------------ src/mimeparser.rs | 2 +- src/test_utils.rs | 11 ++++++----- 3 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 6bf07bf82..a1e14a3dc 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -1779,7 +1779,7 @@ mod tests { use crate::chat::ChatVisibility; use crate::chatlist::Chatlist; use crate::message::Message; - use crate::test_utils::{configured_offline_context, dummy_context}; + use crate::test_utils::*; #[test] fn test_hex_hash() { @@ -2380,19 +2380,7 @@ mod tests { raw_ndn: &[u8], error_msg: &str, ) { - let t = dummy_context().await; - t.ctx - .set_config(Config::Addr, Some(self_addr)) - .await - .unwrap(); - t.ctx - .set_config(Config::ConfiguredAddr, Some(self_addr)) - .await - .unwrap(); - t.ctx - .set_config(Config::Configured, Some("1")) - .await - .unwrap(); + let t = configured_offline_context_with_addr(self_addr).await; dc_receive_imf( &t.ctx, @@ -2429,26 +2417,14 @@ mod tests { #[async_std::test] async fn test_parse_ndn_group_msg() { - let t = dummy_context().await; - t.ctx - .set_config(Config::Addr, Some("alice@gmail.com")) - .await - .unwrap(); - t.ctx - .set_config(Config::ConfiguredAddr, Some("alice@gmail.com")) - .await - .unwrap(); - t.ctx - .set_config(Config::Configured, Some("1")) - .await - .unwrap(); + let t = configured_offline_context_with_addr("alice@gmail.com").await; dc_receive_imf( &t.ctx, b"From: alice@gmail.com\n\ To: bob@example.org, assidhfaaspocwaeofi@gmail.com\n\ Subject: foo\n\ - Message-ID: \n\ + Message-ID: \n\ Chat-Version: 1.0\n\ Chat-Group-ID: abcde\n\ Chat-Group-Name: foo\n\ @@ -2477,12 +2453,10 @@ mod tests { assert_eq!(msg.state, MessageState::OutFailed); let msgs = chat::get_chat_msgs(&t.ctx, msg.chat_id, 0, None).await; - println!("Loading {}…", msg.chat_id); let last_msg = Message::load_from_db(&t.ctx, *msgs.last().unwrap()) .await .unwrap(); - assert_eq!(last_msg.from_id, DC_CONTACT_ID_INFO); assert_eq!( last_msg.text, Some( @@ -2494,5 +2468,6 @@ mod tests { .await, ) ); + assert_eq!(last_msg.from_id, DC_CONTACT_ID_INFO); } } diff --git a/src/mimeparser.rs b/src/mimeparser.rs index f895212b9..1b7ca48b6 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -876,7 +876,7 @@ impl MimeMessage { .and_then(|v| parse_message_id(&v).ok()) { let mut to_list = get_all_addresses_from_header(&report.headers, |header_key| { - header_key == "X-Failed-Recipients" + header_key == "x-failed-recipients" }); let to = if to_list.len() == 1 { Some(to_list.pop().unwrap()) diff --git a/src/test_utils.rs b/src/test_utils.rs index 9724252a5..1502b1ccf 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -41,13 +41,14 @@ pub(crate) async fn dummy_context() -> TestContext { } pub(crate) async fn configured_offline_context() -> TestContext { + configured_offline_context_with_addr("alice@example.org").await +} + +pub(crate) async fn configured_offline_context_with_addr(addr: &str) -> TestContext { let t = dummy_context().await; + t.ctx.set_config(Config::Addr, Some(addr)).await.unwrap(); t.ctx - .set_config(Config::Addr, Some("alice@example.org")) - .await - .unwrap(); - t.ctx - .set_config(Config::ConfiguredAddr, Some("alice@example.org")) + .set_config(Config::ConfiguredAddr, Some(addr)) .await .unwrap(); t.ctx