@@ -1133,14 +1133,16 @@ mod tests {
1133
1133
. with_log_sink ( log_tx)
1134
1134
. build ( )
1135
1135
. await ;
1136
+
1137
+ // We start with empty chatlists.
1136
1138
assert_eq ! ( Chatlist :: try_load( & alice, 0 , None , None ) . await ?. len( ) , 0 ) ;
1137
1139
assert_eq ! ( Chatlist :: try_load( & bob, 0 , None , None ) . await ?. len( ) , 0 ) ;
1138
1140
1139
- let chatid =
1141
+ let alice_chatid =
1140
1142
chat:: create_group_chat ( & alice. ctx , ProtectionStatus :: Protected , "the chat" ) . await ?;
1141
1143
1142
1144
// Step 1: Generate QR-code, secure-join implied by chatid
1143
- let qr = dc_get_securejoin_qr ( & alice. ctx , Some ( chatid ) )
1145
+ let qr = dc_get_securejoin_qr ( & alice. ctx , Some ( alice_chatid ) )
1144
1146
. await
1145
1147
. unwrap ( ) ;
1146
1148
@@ -1232,9 +1234,9 @@ mod tests {
1232
1234
) ;
1233
1235
1234
1236
{
1235
- // TODO: Check if Alice has a hidden 1:1 chat in which there is an info message
1236
- // saying bob is verified. However currently this is purposefully sent to
1237
- // Alice's group chat by commit 3b7b8ea0f1f8b9c9d300388768eed069be59c8be?
1237
+ // Now Alice's chat with Bob should still be hidden, the verified message should
1238
+ // appear in the group chat.
1239
+
1238
1240
let chat = alice
1239
1241
. get_chat ( & bob)
1240
1242
. await
@@ -1244,20 +1246,20 @@ mod tests {
1244
1246
Blocked :: Yes ,
1245
1247
"Alice's 1:1 chat with Bob is not hidden"
1246
1248
) ;
1247
- // let msg_id = chat::get_chat_msgs(&alice.ctx, chat.get_id() , 0x1, None)
1248
- // .await
1249
- // .unwrap()
1250
- // .into_iter()
1251
- // .filter_map(|item| match item {
1252
- // chat::ChatItem::Message { msg_id } => Some(msg_id),
1253
- // _ => None,
1254
- // })
1255
- // .max ()
1256
- // .expect("No messages in Alice's 1:1 chat");
1257
- // let msg = Message::load_from_db(&alice.ctx, msg_id).await.unwrap();
1258
- // assert!(msg.is_info());
1259
- // let text = msg.get_text().unwrap();
1260
- // assert!(text.contains("[email protected] verified"));
1249
+ let msg_id = chat:: get_chat_msgs ( & alice. ctx , alice_chatid , 0x1 , None )
1250
+ . await
1251
+ . unwrap ( )
1252
+ . into_iter ( )
1253
+ . filter_map ( |item| match item {
1254
+ chat:: ChatItem :: Message { msg_id } => Some ( msg_id) ,
1255
+ _ => None ,
1256
+ } )
1257
+ . min ( )
1258
+ . expect ( "No messages in Alice's group chat" ) ;
1259
+ let msg = Message :: load_from_db ( & alice. ctx , msg_id) . await . unwrap ( ) ;
1260
+ assert ! ( msg. is_info( ) ) ;
1261
+ let text = msg. get_text ( ) . unwrap ( ) ;
1262
+ assert ! ( text
. contains
( "[email protected] verified" ) ) ;
1261
1263
}
1262
1264
1263
1265
// Bob should not yet have Alice verified
@@ -1274,10 +1276,56 @@ mod tests {
1274
1276
1275
1277
// Step 7: Bob receives vg-member-added, sends vg-member-added-received
1276
1278
bob. recv_msg ( & sent) . await ;
1277
- assert_eq ! (
1278
- contact_alice. is_verified( & bob. ctx) . await ?,
1279
- VerifiedStatus :: BidirectVerified
1280
- ) ;
1279
+ {
1280
+ // Bob has Alice verified, message shows up in the group chat.
1281
+ assert_eq ! (
1282
+ contact_alice. is_verified( & bob. ctx) . await ?,
1283
+ VerifiedStatus :: BidirectVerified
1284
+ ) ;
1285
+ let chat = bob
1286
+ . get_chat ( & alice)
1287
+ . await
1288
+ . expect ( "Bob has no 1:1 chat with Alice" ) ;
1289
+ assert_eq ! (
1290
+ chat. blocked,
1291
+ Blocked :: Yes ,
1292
+ "Bob's 1:1 chat with Alice is not hidden"
1293
+ ) ;
1294
+ for item in chat:: get_chat_msgs ( & bob. ctx , bob_chatid, 0x1 , None )
1295
+ . await
1296
+ . unwrap ( )
1297
+ {
1298
+ match item {
1299
+ chat:: ChatItem :: Message { msg_id } => {
1300
+ let msg = Message :: load_from_db ( & bob. ctx , msg_id) . await . unwrap ( ) ;
1301
+ let text = msg. get_text ( ) . unwrap ( ) ;
1302
+ println ! ( "msg {} text: {}" , msg_id, text) ;
1303
+ }
1304
+ _ => ( ) ,
1305
+ }
1306
+ }
1307
+ let mut msg_iter = chat:: get_chat_msgs ( & bob. ctx , bob_chatid, 0x1 , None )
1308
+ . await
1309
+ . unwrap ( )
1310
+ . into_iter ( ) ;
1311
+ loop {
1312
+ match msg_iter. next ( ) {
1313
+ Some ( chat:: ChatItem :: Message { msg_id } ) => {
1314
+ let msg = Message :: load_from_db ( & bob. ctx , msg_id) . await . unwrap ( ) ;
1315
+ let text = msg. get_text ( ) . unwrap ( ) ;
1316
+ match text
. contains ( "[email protected] verified" ) {
1317
+ true => {
1318
+ assert ! ( msg. is_info( ) ) ;
1319
+ break ;
1320
+ }
1321
+ false => continue ,
1322
+ }
1323
+ }
1324
+ Some ( _) => continue ,
1325
+ None => panic ! ( "Verified message not found in Bob's group chat" ) ,
1326
+ }
1327
+ }
1328
+ }
1281
1329
1282
1330
let sent = bob. pop_sent_msg ( ) . await ;
1283
1331
let msg = alice. parse_msg ( & sent) . await ;
0 commit comments