@@ -4,6 +4,7 @@ use pretty_assertions::assert_eq;
44
55use crate :: EventType ;
66use crate :: chat;
7+ use crate :: config:: Config ;
78use crate :: contact;
89use crate :: download:: { DownloadState , PRE_MSG_ATTACHMENT_SIZE_THRESHOLD , PostMsgMetadata } ;
910use crate :: message:: { Message , MessageState , Viewtype , delete_msgs, markseen_msgs} ;
@@ -253,6 +254,49 @@ async fn test_lost_pre_msg() -> Result<()> {
253254 Ok ( ( ) )
254255}
255256
257+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
258+ async fn test_pre_msg_mdn ( ) -> Result < ( ) > {
259+ let mut tcm = TestContextManager :: new ( ) ;
260+ let alice = & tcm. alice ( ) . await ;
261+ alice
262+ . set_config_bool ( Config :: PopSentMsgFromHead , true )
263+ . await ?;
264+ let bob = & tcm. bob ( ) . await ;
265+ let alice_chat_id = alice. create_group_with_members ( "" , & [ bob] ) . await ;
266+
267+ let file_bytes = include_bytes ! ( "../../../test-data/image/screenshot.gif" ) ;
268+ let mut msg = Message :: new ( Viewtype :: Image ) ;
269+ msg. set_file_from_bytes ( alice, "a.jpg" , file_bytes, None ) ?;
270+ msg. set_text ( "populate" . to_string ( ) ) ;
271+ let pre_msg = alice. send_msg ( alice_chat_id, & mut msg) . await ;
272+ let alice_msg_id = msg. id ;
273+
274+ let msg = bob. recv_msg ( & pre_msg) . await ;
275+ assert_eq ! ( msg. download_state, DownloadState :: Available ) ;
276+ assert_eq ! ( msg. id. get_state( bob) . await ?, MessageState :: InFresh ) ;
277+ assert_eq ! ( msg. text, "populate" ) ;
278+ markseen_msgs ( bob, vec ! [ msg. id] ) . await ?;
279+ assert_eq ! ( msg. id. get_state( bob) . await ?, MessageState :: InSeen ) ;
280+ assert_eq ! (
281+ bob. sql. count( "SELECT COUNT(*) FROM smtp_mdns" , ( ) ) . await ?,
282+ 1
283+ ) ;
284+ smtp:: queue_mdn ( bob) . await ?;
285+ alice. recv_msg_trash ( & bob. pop_sent_msg ( ) . await ) . await ;
286+ assert_eq ! (
287+ alice_msg_id. get_state( alice) . await ?,
288+ MessageState :: OutPending
289+ ) ;
290+
291+ let _full_msg = alice. pop_sent_msg ( ) . await ;
292+ // BUG: Must be `OutMdnRcvd`
293+ assert_eq ! (
294+ alice_msg_id. get_state( alice) . await ?,
295+ MessageState :: OutDelivered
296+ ) ;
297+ Ok ( ( ) )
298+ }
299+
256300#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
257301async fn test_post_msg_bad_sender ( ) -> Result < ( ) > {
258302 let mut tcm = TestContextManager :: new ( ) ;
0 commit comments