@@ -214,6 +214,7 @@ mod tests {
214214 use crate :: chat:: { self , create_group, send_msg} ;
215215 use crate :: headerdef:: { HeaderDef , HeaderDefMap } ;
216216 use crate :: message:: Viewtype ;
217+ use crate :: mimeparser:: MimeMessage ;
217218 use crate :: test_utils:: TestContext ;
218219
219220 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
@@ -250,11 +251,15 @@ mod tests {
250251
251252 /// Tests that pre message is sent for attachment larger than `PRE_MESSAGE_ATTACHMENT_SIZE_THRESHOLD`
252253 /// Also test that pre message is sent first, before the full message
254+ /// And that Autocrypt-gossip and selfavatar never go into full-messages
253255 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
254256 async fn test_sending_pre_message ( ) -> Result < ( ) > {
255257 let alice = TestContext :: new_alice ( ) . await ;
256258 let bob = TestContext :: new_bob ( ) . await ;
257- let chat = alice. create_chat ( & bob) . await ;
259+ let fiona = TestContext :: new_fiona ( ) . await ;
260+ let group_id = alice
261+ . create_group_with_members ( "test group" , & [ & bob, & fiona] )
262+ . await ;
258263
259264 let mut msg = Message :: new ( Viewtype :: File ) ;
260265 msg. set_file_from_bytes ( & alice. ctx , "test.bin" , & [ 0u8 ; 300_000 ] , None ) ?;
@@ -265,7 +270,9 @@ mod tests {
265270 msg. get_filebytes( & alice. ctx) . await ?. unwrap( ) > PRE_MESSAGE_ATTACHMENT_SIZE_THRESHOLD
266271 ) ;
267272
268- let msg_id = chat:: send_msg ( & alice. ctx , chat. id , & mut msg) . await . unwrap ( ) ;
273+ let msg_id = chat:: send_msg ( & alice. ctx , group_id, & mut msg)
274+ . await
275+ . unwrap ( ) ;
269276 let smtp_rows = alice. get_smtp_rows_for_msg ( msg_id) . await ;
270277
271278 // pre-message and full message should be present
@@ -278,13 +285,12 @@ mod tests {
278285 . 2
279286 . as_bytes ( ) ,
280287 ) ?;
281- let full_message = mailparse:: parse_mail (
282- smtp_rows
283- . get ( 1 )
284- . expect ( "second element exists" )
285- . 2
286- . as_bytes ( ) ,
287- ) ?;
288+ let full_message_bytes = smtp_rows
289+ . get ( 1 )
290+ . expect ( "second element exists" )
291+ . 2
292+ . as_bytes ( ) ;
293+ let full_message = mailparse:: parse_mail ( full_message_bytes) ?;
288294
289295 assert ! (
290296 pre_message
@@ -325,7 +331,10 @@ mod tests {
325331 ) ;
326332
327333 // also test that Autocrypt-gossip and selfavatar should never go into full-messages
328- // TODO: (this needs decryption, right?)
334+ let decrypted_full_message = MimeMessage :: from_bytes ( & bob. ctx , full_message_bytes) . await ?;
335+ assert ! ( !decrypted_full_message. decrypting_failed) ;
336+ assert_eq ! ( decrypted_full_message. gossiped_keys. len( ) , 0 ) ;
337+ assert_eq ! ( decrypted_full_message. user_avatar, None ) ;
329338 Ok ( ( ) )
330339 }
331340
0 commit comments