mirror of
https://github.com/chatmail/core.git
synced 2026-10-04 20:20:17 +03:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8479098397 |
@@ -278,8 +278,7 @@ async fn test_maybe_add_additional_relays_failure() -> Result<()> {
|
||||
t.assert_warns_or_errors(&[
|
||||
"DNS lookup with memory cache failure",
|
||||
"Could not find DNS resolutions",
|
||||
])
|
||||
.await;
|
||||
]);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+22
-22
@@ -75,7 +75,7 @@ async fn setup_call() -> Result<CallSetup> {
|
||||
for (t, m) in [(&bob, &bob_call), (&bob2, &bob2_call)] {
|
||||
assert!(!m.is_info());
|
||||
assert_eq!(m.viewtype, Viewtype::Call);
|
||||
t.evtracker
|
||||
t.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::IncomingCall { .. }))
|
||||
.await;
|
||||
let info = t
|
||||
@@ -129,7 +129,7 @@ async fn accept_call() -> Result<CallSetup> {
|
||||
1
|
||||
);
|
||||
assert_text(&bob, bob_call.id, "Incoming video call").await?;
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
@@ -151,7 +151,7 @@ async fn accept_call() -> Result<CallSetup> {
|
||||
|
||||
bob2.recv_msg_trash(&sent2).await;
|
||||
assert_text(&bob, bob_call.id, "Incoming video call").await?;
|
||||
bob2.evtracker
|
||||
bob2.get_evtracker()
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
@@ -173,7 +173,7 @@ async fn accept_call() -> Result<CallSetup> {
|
||||
alice.recv_msg_trash(&sent2).await;
|
||||
assert_text(&alice, alice_call.id, "Outgoing video call").await?;
|
||||
let ev = alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::OutgoingCallAccepted { .. }))
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -195,7 +195,7 @@ async fn accept_call() -> Result<CallSetup> {
|
||||
alice2.recv_msg_trash(&sent2).await;
|
||||
assert_text(&alice2, alice2_call.id, "Outgoing video call").await?;
|
||||
alice2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::OutgoingCallAccepted { .. }))
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -244,7 +244,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
|
||||
1
|
||||
);
|
||||
assert_text(&bob, bob_call.id, "Incoming video call\n<1 minute").await?;
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
let sent3 = bob.pop_sent_msg().await;
|
||||
@@ -255,7 +255,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
|
||||
|
||||
bob2.recv_msg_trash(&sent3).await;
|
||||
assert_text(&bob2, bob2_call.id, "Incoming video call\n<1 minute").await?;
|
||||
bob2.evtracker
|
||||
bob2.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert!(matches!(
|
||||
@@ -267,7 +267,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
|
||||
alice.recv_msg_trash(&sent3).await;
|
||||
assert_text(&alice, alice_call.id, "Outgoing video call\n<1 minute").await?;
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert!(matches!(
|
||||
@@ -278,7 +278,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
|
||||
alice2.recv_msg_trash(&sent3).await;
|
||||
assert_text(&alice2, alice2_call.id, "Outgoing video call\n<1 minute").await?;
|
||||
alice2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert!(matches!(
|
||||
@@ -308,7 +308,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
|
||||
alice.end_call(alice_call.id).await?;
|
||||
assert_text(&alice, alice_call.id, "Outgoing video call\n<1 minute").await?;
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
let sent3 = alice.pop_sent_msg().await;
|
||||
@@ -320,7 +320,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
|
||||
alice2.recv_msg_trash(&sent3).await;
|
||||
assert_text(&alice2, alice2_call.id, "Outgoing video call\n<1 minute").await?;
|
||||
alice2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert!(matches!(
|
||||
@@ -331,7 +331,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
|
||||
// Bob receives the ending message
|
||||
bob.recv_msg_trash(&sent3).await;
|
||||
assert_text(&bob, bob_call.id, "Incoming video call\n<1 minute").await?;
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert!(matches!(
|
||||
@@ -341,7 +341,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
|
||||
|
||||
bob2.recv_msg_trash(&sent3).await;
|
||||
assert_text(&bob2, bob2_call.id, "Incoming video call\n<1 minute").await?;
|
||||
bob2.evtracker
|
||||
bob2.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert!(matches!(
|
||||
@@ -381,7 +381,7 @@ async fn test_callee_rejects_call() -> Result<()> {
|
||||
1
|
||||
);
|
||||
assert_text(&bob, bob_call.id, "Declined call").await?;
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
let sent3 = bob.pop_sent_msg().await;
|
||||
@@ -389,7 +389,7 @@ async fn test_callee_rejects_call() -> Result<()> {
|
||||
|
||||
bob2.recv_msg_trash(&sent3).await;
|
||||
assert_text(&bob2, bob2_call.id, "Declined call").await?;
|
||||
bob2.evtracker
|
||||
bob2.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert_eq!(call_state(&bob2, bob2_call.id).await?, CallState::Declined);
|
||||
@@ -398,7 +398,7 @@ async fn test_callee_rejects_call() -> Result<()> {
|
||||
alice.recv_msg_trash(&sent3).await;
|
||||
assert_text(&alice, alice_call.id, "Declined call").await?;
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -409,7 +409,7 @@ async fn test_callee_rejects_call() -> Result<()> {
|
||||
alice2.recv_msg_trash(&sent3).await;
|
||||
assert_text(&alice2, alice2_call.id, "Declined call").await?;
|
||||
alice2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -468,7 +468,7 @@ async fn test_caller_cancels_call() -> Result<()> {
|
||||
alice.end_call(alice_call.id).await?;
|
||||
assert_text(&alice, alice_call.id, "Canceled call").await?;
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
let sent3 = alice.pop_sent_msg().await;
|
||||
@@ -480,7 +480,7 @@ async fn test_caller_cancels_call() -> Result<()> {
|
||||
alice2.recv_msg_trash(&sent3).await;
|
||||
assert_text(&alice2, alice2_call.id, "Canceled call").await?;
|
||||
alice2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -491,7 +491,7 @@ async fn test_caller_cancels_call() -> Result<()> {
|
||||
// Bob receives the ending message
|
||||
bob.recv_msg_trash(&sent3).await;
|
||||
assert_text(&bob, bob_call.id, "Missed call").await?;
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert_eq!(call_state(&bob, bob_call.id).await?, CallState::Missed);
|
||||
@@ -503,7 +503,7 @@ async fn test_caller_cancels_call() -> Result<()> {
|
||||
|
||||
bob2.recv_msg_trash(&sent3).await;
|
||||
assert_text(&bob2, bob2_call.id, "Missed call").await?;
|
||||
bob2.evtracker
|
||||
bob2.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||
.await;
|
||||
assert_eq!(call_state(&bob2, bob2_call.id).await?, CallState::Missed);
|
||||
@@ -679,7 +679,7 @@ async fn test_end_text_call() -> Result<()> {
|
||||
.unwrap();
|
||||
assert_eq!(received2.msg_ids.len(), 1);
|
||||
assert_eq!(received2.chat_id, DC_CHAT_ID_TRASH);
|
||||
alice.assert_warn("does not refer to a call message").await;
|
||||
alice.assert_warn("does not refer to a call message");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+41
-63
@@ -310,8 +310,7 @@ async fn test_add_contact_to_chat_ex_add_self() {
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(added, false);
|
||||
t.assert_warn("Invalid attempt to add self e-mail address to group")
|
||||
.await;
|
||||
t.assert_warn("Invalid attempt to add self e-mail address to group");
|
||||
}
|
||||
|
||||
/// Test adding and removing members in a group chat.
|
||||
@@ -739,7 +738,7 @@ async fn test_leave_group() -> Result<()> {
|
||||
|
||||
// Clear events so that we can later check
|
||||
// that the 'Group left' message didn't trigger IncomingMsg:
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
|
||||
// Shift the time so that we can later check the 'Group left' message's timestamp:
|
||||
SystemTime::shift(Duration::from_secs(60));
|
||||
@@ -758,7 +757,7 @@ async fn test_leave_group() -> Result<()> {
|
||||
|
||||
alice.emit_event(EventType::Test);
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|ev| match ev {
|
||||
EventType::Test => true,
|
||||
EventType::IncomingMsg { .. } => panic!("'Group left' message should be silent"),
|
||||
@@ -1309,7 +1308,7 @@ async fn test_marknoticed_all_chats() -> Result<()> {
|
||||
);
|
||||
|
||||
tcm.section("alice: mark as read");
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
marknoticed_all_chats(alice).await?;
|
||||
tcm.section("alice: check that chats are no longer unread and that chatlist update events were received");
|
||||
assert_eq!(alice_chat_normal.get_fresh_msg_cnt(alice).await?, 0);
|
||||
@@ -1321,7 +1320,7 @@ async fn test_marknoticed_all_chats() -> Result<()> {
|
||||
0
|
||||
);
|
||||
|
||||
let emitted_events = alice.evtracker.take_events();
|
||||
let emitted_events = alice.get_evtracker().take_events();
|
||||
for event in &[
|
||||
EventType::ChatlistItemChanged {
|
||||
chat_id: Some(alice_chat_normal),
|
||||
@@ -1457,10 +1456,10 @@ async fn test_archive_fresh_msgs() -> Result<()> {
|
||||
assert_eq!(DC_CHAT_ID_ARCHIVED_LINK.get_fresh_msg_cnt(&t).await?, 2);
|
||||
|
||||
// mark one of the archived+muted chats as noticed: check that the archive-link counter is changed as well
|
||||
t.evtracker.clear_events();
|
||||
t.get_evtracker().clear_events();
|
||||
marknoticed_chat(&t, claire_chat_id).await?;
|
||||
let ev = t
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|ev| {
|
||||
matches!(
|
||||
ev,
|
||||
@@ -2879,8 +2878,7 @@ async fn test_broadcast_members_cant_see_each_other() -> Result<()> {
|
||||
let parsed_by_bob = bob.parse_msg(&vc_pubkey).await;
|
||||
assert!(parsed_by_bob.decryption_error.is_some());
|
||||
|
||||
bob.assert_warn("Could not find symmetric secret for session key")
|
||||
.await;
|
||||
bob.assert_warn("Could not find symmetric secret for session key");
|
||||
|
||||
charlie.recv_msg_trash(&vc_pubkey).await;
|
||||
}
|
||||
@@ -2919,8 +2917,7 @@ async fn test_broadcast_members_cant_see_each_other() -> Result<()> {
|
||||
|
||||
let parsed_by_bob = bob.parse_msg(&member_added).await;
|
||||
assert!(parsed_by_bob.decryption_error.is_some());
|
||||
bob.assert_warn("decryption failed: decrypt_the_ring: missing key")
|
||||
.await;
|
||||
bob.assert_warn("decryption failed: decrypt_the_ring: missing key");
|
||||
|
||||
let rcvd = charlie.recv_msg(&member_added).await;
|
||||
assert_eq!(rcvd.param.get_cmd(), SystemMessage::MemberAddedToGroup);
|
||||
@@ -2953,8 +2950,7 @@ async fn test_broadcast_members_cant_see_each_other() -> Result<()> {
|
||||
|
||||
let parsed_by_bob = bob.parse_msg(&member_removed).await;
|
||||
assert!(parsed_by_bob.decryption_error.is_some());
|
||||
bob.assert_warn("decryption failed: decrypt_the_ring: missing key")
|
||||
.await;
|
||||
bob.assert_warn("decryption failed: decrypt_the_ring: missing key");
|
||||
|
||||
let rcvd = charlie.recv_msg(&member_removed).await;
|
||||
assert_eq!(rcvd.param.get_cmd(), SystemMessage::MemberRemovedFromGroup);
|
||||
@@ -3208,9 +3204,9 @@ async fn test_broadcast_resend_to_new_member() -> Result<()> {
|
||||
.is_some()
|
||||
);
|
||||
bob.recv_msg_trash(&resent_msg).await;
|
||||
bob.assert_warn("missing key").await;
|
||||
bob.assert_warn("missing key").await;
|
||||
bob.assert_warn("unencrypted message").await;
|
||||
bob.assert_warn("missing key");
|
||||
bob.assert_warn("missing key");
|
||||
bob.assert_warn("unencrypted message");
|
||||
}
|
||||
assert!(alice.pop_sent_msg_opt().await.is_none());
|
||||
Ok(())
|
||||
@@ -3229,7 +3225,7 @@ async fn test_broadcast_resend_failed_msg_to_new_member() -> Result<()> {
|
||||
let alice_msg_id = alice.send_text(alice_bc_id, "text").await.sender_msg_id;
|
||||
let mut msg = Message::load_from_db(alice, alice_msg_id).await?;
|
||||
message::set_msg_failed(alice, &mut msg, "error").await?;
|
||||
alice.assert_warn("error").await;
|
||||
alice.assert_warn("error");
|
||||
let fiona_bc_id = tcm.exec_securejoin_qr(fiona, alice, &qr).await;
|
||||
let resent_msg = alice.pop_sent_msg().await;
|
||||
let fiona_msg = fiona.recv_msg(&resent_msg).await;
|
||||
@@ -3321,7 +3317,7 @@ async fn test_broadcast_recipients_sync1() -> Result<()> {
|
||||
sync(alice1, alice2).await;
|
||||
let a2_chatlist = Chatlist::try_load(alice2, 0, Some("Channel"), None).await?;
|
||||
assert!(a2_chatlist.is_empty());
|
||||
alice2.assert_warn("No chat for grpid").await;
|
||||
alice2.assert_warn("No chat for grpid");
|
||||
|
||||
// Alice1 adds Charlie to the broadcast channel,
|
||||
// and now, Alice2 receives the messages
|
||||
@@ -3337,7 +3333,7 @@ async fn test_broadcast_recipients_sync1() -> Result<()> {
|
||||
let request_with_auth = charlie.pop_sent_msg().await;
|
||||
alice1.recv_msg_trash(&request_with_auth).await;
|
||||
alice2.recv_msg_trash(&request_with_auth).await;
|
||||
alice2.assert_warn("unknown grpid").await;
|
||||
alice2.assert_warn("unknown grpid");
|
||||
|
||||
let member_added = alice1.pop_sent_msg().await;
|
||||
let a2_charlie_added = alice2.recv_msg(&member_added).await;
|
||||
@@ -3920,7 +3916,7 @@ async fn test_leave_broadcast() -> Result<()> {
|
||||
|
||||
// Clear events so that we can later check
|
||||
// that the 'Broadcast channel left' message didn't trigger IncomingMsg:
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
|
||||
// Shift the time so that we can later check the "Broadcast channel left" message's timestamp:
|
||||
SystemTime::shift(Duration::from_secs(60));
|
||||
@@ -3946,7 +3942,7 @@ async fn test_leave_broadcast() -> Result<()> {
|
||||
|
||||
alice.emit_event(EventType::Test);
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|ev| match ev {
|
||||
EventType::Test => true,
|
||||
EventType::IncomingMsg { .. } => {
|
||||
@@ -4051,8 +4047,8 @@ async fn test_leave_broadcast_multidevice() -> Result<()> {
|
||||
|
||||
tcm.section("Bob's second device also receives these messages");
|
||||
bob1.recv_msg_trash(&vc_pubkey).await;
|
||||
bob1.assert_warn("decryption failed").await;
|
||||
bob1.assert_warn("unencrypted message").await;
|
||||
bob1.assert_warn("decryption failed");
|
||||
bob1.assert_warn("unencrypted message");
|
||||
bob1.recv_msg_trash(&request_with_auth).await;
|
||||
bob1.recv_msg(&member_added).await;
|
||||
|
||||
@@ -4142,7 +4138,7 @@ async fn test_only_broadcast_owner_can_send_1() -> Result<()> {
|
||||
"Bob receives an answer, but shows it in a single chat because of a fingerprint mismatch",
|
||||
);
|
||||
let rcvd = bob.recv_msg(&member_added).await;
|
||||
bob.assert_warn("wrong sender").await;
|
||||
bob.assert_warn("wrong sender");
|
||||
assert_eq!(rcvd.text, "Member bob@example.net was added.");
|
||||
|
||||
let bob_alice_chat_id = bob.get_chat(alice).await.id;
|
||||
@@ -4207,19 +4203,7 @@ async fn test_only_broadcast_owner_can_send_2() -> Result<()> {
|
||||
tcm.section("Alice sends a message, which is trashed");
|
||||
let sent = alice.send_text(alice_broadcast_id, "Hi").await;
|
||||
bob.recv_msg_trash(&sent).await;
|
||||
bob.assert_warn("This sender is not allowed to encrypt with this secret key")
|
||||
.await;
|
||||
let EventType::Warning(warning) = bob
|
||||
.evtracker
|
||||
.get_matching(|ev| matches!(ev, EventType::Warning(_)))
|
||||
.await
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
assert!(
|
||||
warning.contains("This sender is not allowed to encrypt with this secret key"),
|
||||
"Wrong warning: {warning}"
|
||||
);
|
||||
bob.assert_warn("This sender is not allowed to encrypt with this secret key");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -4322,10 +4306,8 @@ async fn test_encrypt_decrypt_broadcast() -> Result<()> {
|
||||
|
||||
tcm.section("If Bob doesn't know the secret, he can't decrypt the message");
|
||||
bob_without_secret.recv_msg_trash(&sent).await;
|
||||
bob_without_secret
|
||||
.assert_warn("Could not find symmetric secret for session key")
|
||||
.await;
|
||||
bob_without_secret.assert_warn("unencrypted message").await;
|
||||
bob_without_secret.assert_warn("Could not find symmetric secret for session key");
|
||||
bob_without_secret.assert_warn("unencrypted message");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -4455,8 +4437,8 @@ async fn test_out_failed_on_all_keys_missing() -> Result<()> {
|
||||
let mut msg = Message::new_text("Hi".to_string());
|
||||
send_msg(alice, alice_chat_id, &mut msg).await.ok();
|
||||
assert_eq!(msg.id.get_state(alice).await?, MessageState::OutFailed);
|
||||
alice.assert_warn("Missing key").await;
|
||||
alice.assert_warn("cannot encrypt").await;
|
||||
alice.assert_warn("Missing key");
|
||||
alice.assert_warn("cannot encrypt");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -4881,7 +4863,7 @@ async fn test_sync_delete_chat() -> Result<()> {
|
||||
sync(alice0, alice1).await;
|
||||
alice1.assert_no_chat(a1b_chat_id).await;
|
||||
alice1
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ChatDeleted { .. }))
|
||||
.await;
|
||||
|
||||
@@ -4895,7 +4877,7 @@ async fn test_sync_delete_chat() -> Result<()> {
|
||||
sync(alice0, alice1).await;
|
||||
alice1.assert_no_chat(a1_grp_chat_id).await;
|
||||
alice0
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ChatDeleted { .. }))
|
||||
.await;
|
||||
|
||||
@@ -5077,9 +5059,8 @@ async fn test_sync_broadcast_and_send_message() -> Result<()> {
|
||||
let bob_broadcast_id = tcm
|
||||
.exec_securejoin_qr_multi_device(bob, &[alice1, alice2], &qr)
|
||||
.await;
|
||||
bob.assert_warn("Could not find symmetric secret for session key")
|
||||
.await;
|
||||
bob.assert_warn("unencrypted message").await;
|
||||
bob.assert_warn("Could not find symmetric secret for session key");
|
||||
bob.assert_warn("unencrypted message");
|
||||
|
||||
let a2b_contact_id = alice2.add_or_lookup_contact_no_key(bob).await.id;
|
||||
assert_eq!(
|
||||
@@ -5262,8 +5243,8 @@ async fn test_blocked_bob_cant_join_chat() -> Result<()> {
|
||||
|
||||
tcm.exec_securejoin_qr_multi_device(bob, &[alice1, alice2], &qr)
|
||||
.await;
|
||||
alice2.assert_warn("blocked").await;
|
||||
alice2.assert_warn("blocked").await;
|
||||
alice2.assert_warn("blocked");
|
||||
alice2.assert_warn("blocked");
|
||||
let alice1_bob_id = alice1.add_or_lookup_contact_id(bob).await;
|
||||
assert_eq!(get_chat_contacts(alice1, alice1_chat_id).await?.len(), 2);
|
||||
// "vg-member-added" from alice1 adds bob for alice2 to provide membership consistency on
|
||||
@@ -5278,7 +5259,7 @@ async fn test_blocked_bob_cant_join_chat() -> Result<()> {
|
||||
remove_contact_from_chat(alice1, alice1_chat_id, alice1_bob_id).await?;
|
||||
bob.recv_msg(&alice1.pop_sent_msg().await).await;
|
||||
tcm.exec_securejoin_qr(bob, alice1, &qr).await;
|
||||
alice1.assert_warn("blocked").await;
|
||||
alice1.assert_warn("blocked");
|
||||
let members = get_chat_contacts(alice1, alice1_chat_id).await?;
|
||||
assert_eq!(members.len(), 1);
|
||||
assert!(members.contains(&ContactId::SELF));
|
||||
@@ -5310,7 +5291,7 @@ async fn test_blocked_bob_cant_create_single_chat_via_securejoin() -> Result<()>
|
||||
tcm.exec_securejoin_qr_multi_device(bob, &[alice1, alice2], &qr)
|
||||
.await;
|
||||
for _ in 0..3 {
|
||||
alice2.assert_warn("blocked").await;
|
||||
alice2.assert_warn("blocked");
|
||||
}
|
||||
assert_eq!(get_chat_cnt(alice1).await?, chat_cnt + 1);
|
||||
assert_eq!(get_chat_cnt(alice2).await?, chat_cnt);
|
||||
@@ -5407,7 +5388,7 @@ async fn test_nonimage_with_png_ext() -> Result<()> {
|
||||
msg.get_filename().unwrap().contains("screenshot"),
|
||||
vt == Viewtype::File
|
||||
);
|
||||
alice.assert_error("Unknown format").await;
|
||||
alice.assert_error("Unknown format");
|
||||
let msg_bob = bob.recv_msg(&sent_msg).await;
|
||||
assert_eq!(msg_bob.viewtype, Viewtype::File);
|
||||
assert_eq!(msg_bob.get_filemime().unwrap(), "application/octet-stream");
|
||||
@@ -5731,7 +5712,7 @@ async fn test_non_member_cannot_modify_member_list() -> Result<()> {
|
||||
remove_contact_from_chat(bob, bob_chat_id, bob_alice_contact_id).await?;
|
||||
let bob_sent_add_msg = bob.pop_sent_msg().await;
|
||||
alice.recv_msg_trash(&bob_sent_add_msg).await;
|
||||
alice.assert_warn("no contact id").await;
|
||||
alice.assert_warn("no contact id");
|
||||
assert_eq!(get_chat_contacts(alice, alice_chat_id).await?.len(), 1);
|
||||
Ok(())
|
||||
}
|
||||
@@ -6108,8 +6089,7 @@ async fn test_receive_edit_request_after_removal() -> Result<()> {
|
||||
|
||||
bob.recv_msg_trash(&sent2).await;
|
||||
assert_eq!(bob_chat_id.get_msg_cnt(bob).await?, E2EE_INFO_MSGS);
|
||||
bob.assert_warn("Edit message: Database entry does not exist")
|
||||
.await;
|
||||
bob.assert_warn("Edit message: Database entry does not exist");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -6203,7 +6183,7 @@ async fn test_send_delete_request() -> Result<()> {
|
||||
let bob2 = &tcm.bob().await;
|
||||
bob2.recv_msg_opt(&sent2).await;
|
||||
assert!(bob2.recv_msg_opt(&sent1).await.is_none());
|
||||
bob2.assert_warn("not found").await;
|
||||
bob2.assert_warn("not found");
|
||||
|
||||
// Alice has another device, and there is also nothing at the end
|
||||
let alice2 = &tcm.alice().await;
|
||||
@@ -6495,9 +6475,7 @@ async fn test_create_unencrypted_group_chat() -> Result<()> {
|
||||
assert!(res.is_err());
|
||||
|
||||
add_contact_to_chat(alice, chat_id, charlie_address_contact_id).await?;
|
||||
alice
|
||||
.assert_warn("No good message identifying the chat found")
|
||||
.await;
|
||||
alice.assert_warn("No good message identifying the chat found");
|
||||
|
||||
let chat = Chat::load_from_db(alice, chat_id).await?;
|
||||
assert!(!chat.is_encrypted(alice).await?);
|
||||
@@ -6514,7 +6492,7 @@ async fn test_create_group_invalid_name() -> Result<()> {
|
||||
let chat_id = create_group(alice, " ").await?;
|
||||
let chat = Chat::load_from_db(alice, chat_id).await?;
|
||||
assert_eq!(chat.get_name(), "…");
|
||||
alice.assert_error("Invalid chat name").await;
|
||||
alice.assert_error("Invalid chat name");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -6538,7 +6516,7 @@ async fn test_no_avatar_in_adhoc_chats() -> Result<()> {
|
||||
.await?
|
||||
.unwrap()
|
||||
.chat_id;
|
||||
alice.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("unencrypted message");
|
||||
|
||||
// Test that setting avatar in ad hoc group is not possible.
|
||||
let file = alice.dir.path().join("avatar.png");
|
||||
|
||||
@@ -300,7 +300,7 @@ async fn test_event_config_synced() -> Result<()> {
|
||||
.set_config(Config::Displayname, Some("Alice Sync"))
|
||||
.await?;
|
||||
alice0
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|e| {
|
||||
matches!(
|
||||
e,
|
||||
@@ -316,7 +316,7 @@ async fn test_event_config_synced() -> Result<()> {
|
||||
Some("Alice Sync".to_string())
|
||||
);
|
||||
alice1
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|e| {
|
||||
matches!(
|
||||
e,
|
||||
@@ -329,7 +329,7 @@ async fn test_event_config_synced() -> Result<()> {
|
||||
|
||||
alice0.set_config(Config::Displayname, None).await?;
|
||||
alice0
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|e| {
|
||||
matches!(
|
||||
e,
|
||||
|
||||
+1
-1
@@ -760,7 +760,7 @@ mod tests {
|
||||
t.set_config(Config::MailPw, Some("123456")).await.unwrap();
|
||||
assert!(t.configure().await.is_err());
|
||||
|
||||
t.assert_warns_or_errors(&["DNS resolution"]).await;
|
||||
t.assert_warns_or_errors(&["DNS resolution"]);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
|
||||
@@ -238,7 +238,7 @@ async fn test_add_or_lookup() {
|
||||
"\nWonderland, Alice <alice@w.de>\n",
|
||||
);
|
||||
assert_eq!(Contact::add_address_book(&t, book).await.unwrap(), 4);
|
||||
t.assert_warn(r#"invalid address "+1234567890""#).await;
|
||||
t.assert_warn(r#"invalid address "+1234567890""#);
|
||||
|
||||
// check first added contact, this modifies authname because it is empty
|
||||
let (contact_id, sth_modified) = Contact::add_or_lookup(
|
||||
@@ -999,7 +999,7 @@ async fn test_selfavatar_changed_event() -> Result<()> {
|
||||
.await?;
|
||||
|
||||
alice1
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|e| matches!(e, EventType::SelfavatarChanged))
|
||||
.await;
|
||||
|
||||
@@ -1008,7 +1008,7 @@ async fn test_selfavatar_changed_event() -> Result<()> {
|
||||
// Alice's second device applies the selfavatar.
|
||||
assert!(alice2.get_config(Config::Selfavatar).await?.is_some());
|
||||
alice2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|e| matches!(e, EventType::SelfavatarChanged))
|
||||
.await;
|
||||
|
||||
@@ -1075,11 +1075,11 @@ async fn test_was_seen_recently_event() -> Result<()> {
|
||||
let sent_msg = alice.send_text(chat.id, "moin").await;
|
||||
let contact = Contact::get_by_id(&bob, *contacts.first().unwrap()).await?;
|
||||
assert!(!contact.was_seen_recently());
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
bob.recv_msg(&sent_msg).await;
|
||||
let contact = Contact::get_by_id(&bob, *contacts.first().unwrap()).await?;
|
||||
assert!(contact.was_seen_recently());
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ContactsChanged { .. }))
|
||||
.await;
|
||||
recently_seen_loop
|
||||
@@ -1087,20 +1087,21 @@ async fn test_was_seen_recently_event() -> Result<()> {
|
||||
.await;
|
||||
|
||||
// Wait for `was_seen_recently()` to turn off.
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
SystemTime::shift(Duration::from_secs(SEEN_RECENTLY_SECONDS as u64 * 2));
|
||||
recently_seen_loop.interrupt(ContactId::UNDEFINED, 0).await;
|
||||
let contact = Contact::get_by_id(&bob, *contacts.first().unwrap()).await?;
|
||||
assert!(!contact.was_seen_recently());
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ContactsChanged { .. }))
|
||||
.await;
|
||||
}
|
||||
// this warning is only printed when `RecentlySeenLoop` is dropped,
|
||||
// so we can't assert it otherwise.
|
||||
drop(recently_seen_loop);
|
||||
bob.assert_warn("receiving from an empty and closed channel")
|
||||
.await;
|
||||
// wait for logs
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
bob.assert_warn("receiving from an empty and closed channel");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1252,12 +1253,12 @@ async fn test_make_n_import_vcard() -> Result<()> {
|
||||
assert!(t0 <= timestamp && timestamp <= t1);
|
||||
|
||||
let alice = &TestContext::new_alice().await;
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
let contact_ids = import_vcard(alice, &vcard).await?;
|
||||
assert_eq!(contact_ids.len(), 2);
|
||||
for _ in 0..contact_ids.len() {
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ContactsChanged(Some(_))))
|
||||
.await;
|
||||
}
|
||||
@@ -1280,18 +1281,18 @@ async fn test_make_n_import_vcard() -> Result<()> {
|
||||
assert!(msg.get_showpadlock());
|
||||
|
||||
// Bob only actually imports Fiona, though `ContactId::SELF` is also returned.
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
let contact_ids = import_vcard(bob, &vcard).await?;
|
||||
bob.emit_event(EventType::Test);
|
||||
assert_eq!(contact_ids.len(), 2);
|
||||
assert_eq!(contact_ids[0], ContactId::SELF);
|
||||
let ev = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ContactsChanged { .. }))
|
||||
.await;
|
||||
assert_eq!(ev, EventType::ContactsChanged(Some(contact_ids[1])));
|
||||
let ev = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ContactsChanged { .. } | EventType::Test))
|
||||
.await;
|
||||
assert_eq!(ev, EventType::Test);
|
||||
@@ -1317,10 +1318,10 @@ async fn test_import_vcard_key_change() -> Result<()> {
|
||||
let bob_addr = &bob.get_config(Config::Addr).await?.unwrap();
|
||||
bob.set_config(Config::Displayname, Some("Bob")).await?;
|
||||
let vcard = make_vcard(bob, &[ContactId::SELF]).await?;
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
let alice_bob_id = import_vcard(alice, &vcard).await?[0];
|
||||
let ev = alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ContactsChanged { .. }))
|
||||
.await;
|
||||
assert_eq!(ev, EventType::ContactsChanged(Some(alice_bob_id)));
|
||||
@@ -1423,10 +1424,10 @@ async fn test_name_changes() -> Result<()> {
|
||||
assert_eq!(bob_alice_contact.get_display_name(), "Alice Revision 2");
|
||||
|
||||
// Explicitly rename contact to "Renamed".
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
bob_alice_contact.id.set_name(bob, "Renamed").await?;
|
||||
let event = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|e| matches!(e, EventType::ContactsChanged { .. }))
|
||||
.await;
|
||||
assert_eq!(
|
||||
|
||||
@@ -616,11 +616,10 @@ async fn test_cache_is_cleared_when_io_is_started() -> Result<()> {
|
||||
// Starting IO will fail of course because no server settings are configured,
|
||||
// but it should invalidate the caches:
|
||||
alice.start_io().await;
|
||||
|
||||
alice
|
||||
.assert_warn("No IMAP connection candidates provided")
|
||||
.await;
|
||||
alice.assert_warn("IMAP got rate limited").await;
|
||||
// wait for logs
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
alice.assert_warn("No IMAP connection candidates provided");
|
||||
alice.assert_warn("IMAP got rate limited");
|
||||
|
||||
assert_eq!(
|
||||
alice.get_config(Config::Displayname).await?,
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ Sent with my Delta Chat Messenger: https://delta.chat";
|
||||
assert!(chat::send_msg(alice, chat.id, &mut msg).await.is_err());
|
||||
let expected_error = "\u{26a0}\u{fe0f} Your email provider example.org requires end-to-end encryption which is not setup yet.";
|
||||
assert_eq!(msg.error().unwrap(), expected_error);
|
||||
alice.assert_warn(expected_error).await;
|
||||
alice.assert_warn(expected_error);
|
||||
let info_msg = alice.get_last_msg().await;
|
||||
assert_eq!(
|
||||
info_msg.get_info_type(),
|
||||
|
||||
@@ -223,8 +223,7 @@ async fn test_ephemeral_timer_rollback() -> Result<()> {
|
||||
Timer::Disabled
|
||||
);
|
||||
assert_eq!(chat_bob.get_ephemeral_timer(&bob.ctx).await?, enabled(60));
|
||||
bob.assert_warn("Ignoring ephemeral timer change to Disabled")
|
||||
.await;
|
||||
bob.assert_warn("Ignoring ephemeral timer change to Disabled");
|
||||
|
||||
// Alice receives message from Bob
|
||||
alice.recv_msg(&sent_timer_change).await;
|
||||
@@ -331,7 +330,7 @@ async fn check_msg_will_be_deleted(
|
||||
|
||||
assert!(next_expiration < deleted_at);
|
||||
delete_expired_messages(t, deleted_at).await?;
|
||||
t.evtracker
|
||||
t.get_evtracker()
|
||||
.get_matching(|evt| {
|
||||
if let EventType::MsgDeleted {
|
||||
msg_id: event_msg_id,
|
||||
@@ -840,9 +839,7 @@ async fn test_ephemeral_timer_non_member() -> Result<()> {
|
||||
Timer::Disabled
|
||||
);
|
||||
|
||||
alice
|
||||
.assert_warn("Ignoring ephemeral timer change to Enabled")
|
||||
.await;
|
||||
alice.assert_warn("Ignoring ephemeral timer change to Enabled");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -876,11 +873,9 @@ async fn test_disappearing_unknown_viewtype() -> Result<()> {
|
||||
|
||||
// This should not fail.
|
||||
delete_expired_messages(alice, time()).await?;
|
||||
alice
|
||||
.assert_warn(
|
||||
"Using default viewtype for ephemeral handling.: Integer 70 out of range at index 2",
|
||||
)
|
||||
.await;
|
||||
alice.assert_warn(
|
||||
"Using default viewtype for ephemeral handling.: Integer 70 out of range at index 2",
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -912,10 +907,8 @@ async fn test_delete_device_after_unknown_viewtype() -> Result<()> {
|
||||
|
||||
// This should not fail.
|
||||
delete_expired_messages(alice, time()).await?;
|
||||
alice
|
||||
.assert_warn(
|
||||
"Using default viewtype for delete-old handling.: Integer 70 out of range at index 2",
|
||||
)
|
||||
.await;
|
||||
alice.assert_warn(
|
||||
"Using default viewtype for delete-old handling.: Integer 70 out of range at index 2",
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ mod test_chatlist_events {
|
||||
async fn wait_for_chatlist_and_specific_item(context: &TestContext, chat_id: ChatId) {
|
||||
let first_event_is_item = AtomicBool::new(false);
|
||||
context
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| match evt {
|
||||
EventType::ChatlistItemChanged {
|
||||
chat_id: Some(ev_chat_id),
|
||||
@@ -104,7 +104,7 @@ mod test_chatlist_events {
|
||||
|
||||
async fn wait_for_chatlist_specific_item(context: &TestContext, chat_id: ChatId) {
|
||||
context
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| match evt {
|
||||
EventType::ChatlistItemChanged {
|
||||
chat_id: Some(ev_chat_id),
|
||||
@@ -116,14 +116,14 @@ mod test_chatlist_events {
|
||||
|
||||
async fn wait_for_chatlist_all_items(context: &TestContext) {
|
||||
context
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ChatlistItemChanged { chat_id: None }))
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn wait_for_chatlist(context: &TestContext) {
|
||||
context
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ChatlistChanged))
|
||||
.await;
|
||||
}
|
||||
@@ -170,12 +170,12 @@ mod test_chatlist_events {
|
||||
.await?;
|
||||
set_muted(&bob, bob_chat.id, MuteDuration::Forever).await?;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
|
||||
let sent_msg = alice.send_text(chat.id, "moin2").await;
|
||||
bob.recv_msg(&sent_msg).await;
|
||||
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|evt| match evt {
|
||||
EventType::ChatlistItemChanged {
|
||||
chat_id: Some(chat_id),
|
||||
@@ -205,7 +205,7 @@ mod test_chatlist_events {
|
||||
let sent_msg = alice.send_text(chat.id, "moin2").await;
|
||||
bob.recv_msg(&sent_msg).await;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
chat::marknoticed_chat(&bob, DC_CHAT_ID_ARCHIVED_LINK).await?;
|
||||
wait_for_chatlist_specific_item(&bob, DC_CHAT_ID_ARCHIVED_LINK).await;
|
||||
|
||||
@@ -222,7 +222,7 @@ mod test_chatlist_events {
|
||||
let sent_msg = alice.send_text(alice_to_bob_chat.id, "hello").await;
|
||||
bob.recv_msg(&sent_msg).await;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
// set alice name then receive messagefrom her with bob
|
||||
alice.set_config(Config::Displayname, Some("Alice")).await?;
|
||||
let sent_msg = alice
|
||||
@@ -234,7 +234,7 @@ mod test_chatlist_events {
|
||||
|
||||
wait_for_chatlist_all_items(&bob).await;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
// set name
|
||||
alice_on_bob.id.set_name(&bob, "Alice2").await?;
|
||||
assert!(bob.add_or_lookup_contact(&alice).await.get_display_name() == "Alice2");
|
||||
@@ -254,7 +254,7 @@ mod test_chatlist_events {
|
||||
let sent_msg = alice.send_text(alice_to_bob_chat.id, "hello").await;
|
||||
bob.recv_msg(&sent_msg).await;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
// set alice avatar then receive messagefrom her with bob
|
||||
let file = alice.dir.path().join("avatar.png");
|
||||
let bytes = include_bytes!("../../test-data/image/avatar64x64.png");
|
||||
@@ -280,7 +280,7 @@ mod test_chatlist_events {
|
||||
let alice = tcm.alice().await;
|
||||
let chat = create_group(&alice, "My Group").await?;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
chat.delete(&alice).await?;
|
||||
wait_for_chatlist(&alice).await;
|
||||
Ok(())
|
||||
@@ -291,7 +291,7 @@ mod test_chatlist_events {
|
||||
async fn test_create_group() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = tcm.alice().await;
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
let chat = create_group(&alice, "My Group").await?;
|
||||
wait_for_chatlist_and_specific_item(&alice, chat).await;
|
||||
Ok(())
|
||||
@@ -302,7 +302,7 @@ mod test_chatlist_events {
|
||||
async fn test_create_broadcast() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = tcm.alice().await;
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
create_broadcast(&alice, "Channel".to_string()).await?;
|
||||
wait_for_chatlist(&alice).await;
|
||||
Ok(())
|
||||
@@ -315,11 +315,11 @@ mod test_chatlist_events {
|
||||
let alice = tcm.alice().await;
|
||||
let chat = create_group(&alice, "My Group").await?;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
chat::set_muted(&alice, chat, MuteDuration::Forever).await?;
|
||||
wait_for_chatlist_specific_item(&alice, chat).await;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
chat::set_muted(&alice, chat, MuteDuration::NotMuted).await?;
|
||||
wait_for_chatlist_specific_item(&alice, chat).await;
|
||||
|
||||
@@ -340,7 +340,7 @@ mod test_chatlist_events {
|
||||
.unwrap(),
|
||||
);
|
||||
chat::set_muted(&alice, chat, mute_duration).await?;
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
SystemTime::shift(Duration::from_secs(3));
|
||||
wait_for_chatlist_specific_item(&alice, chat).await;
|
||||
|
||||
@@ -354,7 +354,7 @@ mod test_chatlist_events {
|
||||
let alice = tcm.alice().await;
|
||||
let chat = create_group(&alice, "My Group").await?;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
chat::set_chat_name(&alice, chat, "New Name").await?;
|
||||
wait_for_chatlist_specific_item(&alice, chat).await;
|
||||
|
||||
@@ -368,7 +368,7 @@ mod test_chatlist_events {
|
||||
let alice = tcm.alice().await;
|
||||
let chat = create_group(&alice, "My Group").await?;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
let file = alice.dir.path().join("avatar.png");
|
||||
let bytes = include_bytes!("../../test-data/image/avatar64x64.png");
|
||||
tokio::fs::write(&file, bytes).await?;
|
||||
@@ -391,7 +391,7 @@ mod test_chatlist_events {
|
||||
wait_for_chatlist_specific_item(&bob, chat_id_for_bob).await;
|
||||
chat_id_for_bob.accept(&bob).await?;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
chat::set_chat_name(&alice, chat, "New Name").await?;
|
||||
let sent_msg = alice.send_text(chat, "Hello").await;
|
||||
bob.recv_msg(&sent_msg).await;
|
||||
@@ -410,7 +410,7 @@ mod test_chatlist_events {
|
||||
let sent_msg = alice.send_text(chat, "Hello").await;
|
||||
let chat_id_for_bob = bob.recv_msg(&sent_msg).await.chat_id;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
chat_id_for_bob.accept(&bob).await?;
|
||||
wait_for_chatlist_specific_item(&bob, chat_id_for_bob).await;
|
||||
|
||||
@@ -427,7 +427,7 @@ mod test_chatlist_events {
|
||||
let sent_msg = alice.send_text(chat, "Hello").await;
|
||||
let chat_id_for_bob = bob.recv_msg(&sent_msg).await.chat_id;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
chat_id_for_bob.block(&bob).await?;
|
||||
wait_for_chatlist(&bob).await;
|
||||
|
||||
@@ -442,7 +442,7 @@ mod test_chatlist_events {
|
||||
let chat = create_group(&alice, "My Group").await?;
|
||||
let message = chat::send_text_msg(&alice, chat, "Hello World".to_owned()).await?;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
message::delete_msgs(&alice, &[message]).await?;
|
||||
wait_for_chatlist_specific_item(&alice, chat).await;
|
||||
|
||||
@@ -465,7 +465,7 @@ mod test_chatlist_events {
|
||||
let chat_id_for_bob = bob.recv_msg(&sent_msg).await.chat_id;
|
||||
assert!(chat_id_for_bob.get_fresh_msg_cnt(&bob).await? >= 1);
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
chat::marknoticed_chat(&bob, chat_id_for_bob).await?;
|
||||
wait_for_chatlist_specific_item(&bob, chat_id_for_bob).await;
|
||||
|
||||
@@ -480,11 +480,11 @@ mod test_chatlist_events {
|
||||
let contact_id = Contact::create(&alice, "example", "example@example.com").await?;
|
||||
let _ = ChatId::create_for_contact(&alice, contact_id).await;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
Contact::block(&alice, contact_id).await?;
|
||||
wait_for_chatlist(&alice).await;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
Contact::unblock(&alice, contact_id).await?;
|
||||
wait_for_chatlist(&alice).await;
|
||||
|
||||
@@ -506,7 +506,7 @@ mod test_chatlist_events {
|
||||
)
|
||||
.await?;
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ChatEphemeralTimerModified { .. }))
|
||||
.await;
|
||||
|
||||
@@ -533,7 +533,7 @@ Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no
|
||||
|
||||
First thread."#;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
receive_imf(&alice, mime, false).await?;
|
||||
wait_for_chatlist(&alice).await;
|
||||
|
||||
@@ -553,34 +553,34 @@ First thread."#;
|
||||
let qr = get_securejoin_qr(&alice.ctx, Some(alice_chatid)).await?;
|
||||
|
||||
// Step 2: Bob scans QR-code, sends vg-request
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
let bob_chatid = join_securejoin(&bob.ctx, &qr).await?;
|
||||
wait_for_chatlist(&bob).await;
|
||||
|
||||
let sent = bob.pop_sent_msg().await;
|
||||
|
||||
// Step 3: Alice receives vg-request, sends vg-auth-required
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
alice.recv_msg_trash(&sent).await;
|
||||
|
||||
let sent = alice.pop_sent_msg().await;
|
||||
|
||||
// Step 4: Bob receives vg-auth-required, sends vg-request-with-auth
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
bob.recv_msg_trash(&sent).await;
|
||||
wait_for_chatlist_and_specific_item(&bob, bob_chatid).await;
|
||||
|
||||
let sent = bob.pop_sent_msg().await;
|
||||
|
||||
// Step 5+6: Alice receives vg-request-with-auth, sends vg-member-added
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
alice.recv_msg_trash(&sent).await;
|
||||
wait_for_chatlist_and_specific_item(&alice, alice_chatid).await;
|
||||
|
||||
let sent = alice.pop_sent_msg().await;
|
||||
|
||||
// Step 7: Bob receives vg-member-added
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
bob.recv_msg(&sent).await;
|
||||
wait_for_chatlist_and_specific_item(&bob, bob_chatid).await;
|
||||
|
||||
@@ -602,7 +602,7 @@ First thread."#;
|
||||
let message = Message::load_from_db(&alice, msg_id).await?;
|
||||
assert_eq!(message.get_state(), MessageState::OutDelivered);
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
chat::resend_msgs(&alice, &[msg_id]).await?;
|
||||
wait_for_chatlist_specific_item(&alice, chat).await;
|
||||
|
||||
@@ -618,7 +618,7 @@ First thread."#;
|
||||
let msg_id = chat::send_text_msg(&alice, chat, "Hello".to_owned()).await?;
|
||||
let _ = alice.pop_sent_msg().await;
|
||||
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
reaction::send_reaction(&alice, msg_id, "👍").await?;
|
||||
let _ = alice.pop_sent_msg().await;
|
||||
wait_for_chatlist_specific_item(&alice, chat).await;
|
||||
|
||||
+17
-19
@@ -867,7 +867,7 @@ mod tests {
|
||||
{
|
||||
panic!("got error on import: {err:#}");
|
||||
}
|
||||
context2.assert_warn("Failed to import secret key").await;
|
||||
context2.assert_warn("Failed to import secret key");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -900,14 +900,12 @@ mod tests {
|
||||
assert_eq!(msg.chat_id, alice.get_self_chat().await.id);
|
||||
assert_eq!(msg.get_text(), "Encrypted with old key");
|
||||
|
||||
alice
|
||||
.assert_warns_or_errors(&[
|
||||
"rPGP error: unexpected block type: PGP PUBLIC KEY BLOCK",
|
||||
"UNIQUE constraint failed",
|
||||
"IMEX failed to complete",
|
||||
"No private keys found in",
|
||||
])
|
||||
.await;
|
||||
alice.assert_warns_or_errors(&[
|
||||
"rPGP error: unexpected block type: PGP PUBLIC KEY BLOCK",
|
||||
"UNIQUE constraint failed",
|
||||
"IMEX failed to complete",
|
||||
"No private keys found in",
|
||||
]);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -930,7 +928,7 @@ mod tests {
|
||||
.is_ok()
|
||||
);
|
||||
let _event = context1
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ImexProgress(1000)))
|
||||
.await;
|
||||
|
||||
@@ -948,8 +946,8 @@ mod tests {
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
context2.assert_error("file is not a database").await;
|
||||
context2.assert_warn("IMEX failed to complete").await;
|
||||
context2.assert_error("file is not a database");
|
||||
context2.assert_warn("IMEX failed to complete");
|
||||
|
||||
assert!(
|
||||
imex(&context2, ImexMode::ImportBackup, backup.as_ref(), None)
|
||||
@@ -957,7 +955,7 @@ mod tests {
|
||||
.is_ok()
|
||||
);
|
||||
let _event = context2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ImexProgress(1000)))
|
||||
.await;
|
||||
|
||||
@@ -991,7 +989,7 @@ mod tests {
|
||||
|
||||
imex(context1, ImexMode::ExportBackup, backup_dir.path(), None).await?;
|
||||
let _event = context1
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ImexProgress(1000)))
|
||||
.await;
|
||||
|
||||
@@ -999,7 +997,7 @@ mod tests {
|
||||
let backup = has_backup(context2, backup_dir.path()).await?;
|
||||
imex(context2, ImexMode::ImportBackup, backup.as_ref(), None).await?;
|
||||
let _event = context2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ImexProgress(1000)))
|
||||
.await;
|
||||
assert!(context2.is_configured().await?);
|
||||
@@ -1031,7 +1029,7 @@ mod tests {
|
||||
.is_ok()
|
||||
);
|
||||
let _event = context1
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ImexProgress(1000)))
|
||||
.await;
|
||||
let backup = has_backup(&context2, backup_dir.path()).await?;
|
||||
@@ -1067,12 +1065,12 @@ mod tests {
|
||||
|
||||
// Some UIs show the error from the event to the user.
|
||||
// Therefore, it must also be a user-facing string, rather than some technical info:
|
||||
context2.assert_error("This profile is from a newer version of Delta Chat. Please update Delta Chat and try again").await;
|
||||
context2.assert_error("This profile is from a newer version of Delta Chat. Please update Delta Chat and try again");
|
||||
|
||||
context2.assert_warn("IMEX failed to complete").await;
|
||||
context2.assert_warn("IMEX failed to complete");
|
||||
|
||||
context2
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ImexProgress(0)))
|
||||
.await;
|
||||
|
||||
|
||||
+5
-10
@@ -465,10 +465,10 @@ mod tests {
|
||||
|
||||
// Check that both received the ImexProgress events.
|
||||
for ctx in [&ctx0, &ctx1] {
|
||||
ctx.evtracker
|
||||
ctx.get_evtracker()
|
||||
.get_matching(|ev| matches!(ev, EventType::ImexProgress(1)))
|
||||
.await;
|
||||
ctx.evtracker
|
||||
ctx.get_evtracker()
|
||||
.get_matching(|ev| matches!(ev, EventType::ImexProgress(1000)))
|
||||
.await;
|
||||
}
|
||||
@@ -488,16 +488,11 @@ mod tests {
|
||||
// Try to overwrite an existing profile.
|
||||
let err = get_backup(ctx1, provider.qr()).await.unwrap_err();
|
||||
assert!(format!("{err:#}").contains("Cannot import backups to accounts in use"));
|
||||
ctx1.assert_error("Cannot import backups to accounts in use")
|
||||
.await;
|
||||
ctx1.assert_error("Cannot import backups to accounts in use");
|
||||
|
||||
// ctx0 is supposed to also finish, and emit an error:
|
||||
provider.await.unwrap();
|
||||
ctx0.evtracker
|
||||
.get_matching(|e| matches!(e, EventType::Error(_)))
|
||||
.await;
|
||||
ctx0.assert_error("Error while handling backup connection")
|
||||
.await;
|
||||
ctx0.assert_error("Error while handling backup connection");
|
||||
|
||||
assert_eq!(ctx1.get_primary_self_addr().await?, "bob@example.net");
|
||||
|
||||
@@ -511,7 +506,7 @@ mod tests {
|
||||
|
||||
let provider = BackupProvider::prepare(&ctx).await.unwrap();
|
||||
drop(provider);
|
||||
ctx.evtracker
|
||||
ctx.get_evtracker()
|
||||
.get_matching(|ev| matches!(ev, EventType::ImexProgress(0)))
|
||||
.await;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1120,9 +1120,9 @@ Content-Disposition: attachment; filename="location.kml"
|
||||
SystemTime::shift(Duration::from_secs(10));
|
||||
delete_expired(alice, time()).await?;
|
||||
maybe_send(alice).await?;
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
bob.recv_msg_opt(&alice.pop_sent_msg().await).await;
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching_ex(
|
||||
bob,
|
||||
ExpectedEvents {
|
||||
|
||||
+4
-4
@@ -143,11 +143,11 @@ mod tests {
|
||||
assert_eq!(t.get_last_error(), "");
|
||||
|
||||
error!(t, "foo-error");
|
||||
t.assert_error("foo-error").await;
|
||||
t.assert_error("foo-error");
|
||||
assert_eq!(t.get_last_error(), "foo-error");
|
||||
|
||||
warn!(t, "foo-warning");
|
||||
t.assert_warn("foo-warning").await;
|
||||
t.assert_warn("foo-warning");
|
||||
assert_eq!(t.get_last_error(), "foo-error");
|
||||
|
||||
info!(t, "foo-info");
|
||||
@@ -155,8 +155,8 @@ mod tests {
|
||||
|
||||
error!(t, "bar-error");
|
||||
error!(t, "baz-error");
|
||||
t.assert_error("bar-error").await;
|
||||
t.assert_error("baz-error").await;
|
||||
t.assert_error("bar-error");
|
||||
t.assert_error("baz-error");
|
||||
assert_eq!(t.get_last_error(), "baz-error");
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -438,7 +438,7 @@ async fn test_get_state() -> Result<()> {
|
||||
|
||||
set_msg_failed(&alice, &mut alice_msg, "badly failed").await?;
|
||||
assert_state(&alice, alice_msg.id, MessageState::OutFailed).await;
|
||||
alice.assert_warn("badly failed").await;
|
||||
alice.assert_warn("badly failed");
|
||||
|
||||
// check incoming message states on receiver side
|
||||
let bob_msg = bob.recv_msg(&payload).await;
|
||||
|
||||
@@ -749,12 +749,8 @@ async fn test_remove_member_bcc() -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
alice
|
||||
.assert_warn("No good message identifying the chat found")
|
||||
.await;
|
||||
alice
|
||||
.assert_warn("No good message identifying the chat found")
|
||||
.await;
|
||||
alice.assert_warn("No good message identifying the chat found");
|
||||
alice.assert_warn("No good message identifying the chat found");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -288,8 +288,7 @@ async fn test_get_attachment_filename_apostrophed_invalid() {
|
||||
);
|
||||
let filename = get_attachment_filename(&t, &mail.subparts[1]).unwrap();
|
||||
assert_eq!(filename, Some("somedäüta.html.zip".to_string()));
|
||||
t.assert_warn("apostrophed encoding invalid: somedäüta.html.zip")
|
||||
.await;
|
||||
t.assert_warn("apostrophed encoding invalid: somedäüta.html.zip");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -345,9 +344,7 @@ async fn test_parse_first_addr() {
|
||||
let mimeparser = MimeMessage::from_bytes(&context.ctx, &raw[..]).await;
|
||||
|
||||
assert!(mimeparser.is_err());
|
||||
context
|
||||
.assert_warn("Invalid address found: must contain a '@' symbol")
|
||||
.await;
|
||||
context.assert_warn("Invalid address found: must contain a '@' symbol");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -2034,7 +2031,7 @@ async fn test_multiple_autocrypt_hdrs() -> Result<()> {
|
||||
.msg_ids[0];
|
||||
let msg = Message::load_from_db(bob, msg_id).await?;
|
||||
assert!(msg.get_showpadlock());
|
||||
bob.assert_warn("Unknown Autocrypt attribute found").await;
|
||||
bob.assert_warn("Unknown Autocrypt attribute found");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -89,14 +89,7 @@ async fn test_shared_secret_decryption_ex(
|
||||
get_highest_msg_id(recipient_ctx).await,
|
||||
"receive_imf() must not add any message. Otherwise, Bob may send something about an error to the attacker, leaking that he knows the secret"
|
||||
);
|
||||
let EventType::Warning(warning) = recipient_ctx
|
||||
.evtracker
|
||||
.get_matching(|ev| matches!(ev, EventType::Warning(_)))
|
||||
.await
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
assert!(warning.contains(error_pattern), "Wrong warning: {warning}");
|
||||
recipient_ctx.assert_warn(error_pattern);
|
||||
} else {
|
||||
let msg = recipient_ctx.get_last_msg().await;
|
||||
assert_eq!(&[msg.id], rcvd.msg_ids.as_slice());
|
||||
@@ -142,8 +135,6 @@ async fn test_broadcast_security_attacker_signature() -> Result<()> {
|
||||
Some("This sender is not allowed to encrypt with this secret key"),
|
||||
)
|
||||
.await?;
|
||||
bob.assert_warn("This sender is not allowed to encrypt with this secret key")
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -167,8 +158,6 @@ async fn test_broadcast_security_no_signature() -> Result<()> {
|
||||
Some("Unsigned message is not allowed to be encrypted with this shared secret"),
|
||||
)
|
||||
.await?;
|
||||
bob.assert_warn("Unsigned message is not allowed to be encrypted with this shared secret")
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -218,8 +207,6 @@ async fn test_qr_code_security() -> Result<()> {
|
||||
Some("This sender is not allowed to encrypt with this secret key"),
|
||||
)
|
||||
.await?;
|
||||
bob.assert_warn("This sender is not allowed to encrypt with this secret key")
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -263,8 +250,6 @@ async fn test_unknown_secret() -> Result<()> {
|
||||
Some("Could not find symmetric secret for session key"),
|
||||
)
|
||||
.await?;
|
||||
bob.assert_warn("Could not find symmetric secret for session key")
|
||||
.await;
|
||||
bob.assert_warn("unencrypted message").await;
|
||||
bob.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+1
-1
@@ -541,7 +541,7 @@ mod tests {
|
||||
None
|
||||
);
|
||||
|
||||
t.assert_warn("os error 2").await;
|
||||
t.assert_warn("os error 2");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ async fn test_can_communicate() {
|
||||
|
||||
bob.recv_msg_trash(&alice.pop_sent_msg().await).await;
|
||||
loop {
|
||||
let event = bob.evtracker.recv().await.unwrap();
|
||||
let event = bob.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeAdvertisementReceived { msg_id } = event.typ {
|
||||
assert!(msg_id == bob_webxdc.id);
|
||||
break;
|
||||
@@ -91,7 +91,7 @@ async fn test_can_communicate() {
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
let event = bob.evtracker.recv().await.unwrap();
|
||||
let event = bob.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeData { data, .. } = event.typ {
|
||||
if data == "alice -> bob".as_bytes() {
|
||||
break;
|
||||
@@ -112,7 +112,7 @@ async fn test_can_communicate() {
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
let event = alice.evtracker.recv().await.unwrap();
|
||||
let event = alice.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeData { data, .. } = event.typ {
|
||||
if data == "bob -> alice".as_bytes() {
|
||||
break;
|
||||
@@ -154,7 +154,7 @@ async fn test_can_communicate() {
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
let event = alice.evtracker.recv().await.unwrap();
|
||||
let event = alice.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeData { data, .. } = event.typ {
|
||||
if data == "bob -> alice 2".as_bytes() {
|
||||
break;
|
||||
@@ -207,10 +207,11 @@ async fn test_duplicated_out_of_order_advertisement() -> Result<()> {
|
||||
bob_webxdc.chat_id.accept(bob).await?;
|
||||
|
||||
bob.recv_msg_trash(&advertisement).await;
|
||||
bob.assert_warn("Cannot add iroh peer");
|
||||
loop {
|
||||
let event = bob.evtracker.recv().await.unwrap();
|
||||
let event = bob.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeAdvertisementReceived { msg_id } = event.typ {
|
||||
assert!(msg_id == bob_webxdc.id);
|
||||
assert_eq!(msg_id, bob_webxdc.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -224,15 +225,12 @@ async fn test_duplicated_out_of_order_advertisement() -> Result<()> {
|
||||
vec![
|
||||
alice
|
||||
.get_or_try_init_peer_channel()
|
||||
.await
|
||||
.unwrap()
|
||||
.await?
|
||||
.get_node_addr()
|
||||
.await
|
||||
.unwrap()
|
||||
.await?
|
||||
.node_id
|
||||
]
|
||||
);
|
||||
bob.assert_warn("Cannot add iroh peer").await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -319,7 +317,7 @@ async fn test_can_reconnect() {
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
let event = bob.evtracker.recv().await.unwrap();
|
||||
let event = bob.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeData { data, .. } = event.typ {
|
||||
if data == "alice -> bob".as_bytes() {
|
||||
break;
|
||||
@@ -378,7 +376,7 @@ async fn test_can_reconnect() {
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
let event = alice.evtracker.recv().await.unwrap();
|
||||
let event = alice.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeData { data, .. } = event.typ {
|
||||
if data == "bob -> alice".as_bytes() {
|
||||
break;
|
||||
@@ -503,10 +501,10 @@ async fn test_webxdc_resend() {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
}
|
||||
};
|
||||
fiona.assert_warn("Missing key for bob@example.net").await;
|
||||
fiona.assert_warn("Missing key for bob@example.net");
|
||||
let realtime_receive_loop = async {
|
||||
loop {
|
||||
let event = fiona.evtracker.recv().await.unwrap();
|
||||
let event = fiona.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeData { data, .. } = event.typ {
|
||||
if data == b"alice -> bob & fiona" {
|
||||
break;
|
||||
@@ -574,7 +572,7 @@ async fn connect_alice_bob(
|
||||
|
||||
eprintln!("Waiting for ephemeral message");
|
||||
loop {
|
||||
let event = bob.evtracker.recv().await.unwrap();
|
||||
let event = bob.get_evtracker().recv().await.unwrap();
|
||||
if let EventType::WebxdcRealtimeData { data, .. } = event.typ {
|
||||
if data == b"alice -> bob" {
|
||||
break;
|
||||
|
||||
@@ -358,7 +358,7 @@ mod tests {
|
||||
.await
|
||||
.is_ok()
|
||||
);
|
||||
alice.assert_warn("Message is not pinnable").await;
|
||||
alice.assert_warn("Message is not pinnable");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+2
-4
@@ -584,10 +584,8 @@ async fn test_withdraw_joinbroadcast() -> Result<()> {
|
||||
assert_eq!(bob_chat.is_self_in_chat(bob).await?, true);
|
||||
assert_eq!(get_chat_contacts(alice, chat_id).await?.len(), 1);
|
||||
|
||||
alice
|
||||
.assert_warn("Could not find symmetric secret for session key")
|
||||
.await;
|
||||
alice.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("Could not find symmetric secret for session key");
|
||||
alice.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -156,10 +156,10 @@ mod tests {
|
||||
};
|
||||
assert!(!t.quota_needs_update(0, TIMEOUT).await);
|
||||
|
||||
t.evtracker.clear_events();
|
||||
t.get_evtracker().clear_events();
|
||||
t.set_primary_self_addr("new@addr").await?;
|
||||
assert!(t.quota.read().await.is_empty());
|
||||
t.evtracker
|
||||
t.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::ConnectivityChanged))
|
||||
.await;
|
||||
assert!(t.quota_needs_update(0, TIMEOUT).await);
|
||||
|
||||
+5
-5
@@ -733,7 +733,7 @@ Content-Disposition: reaction\n\
|
||||
expected_contact_id: ContactId,
|
||||
) -> Result<()> {
|
||||
let event = t
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
@@ -764,7 +764,7 @@ Content-Disposition: reaction\n\
|
||||
expected_reaction: &str,
|
||||
) -> Result<()> {
|
||||
let event = t
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
// Check for absence of `IncomingMsg` events -- it appeared that it's quite easy to make
|
||||
// bugs when `IncomingMsg` is issued for reactions.
|
||||
.get_matching(|evt| {
|
||||
@@ -794,7 +794,7 @@ Content-Disposition: reaction\n\
|
||||
/// Checks that no unwanted events remain after expecting "wanted" reaction events.
|
||||
async fn expect_no_unwanted_events(t: &TestContext) {
|
||||
let ev = t
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching_opt(t, |evt| {
|
||||
matches!(
|
||||
evt,
|
||||
@@ -849,7 +849,7 @@ Content-Disposition: reaction\n\
|
||||
|
||||
bob_msg.chat_id.accept(&bob).await?;
|
||||
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
send_reaction(&bob, bob_msg.id, "👍").await.unwrap();
|
||||
expect_reactions_changed_event(&bob, bob_msg.chat_id, bob_msg.id, ContactId::SELF).await?;
|
||||
expect_no_unwanted_events(&bob).await;
|
||||
@@ -1039,7 +1039,7 @@ Content-Disposition: reaction\n\
|
||||
SystemTime::shift(Duration::from_secs(10));
|
||||
send_reaction(&alice, alice_msg1.sender_msg_id, "🍿").await?;
|
||||
let alice_send_reaction = alice.pop_sent_msg().await;
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
bob.recv_msg_opt(&alice_send_reaction).await;
|
||||
expect_no_unwanted_events(&bob).await;
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ async fn test_mdn_and_alias() -> Result<()> {
|
||||
|
||||
let chats = Chatlist::try_load(&alice, 0, None, None).await?;
|
||||
assert_eq!(chats.len(), 1);
|
||||
alice.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ async fn test_no_from() {
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
t.assert_warn("No from in message").await;
|
||||
t.assert_warn("No from in message");
|
||||
|
||||
// Check that tombstone MsgId is returned.
|
||||
assert_eq!(received.msg_ids.len(), 1);
|
||||
@@ -358,7 +358,7 @@ async fn test_no_message_id_header() {
|
||||
// Check that the message is not shown to the user:
|
||||
assert!(chats.is_empty());
|
||||
|
||||
t.assert_warn("No from in message").await;
|
||||
t.assert_warn("No from in message");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -492,8 +492,8 @@ async fn test_parse_ndn_tiscali() {
|
||||
Some(msg),
|
||||
)
|
||||
.await;
|
||||
t.assert_warn("DSN without action").await;
|
||||
t.assert_warn(msg).await;
|
||||
t.assert_warn("DSN without action");
|
||||
t.assert_warn(msg);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -507,7 +507,7 @@ async fn test_parse_ndn_testrun() {
|
||||
Some(msg),
|
||||
)
|
||||
.await;
|
||||
t.assert_warn(msg).await;
|
||||
t.assert_warn(msg);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -521,7 +521,7 @@ async fn test_parse_ndn_yahoo() {
|
||||
Some(msg),
|
||||
)
|
||||
.await;
|
||||
t.assert_warn(msg).await;
|
||||
t.assert_warn(msg);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -535,7 +535,7 @@ async fn test_parse_ndn_gmail() {
|
||||
Some("Delivery Status Notification (Failure) – ** Die Adresse wurde nicht gefunden **\n\nIhre Nachricht wurde nicht an assidhfaaspocwaeofi@gmail.com zugestellt, weil die Adresse nicht gefunden wurde oder keine E-Mails empfangen kann.\n\nHier erfahren Sie mehr: https://support.google.com/mail/?p=NoSuchUser\n\nAntwort:\n\n550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient\'s email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/?p=NoSuchUser i18sor6261697wrs.38 - gsmtp"),
|
||||
)
|
||||
.await;
|
||||
t.assert_warn(msg).await;
|
||||
t.assert_warn(msg);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -549,7 +549,7 @@ async fn test_parse_ndn_gmx() {
|
||||
Some(msg),
|
||||
)
|
||||
.await;
|
||||
t.assert_warn(msg).await;
|
||||
t.assert_warn(msg);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -563,7 +563,7 @@ async fn test_parse_ndn_posteo() {
|
||||
Some(msg),
|
||||
)
|
||||
.await;
|
||||
t.assert_warn(msg).await;
|
||||
t.assert_warn(msg);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -577,7 +577,7 @@ async fn test_parse_ndn_testrun_2() {
|
||||
Some(msg),
|
||||
)
|
||||
.await;
|
||||
t.assert_warn(msg).await;
|
||||
t.assert_warn(msg);
|
||||
}
|
||||
|
||||
/// Tests that text part is not squashed into OpenPGP attachment.
|
||||
@@ -592,8 +592,8 @@ async fn test_parse_ndn_with_attachment() {
|
||||
Some(msg),
|
||||
)
|
||||
.await;
|
||||
t.assert_warn("Missing attachment").await;
|
||||
t.assert_warn(msg).await;
|
||||
t.assert_warn("Missing attachment");
|
||||
t.assert_warn(msg);
|
||||
}
|
||||
|
||||
/// Test that DSN is not treated as NDN if Action: is not "failed"
|
||||
@@ -678,7 +678,7 @@ async fn test_resend_after_ndn() -> Result<()> {
|
||||
)
|
||||
.await;
|
||||
chat::resend_msgs(&t, &[msg_id]).await?;
|
||||
t.assert_warn("Undelivered Mail Returned to Sender").await;
|
||||
t.assert_warn("Undelivered Mail Returned to Sender");
|
||||
let msg = Message::load_from_db(&t, msg_id).await?;
|
||||
assert_eq!(msg.state, MessageState::OutPending);
|
||||
assert_eq!(msg.error(), None);
|
||||
@@ -741,8 +741,7 @@ async fn test_parse_ndn_group_msg() -> Result<()> {
|
||||
ChatItem::Message { msg_id } if msg_id == msg.id
|
||||
));
|
||||
|
||||
t.assert_warn("Delivery Status Notification (Failure)")
|
||||
.await;
|
||||
t.assert_warn("Delivery Status Notification (Failure)");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -794,8 +793,8 @@ async fn test_concat_multiple_ndns() -> Result<()> {
|
||||
|
||||
assert_eq!(msg.error(), Some([err.clone(), err.clone()].join("\n\n")));
|
||||
|
||||
t.assert_warn(&err).await;
|
||||
t.assert_warn(&err).await;
|
||||
t.assert_warn(&err);
|
||||
t.assert_warn(&err);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -818,7 +817,7 @@ async fn test_html_only_mail() {
|
||||
msg.text,
|
||||
"Guten Abend,\n\nLots of text\n\ntext with Umlaut ä...\n\nMfG\n\n--------------------------------------\n\n[Camping ](https://example.com/)\n\nsomeaddress\n\nsometown"
|
||||
);
|
||||
t.assert_warn("Missing attachment").await;
|
||||
t.assert_warn("Missing attachment");
|
||||
}
|
||||
|
||||
static GH_MAILINGLIST: &[u8] =
|
||||
@@ -1021,7 +1020,7 @@ async fn test_block_mailing_list() {
|
||||
t.allow_unencrypted().await.unwrap();
|
||||
|
||||
receive_imf(&t.ctx, DC_MAILINGLIST, false).await.unwrap();
|
||||
t.evtracker.wait_next_incoming_message().await;
|
||||
t.get_evtracker().wait_next_incoming_message().await;
|
||||
let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap();
|
||||
assert_eq!(chats.len(), 1);
|
||||
let chat_id = chats.get_chat_id(0).unwrap();
|
||||
@@ -1037,7 +1036,7 @@ async fn test_block_mailing_list() {
|
||||
receive_imf(&t.ctx, DC_MAILINGLIST2, false).await.unwrap();
|
||||
|
||||
// Check that no notification is displayed for blocked mailing list message.
|
||||
while let Ok(event) = t.evtracker.try_recv() {
|
||||
while let Ok(event) = t.get_evtracker().try_recv() {
|
||||
assert!(!matches!(event.typ, EventType::IncomingMsg { .. }));
|
||||
}
|
||||
|
||||
@@ -1695,7 +1694,7 @@ async fn test_save_mime_headers_off() -> anyhow::Result<()> {
|
||||
assert_eq!(msg.get_text(), "hi!");
|
||||
let html = msg.id.get_html(&bob).await?;
|
||||
assert!(html.is_none());
|
||||
bob.assert_warn("get_html: no mime").await;
|
||||
bob.assert_warn("get_html: no mime");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2664,16 +2663,12 @@ Second thread."#;
|
||||
chat::add_contact_to_chat(&alice, alice_first_msg.chat_id, alice_fiona_contact_id).await?;
|
||||
let alice_first_invite = alice.pop_sent_msg().await;
|
||||
let fiona_first_invite = fiona.recv_msg(&alice_first_invite).await;
|
||||
fiona
|
||||
.assert_warn(r#"Added "fiona@example.net" has no gossiped key."#)
|
||||
.await;
|
||||
fiona.assert_warn(r#"Added "fiona@example.net" has no gossiped key."#);
|
||||
|
||||
chat::add_contact_to_chat(&alice, alice_second_msg.chat_id, alice_fiona_contact_id).await?;
|
||||
let alice_second_invite = alice.pop_sent_msg().await;
|
||||
let fiona_second_invite = fiona.recv_msg(&alice_second_invite).await;
|
||||
fiona
|
||||
.assert_warn(r#"Added "fiona@example.net" has no gossiped key."#)
|
||||
.await;
|
||||
fiona.assert_warn(r#"Added "fiona@example.net" has no gossiped key."#);
|
||||
|
||||
// Fiona was added to two separate chats and should see two separate chats, even though they
|
||||
// don't have different group IDs to distinguish them.
|
||||
@@ -2791,7 +2786,7 @@ async fn test_incoming_contact_request() -> Result<()> {
|
||||
assert!(chat.is_contact_request());
|
||||
|
||||
let event = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::IncomingMsg { .. }))
|
||||
.await;
|
||||
match event {
|
||||
@@ -2810,7 +2805,7 @@ async fn test_incoming_contact_request() -> Result<()> {
|
||||
// There are only `MsgsChanged` events for each message,
|
||||
// but no `IncomingMsg` before or after.
|
||||
let event = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
@@ -2936,7 +2931,7 @@ async fn test_invalid_to_address() -> Result<()> {
|
||||
|
||||
// receive_imf should not fail on this mail with invalid To: field
|
||||
receive_imf(&alice, mime, false).await?;
|
||||
alice.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -3389,8 +3384,8 @@ async fn test_outgoing_undecryptable() -> Result<()> {
|
||||
// The device message mustn't be added too frequently.
|
||||
assert_eq!(alice.get_last_msg_in(dev_chat_id).await.id, dev_msg.id);
|
||||
|
||||
alice.assert_warn("decryption failed").await;
|
||||
alice.assert_warn("decryption failed").await;
|
||||
alice.assert_warn("decryption failed");
|
||||
alice.assert_warn("decryption failed");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -3516,9 +3511,8 @@ async fn test_forged_from_and_no_valid_signatures() -> Result<()> {
|
||||
let raw = String::from_utf8(raw.to_vec())?.replace("alice@example.org", "clarice@example.org");
|
||||
let received_msg = receive_imf(t, raw.as_bytes(), false).await?.unwrap();
|
||||
assert!(received_msg.chat_id.is_trash());
|
||||
t.assert_warn("From header in encrypted part doesn't match the outer one")
|
||||
.await;
|
||||
t.assert_warn("From header is forged").await;
|
||||
t.assert_warn("From header in encrypted part doesn't match the outer one");
|
||||
t.assert_warn("From header is forged");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -4535,7 +4529,7 @@ async fn test_outgoing_msg_forgery() -> Result<()> {
|
||||
bob.configure_addr("bob@example.net").await;
|
||||
imex(bob, ImexMode::ImportSelfKeys, export_dir.path(), None).await?;
|
||||
assert_eq!(crate::key::load_self_secret_keyring(bob).await?.len(), 1);
|
||||
bob.assert_warn("Failed to import secret key").await;
|
||||
bob.assert_warn("Failed to import secret key");
|
||||
let malice = &tcm.unconfigured().await;
|
||||
malice.configure_addr(alice_addr).await;
|
||||
|
||||
@@ -4548,7 +4542,7 @@ async fn test_outgoing_msg_forgery() -> Result<()> {
|
||||
let sent_msg = malice.send_text(malice_chat_id, "hi from malice").await;
|
||||
let msg = alice.recv_msg_opt(&sent_msg).await;
|
||||
assert!(msg.is_none());
|
||||
alice.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -4635,8 +4629,8 @@ async fn test_protected_group_add_remove_member_missing_key() -> Result<()> {
|
||||
msg.get_text(),
|
||||
stock_str::msg_del_member_local(alice, alice_bob_id, ContactId::SELF).await
|
||||
);
|
||||
alice.assert_warn("Missing key for bob@example.net").await;
|
||||
alice.assert_warn("Missing key for bob@example.net").await;
|
||||
alice.assert_warn("Missing key for bob@example.net");
|
||||
alice.assert_warn("Missing key for bob@example.net");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -4694,7 +4688,7 @@ Chat-Group-Member-Removed: charlie@example.com",
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
bob.assert_warn("unencrypted message").await;
|
||||
bob.assert_warn("unencrypted message");
|
||||
assert_eq!(get_chat_cnt(bob).await?, chat_cnt);
|
||||
Ok(())
|
||||
}
|
||||
@@ -4786,12 +4780,8 @@ async fn test_forged_from() -> Result<()> {
|
||||
// We take the address from the encrypted part
|
||||
// and send replies there.
|
||||
assert_eq!(contact.get_addr(), "bob@example.net");
|
||||
alice
|
||||
.assert_warn(r#"Autocrypt header address "bob@example.net" is not "notbob@example.net""#)
|
||||
.await;
|
||||
alice
|
||||
.assert_warn("From header in encrypted part doesn't match the outer one")
|
||||
.await;
|
||||
alice.assert_warn(r#"Autocrypt header address "bob@example.net" is not "notbob@example.net""#);
|
||||
alice.assert_warn("From header in encrypted part doesn't match the outer one");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -4938,7 +4928,7 @@ async fn test_receive_vcard() -> Result<()> {
|
||||
assert_eq!(&parsed[0].addr, "claire@example.org");
|
||||
} else {
|
||||
assert_eq!(&parsed[0].addr, "");
|
||||
alice.assert_warn("Not a valid DeltaChat vCard").await;
|
||||
alice.assert_warn("Not a valid DeltaChat vCard");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -5267,9 +5257,7 @@ async fn test_recv_outgoing_msg_no_intended_recipient_fingerprint() -> Result<()
|
||||
// Alice does not have Bob's key.
|
||||
// Message is encrypted, but is received in ad hoc group with Bob's address.
|
||||
let rcvd_msg = receive_imf(alice, payload, false).await?.unwrap();
|
||||
alice
|
||||
.assert_warn("No key-contact looked up. Downgrading to AdHocGroup.")
|
||||
.await;
|
||||
alice.assert_warn("No key-contact looked up. Downgrading to AdHocGroup.");
|
||||
let msg_alice = Message::load_from_db(alice, rcvd_msg.msg_ids[0]).await?;
|
||||
|
||||
assert!(msg_alice.get_showpadlock());
|
||||
@@ -5380,7 +5368,7 @@ async fn test_no_address_contact_added_into_group() -> Result<()> {
|
||||
// Unencrypted message should not even be assigned to encrypted chat.
|
||||
assert_ne!(msg.chat_id, alice_chat_id);
|
||||
|
||||
alice.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5414,7 +5402,7 @@ async fn test_outgoing_plaintext_two_member_group() -> Result<()> {
|
||||
|
||||
let chat = Chat::load_from_db(alice, msg.chat_id).await?;
|
||||
assert_eq!(chat.typ, Chattype::Group);
|
||||
alice.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5653,9 +5641,7 @@ async fn test_small_unencrypted_group() -> Result<()> {
|
||||
let alice_bob_id = alice.add_or_lookup_address_contact_id(bob).await;
|
||||
add_contact_to_chat(alice, alice_chat_id, alice_bob_id).await?;
|
||||
send_text_msg(alice, alice_chat_id, "Hello!".to_string()).await?;
|
||||
alice
|
||||
.assert_warn("No good message identifying the chat found")
|
||||
.await;
|
||||
alice.assert_warn("No good message identifying the chat found");
|
||||
|
||||
let sent_msg = alice.pop_sent_msg().await;
|
||||
let bob_chat_id = bob.recv_msg(&sent_msg).await.chat_id;
|
||||
|
||||
@@ -35,7 +35,7 @@ async fn test_setup_contact_basic() {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_setup_contact_wrong_alice_gossip() {
|
||||
let (alice, _) = test_setup_contact_ex(SetupContactCase::WrongAliceGossip).await;
|
||||
alice.assert_warn("No self addr+pubkey gossip found").await;
|
||||
alice.assert_warn("No self addr+pubkey gossip found");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -163,7 +163,7 @@ async fn test_setup_contact_ex(case: SetupContactCase) -> (TestContext, TestCont
|
||||
|
||||
// Check Bob emitted the JoinerProgress event.
|
||||
let event = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::SecurejoinJoinerProgress { .. }))
|
||||
.await;
|
||||
match event {
|
||||
@@ -309,8 +309,8 @@ async fn test_setup_contact_bad_qr() {
|
||||
let bob = TestContext::new_bob().await;
|
||||
let ret = join_securejoin(&bob.ctx, "not a qr code").await;
|
||||
assert!(ret.is_err());
|
||||
bob.assert_warn("Unsupported QR type").await;
|
||||
bob.assert_error("QR process failed").await;
|
||||
bob.assert_warn("Unsupported QR type");
|
||||
bob.assert_error("QR process failed");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -331,7 +331,7 @@ async fn test_setup_contact_bob_knows_alice() -> Result<()> {
|
||||
|
||||
// Check Bob emitted the JoinerProgress event.
|
||||
let event = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::SecurejoinJoinerProgress { .. }))
|
||||
.await;
|
||||
match event {
|
||||
@@ -370,7 +370,7 @@ async fn test_setup_contact_bob_knows_alice() -> Result<()> {
|
||||
|
||||
// Check Alice signalled success via the SecurejoinInviterProgress event.
|
||||
let event = alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
@@ -535,7 +535,7 @@ async fn test_secure_join_group_ex(v3: bool, remove_invite: bool) -> Result<()>
|
||||
|
||||
// Check Bob emitted the JoinerProgress event.
|
||||
let event = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::SecurejoinJoinerProgress { .. }))
|
||||
.await;
|
||||
match event {
|
||||
@@ -573,7 +573,7 @@ async fn test_secure_join_group_ex(v3: bool, remove_invite: bool) -> Result<()>
|
||||
|
||||
// Check Alice signalled success via the SecurejoinInviterProgress event.
|
||||
let event = alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| {
|
||||
matches!(
|
||||
evt,
|
||||
@@ -795,7 +795,7 @@ First thread."#;
|
||||
let chat_id = msg.chat_id;
|
||||
|
||||
assert!(get_securejoin_qr(&alice, Some(chat_id)).await.is_err());
|
||||
alice.assert_error("Can't generate QR code").await;
|
||||
alice.assert_error("Can't generate QR code");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -988,11 +988,9 @@ async fn test_parallel_setup_contact(bob_deletes_fiona_contact: bool) -> Result<
|
||||
let bob_alice_contact = Contact::get_by_id(bob, bob_alice_contact_id).await.unwrap();
|
||||
assert_eq!(bob_alice_contact.is_verified(bob).await.unwrap(), true);
|
||||
|
||||
bob.assert_warn("Message does not match expected fingerprint")
|
||||
.await;
|
||||
bob.assert_warn("Message does not match expected fingerprint");
|
||||
if bob_deletes_fiona_contact {
|
||||
bob.assert_warn("Message does not match expected fingerprint")
|
||||
.await;
|
||||
bob.assert_warn("Message does not match expected fingerprint");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1025,7 +1023,7 @@ async fn test_wrong_auth_token() -> Result<()> {
|
||||
|
||||
let alice_bob_contact = alice.add_or_lookup_contact(bob).await;
|
||||
assert!(!alice_bob_contact.is_verified(alice).await?);
|
||||
alice.assert_warn("invalid auth code").await;
|
||||
alice.assert_warn("invalid auth code");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1228,7 +1226,7 @@ async fn test_rejoin_group() -> Result<()> {
|
||||
// Bob gets two progress events.
|
||||
for expected_progress in [400, 1000] {
|
||||
let EventType::SecurejoinJoinerProgress { progress, .. } = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::SecurejoinJoinerProgress { .. }))
|
||||
.await
|
||||
else {
|
||||
@@ -1242,7 +1240,7 @@ async fn test_rejoin_group() -> Result<()> {
|
||||
|
||||
// Bob immediately receives progress 1000 event.
|
||||
let EventType::SecurejoinJoinerProgress { progress, .. } = bob
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::SecurejoinJoinerProgress { .. }))
|
||||
.await
|
||||
else {
|
||||
@@ -1389,9 +1387,8 @@ async fn test_qr_no_implicit_inviter_addition() -> Result<()> {
|
||||
let charlie_chat_contacts = chat::get_chat_contacts(charlie, charlie_chat_id).await?;
|
||||
assert_eq!(charlie_chat_contacts.len(), 2);
|
||||
|
||||
bob.assert_error("self not in group").await;
|
||||
bob.assert_warn("the account is not part of the group/broadcast")
|
||||
.await;
|
||||
bob.assert_error("self not in group");
|
||||
bob.assert_warn("the account is not part of the group/broadcast");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1604,9 +1601,8 @@ async fn test_auth_token_is_synchronized() -> Result<()> {
|
||||
.unwrap();
|
||||
assert_eq!(auth_count, 2);
|
||||
|
||||
bob.assert_warn("Could not find symmetric secret for session key")
|
||||
.await;
|
||||
bob.assert_warn("unencrypted message").await;
|
||||
bob.assert_warn("Could not find symmetric secret for session key");
|
||||
bob.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ async fn test_housekeeping_db_closed() {
|
||||
}
|
||||
}
|
||||
|
||||
t.assert_warns_or_errors(&["no SQL connection"]).await;
|
||||
t.assert_warns_or_errors(&["no SQL connection"]);
|
||||
}
|
||||
|
||||
/// Regression test for a bug where housekeeping deleted drafts since their
|
||||
@@ -178,7 +178,7 @@ async fn test_db_reopen() -> Result<()> {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_migration_flags() -> Result<()> {
|
||||
let t = TestContext::new().await;
|
||||
t.evtracker.get_info_contains("Opened database").await;
|
||||
t.get_evtracker().get_info_contains("Opened database").await;
|
||||
|
||||
// as migrations::run() was already executed on context creation,
|
||||
// another call should not result in any action needed.
|
||||
@@ -190,7 +190,7 @@ async fn test_migration_flags() -> Result<()> {
|
||||
|
||||
loop {
|
||||
let evt = t
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::Info(_)))
|
||||
.await;
|
||||
match evt {
|
||||
|
||||
+14
-14
@@ -254,7 +254,7 @@ async fn test_message_stats() -> Result<()> {
|
||||
expected.get_mut(&Chattype::Single).unwrap().verified += 1;
|
||||
|
||||
check_stats(&send_and_read_stats(alice).await, &expected);
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -319,12 +319,12 @@ async fn test_stats_securejoin_sources() -> Result<()> {
|
||||
join_securejoin_with_ux_info(alice, &qr, Some(SecurejoinSource::InternalLink), None).await?;
|
||||
expected.internal_link += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, Some(SecurejoinSource::ImageLoaded), None).await?;
|
||||
expected.image_loaded += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, Some(SecurejoinSource::Scan), None).await?;
|
||||
expected.scan += 1;
|
||||
@@ -372,27 +372,27 @@ async fn test_stats_securejoin_uipaths() -> Result<()> {
|
||||
join_securejoin(alice, &qr).await?;
|
||||
expected.other += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
|
||||
join_securejoin(alice, &qr).await?;
|
||||
expected.other += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, None, Some(SecurejoinUiPath::NewContact)).await?;
|
||||
expected.new_contact += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, None, Some(SecurejoinUiPath::NewContact)).await?;
|
||||
expected.new_contact += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, None, Some(SecurejoinUiPath::QrIcon)).await?;
|
||||
expected.qr_icon += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -468,12 +468,12 @@ async fn test_stats_securejoin_invites() -> Result<()> {
|
||||
});
|
||||
check_stats(alice, &expected).await;
|
||||
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
bob.assert_warn("missing key").await;
|
||||
bob.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
alice.assert_warn("Missing securejoin source");
|
||||
bob.assert_warn("missing key");
|
||||
bob.assert_warn("unencrypted message");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+1
-1
@@ -490,6 +490,6 @@ mod tests {
|
||||
msg.get_summary_text_without_prefix(ctx).await,
|
||||
"📎 foo.bar \u{2013} bla bla"
|
||||
); // skipping prefix used for reactions summaries
|
||||
d.assert_warn("Not a valid DeltaChat vCard").await;
|
||||
d.assert_warn("Not a valid DeltaChat vCard");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -695,8 +695,8 @@ mod tests {
|
||||
bob.recv_msg_trash(&sent_msg).await;
|
||||
assert!(!token::exists(&bob, token::Namespace::Auth, "testtoken").await?);
|
||||
|
||||
bob.assert_warn("missing key").await;
|
||||
bob.assert_warn("unencrypted message").await;
|
||||
bob.assert_warn("missing key");
|
||||
bob.assert_warn("unencrypted message");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+37
-61
@@ -12,7 +12,6 @@ use std::sync::{Arc, LazyLock};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Result;
|
||||
use async_channel::{self as channel, Receiver, Sender};
|
||||
use chat::ChatItem;
|
||||
use deltachat_contact_tools::{ContactAddress, EmailAddress};
|
||||
use nu_ansi_term::Color;
|
||||
@@ -443,8 +442,6 @@ pub struct TestContext {
|
||||
/// Temporary directory used to store SQLite database.
|
||||
pub dir: TempDir,
|
||||
|
||||
pub evtracker: EventTracker,
|
||||
|
||||
log_sink: LogSink,
|
||||
}
|
||||
|
||||
@@ -522,13 +519,12 @@ impl TestContext {
|
||||
context_names.insert(id, name);
|
||||
}
|
||||
let events = Events::new();
|
||||
let evtracker_receiver = events.get_emitter();
|
||||
let emitter = events.get_emitter();
|
||||
let ctx = Context::new(&dbfile, id, events, StockStrings::new())
|
||||
.await
|
||||
.expect("failed to create context");
|
||||
|
||||
let log_sink = LogSink::new();
|
||||
log_sink.subscribe(ctx.get_event_emitter());
|
||||
let log_sink = LogSink::new(emitter);
|
||||
|
||||
ctx.set_config(Config::SkipStartMessages, Some("1"))
|
||||
.await
|
||||
@@ -536,12 +532,7 @@ impl TestContext {
|
||||
ctx.set_config(Config::BccSelf, Some("1")).await.unwrap();
|
||||
ctx.set_config(Config::SyncMsgs, Some("0")).await.unwrap();
|
||||
|
||||
Self {
|
||||
ctx,
|
||||
dir,
|
||||
evtracker: EventTracker::new(evtracker_receiver),
|
||||
log_sink,
|
||||
}
|
||||
Self { ctx, dir, log_sink }
|
||||
}
|
||||
|
||||
/// Sets a name for this [`TestContext`] if one isn't yet set.
|
||||
@@ -1175,15 +1166,15 @@ ORDER BY id"
|
||||
/// Asserts a warning containing `pat` should be logged.
|
||||
///
|
||||
/// Delegates to [`InnerLogSink::assert_warn`].
|
||||
pub async fn assert_warn(&self, pat: &str) {
|
||||
self.log_sink.assert_warn(pat).await
|
||||
pub fn assert_warn(&self, pat: &str) {
|
||||
self.log_sink.assert_warn(pat)
|
||||
}
|
||||
|
||||
/// Asserts an error containing `pat` should be logged.
|
||||
///
|
||||
/// Delegates to [`InnerLogSink::assert_error`].
|
||||
pub async fn assert_error(&self, pat: &str) {
|
||||
self.log_sink.assert_error(pat).await
|
||||
pub fn assert_error(&self, pat: &str) {
|
||||
self.log_sink.assert_error(pat)
|
||||
}
|
||||
|
||||
/// Asserts that a list of errors and/or warnings has been logged,
|
||||
@@ -1195,8 +1186,13 @@ ORDER BY id"
|
||||
/// the first one takes precedence.
|
||||
///
|
||||
/// Delegates to [`InnerLogSink::assert_warns_or_errors`].
|
||||
pub async fn assert_warns_or_errors(&self, pats: &[&str]) {
|
||||
self.log_sink.assert_warns_or_errors(pats).await
|
||||
pub fn assert_warns_or_errors(&self, pats: &[&str]) {
|
||||
self.log_sink.assert_warns_or_errors(pats)
|
||||
}
|
||||
|
||||
/// Returns a reference to the event tracker.
|
||||
pub fn get_evtracker(&self) -> &EventTracker {
|
||||
&self.log_sink.evtracker
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1311,13 +1307,13 @@ impl Drop for TestContext {
|
||||
/// A receiver of [`Event`]s which will log the events to the captured test stdout.
|
||||
///
|
||||
/// Panics on [`drop`][`Drop::drop`], if an unexpected warning or error was received.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LogSink(Arc<InnerLogSink>);
|
||||
|
||||
impl LogSink {
|
||||
/// Creates a new [`LogSink`] and returns the attached event sink.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
pub fn new(event_emitter: EventEmitter) -> Self {
|
||||
Self(Arc::new(InnerLogSink::new(event_emitter)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1331,54 +1327,33 @@ impl Deref for LogSink {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InnerLogSink {
|
||||
/// Log events receiver.
|
||||
events: Receiver<Event>,
|
||||
|
||||
/// Sender side of the log receiver.
|
||||
///
|
||||
/// It is cloned when log sink is subscribed
|
||||
/// to new event emitter.
|
||||
sender: Sender<Event>,
|
||||
pub(crate) evtracker: EventTracker,
|
||||
}
|
||||
|
||||
impl Default for InnerLogSink {
|
||||
fn default() -> Self {
|
||||
let (tx, rx) = channel::unbounded();
|
||||
impl InnerLogSink {
|
||||
fn new(event_emitter: EventEmitter) -> Self {
|
||||
Self {
|
||||
events: rx,
|
||||
sender: tx,
|
||||
evtracker: EventTracker::new(event_emitter),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl InnerLogSink {
|
||||
/// Subscribes this log sink to event emitter.
|
||||
pub fn subscribe(&self, event_emitter: EventEmitter) {
|
||||
let sender = self.sender.clone();
|
||||
task::spawn(async move {
|
||||
while let Some(event) = event_emitter.recv().await {
|
||||
print_event(&event);
|
||||
sender.try_send(event).ok();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async fn assert(&self, is_error: bool, pat: &str) {
|
||||
while let Ok(Ok(event)) =
|
||||
tokio::time::timeout(Duration::from_secs(1), self.events.recv()).await
|
||||
{
|
||||
fn assert(&self, is_error: bool, pat: &str) {
|
||||
while let Ok(event) = self.evtracker.try_recv() {
|
||||
if Self::assert_inner(event, is_error, pat) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if is_error {
|
||||
panic!("Expected an error log.")
|
||||
panic!("Expected an error log matching '{pat}'.")
|
||||
} else {
|
||||
panic!("Expected a warning log.")
|
||||
panic!("Expected a warning log matching '{pat}'.")
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_inner(log_event: Event, is_error: bool, pat: &str) -> bool {
|
||||
print_event(&log_event);
|
||||
if let Some(log) = match is_error {
|
||||
false => log_event.typ.get_warn(),
|
||||
true => log_event.typ.get_error(),
|
||||
@@ -1408,11 +1383,11 @@ impl InnerLogSink {
|
||||
///
|
||||
/// Order of `pats` matters: if a log can be matched by multiple patterns,
|
||||
/// the first one takes precedence.
|
||||
pub async fn assert_warns_or_errors(&self, pats: &[&str]) {
|
||||
pub fn assert_warns_or_errors(&self, pats: &[&str]) {
|
||||
let mut hits = BTreeSet::new();
|
||||
'events: while let Ok(Ok(event)) =
|
||||
tokio::time::timeout(Duration::from_secs(1), self.events.recv()).await
|
||||
{
|
||||
'events: while let Ok(event) = self.evtracker.try_recv() {
|
||||
print_event(&event);
|
||||
|
||||
let Some(log) = event.typ.get_warn().or_else(|| event.typ.get_error()) else {
|
||||
continue 'events;
|
||||
};
|
||||
@@ -1439,13 +1414,13 @@ impl InnerLogSink {
|
||||
}
|
||||
|
||||
/// Asserts that a warning containing `pat` should be logged.
|
||||
pub async fn assert_warn(&self, pat: &str) {
|
||||
self.assert(false, pat).await
|
||||
pub fn assert_warn(&self, pat: &str) {
|
||||
self.assert(false, pat)
|
||||
}
|
||||
|
||||
/// Asserts that an error containing `pat` should be logged.
|
||||
pub async fn assert_error(&self, pat: &str) {
|
||||
self.assert(true, pat).await
|
||||
pub fn assert_error(&self, pat: &str) {
|
||||
self.assert(true, pat)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1466,7 +1441,8 @@ macro_rules! soft_assert {
|
||||
|
||||
impl Drop for InnerLogSink {
|
||||
fn drop(&mut self) {
|
||||
while let Ok(event) = self.events.try_recv() {
|
||||
while let Ok(event) = self.evtracker.try_recv() {
|
||||
print_event(&event);
|
||||
soft_assert!(!event.is_warn(), "Logged an unexpected warning: {event:?}");
|
||||
soft_assert!(!event.is_error(), "Logged an unexpected error: {event:?}");
|
||||
}
|
||||
@@ -1573,7 +1549,7 @@ pub fn pqc_keypair() -> SignedSecretKey {
|
||||
///
|
||||
/// The methods only return [`EventType`] rather than the full [`Event`] since it can only
|
||||
/// be attached to a single [`TestContext`] and therefore the context is already known as
|
||||
/// you will be accessing it as [`TestContext::evtracker`].
|
||||
/// you will be accessing it as [`TestContext::get_evtracker`].
|
||||
#[derive(Debug)]
|
||||
pub struct EventTracker(EventEmitter);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::test_utils::{EventTracker, TestContext, TestContextManager, sync};
|
||||
|
||||
async fn wait_for_item_changed(context: &TestContext) {
|
||||
context
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::AccountsItemChanged))
|
||||
.await;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ async fn test_account_event() -> Result<()> {
|
||||
async fn test_set_displayname() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let context = tcm.alice().await;
|
||||
context.evtracker.clear_events();
|
||||
context.get_evtracker().clear_events();
|
||||
context
|
||||
.set_config(crate::config::Config::Displayname, Some("🐰 Alice"))
|
||||
.await?;
|
||||
@@ -69,7 +69,7 @@ async fn test_set_selfavatar() -> Result<()> {
|
||||
let file = context.dir.path().join("avatar.jpg");
|
||||
let bytes = include_bytes!("../../test-data/image/avatar1000x1000.jpg");
|
||||
tokio::fs::write(&file, bytes).await?;
|
||||
context.evtracker.clear_events();
|
||||
context.get_evtracker().clear_events();
|
||||
context
|
||||
.set_config(
|
||||
crate::config::Config::Selfavatar,
|
||||
@@ -84,7 +84,7 @@ async fn test_set_selfavatar() -> Result<()> {
|
||||
async fn test_set_private_tag() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let context = tcm.alice().await;
|
||||
context.evtracker.clear_events();
|
||||
context.get_evtracker().clear_events();
|
||||
context
|
||||
.set_config(crate::config::Config::PrivateTag, Some("Wonderland"))
|
||||
.await?;
|
||||
@@ -105,7 +105,7 @@ async fn test_import_backup() -> Result<()> {
|
||||
|
||||
let context2 = TestContext::new().await;
|
||||
assert!(!context2.is_configured().await?);
|
||||
context2.evtracker.clear_events();
|
||||
context2.get_evtracker().clear_events();
|
||||
let backup = has_backup(&context2, backup_dir.path()).await?;
|
||||
imex(&context2, ImexMode::ImportBackup, backup.as_ref(), None).await?;
|
||||
assert!(context2.is_configured().await?);
|
||||
@@ -123,7 +123,7 @@ async fn test_receive_backup() {
|
||||
// Set up second device.
|
||||
let ctx1 = tcm.unconfigured().await;
|
||||
|
||||
ctx1.evtracker.clear_events();
|
||||
ctx1.get_evtracker().clear_events();
|
||||
get_backup(&ctx1, provider.qr()).await.unwrap();
|
||||
|
||||
// Make sure the provider finishes without an error.
|
||||
@@ -147,7 +147,7 @@ async fn test_sync() -> Result<()> {
|
||||
alice0
|
||||
.set_config(Config::Displayname, Some(new_name))
|
||||
.await?;
|
||||
alice1.evtracker.clear_events();
|
||||
alice1.get_evtracker().clear_events();
|
||||
sync(&alice0, &alice1).await;
|
||||
wait_for_item_changed(&alice1).await;
|
||||
assert_eq!(
|
||||
@@ -162,7 +162,7 @@ async fn test_sync() -> Result<()> {
|
||||
alice0
|
||||
.set_config(Config::Selfavatar, Some(file.to_str().unwrap()))
|
||||
.await?;
|
||||
alice1.evtracker.clear_events();
|
||||
alice1.get_evtracker().clear_events();
|
||||
sync(&alice0, &alice1).await;
|
||||
wait_for_item_changed(&alice1).await;
|
||||
|
||||
|
||||
+2
-4
@@ -218,10 +218,8 @@ async fn test_aeap_replay_attack() -> Result<()> {
|
||||
assert!(chat::is_contact_in_chat(&bob, group, bob_alice_contact).await?);
|
||||
assert!(!chat::is_contact_in_chat(&bob, group, bob_fiona_contact).await?);
|
||||
|
||||
bob.assert_warn(r#"Autocrypt header address "alice@example.org" is not "fiona@example.net""#)
|
||||
.await;
|
||||
bob.assert_warn("From header in encrypted part doesn't match the outer one")
|
||||
.await;
|
||||
bob.assert_warn(r#"Autocrypt header address "alice@example.org" is not "fiona@example.net""#);
|
||||
bob.assert_warn("From header in encrypted part doesn't match the outer one");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -52,6 +52,6 @@ async fn test_download_stub_message() -> Result<()> {
|
||||
assert_eq!(msg.download_state(), DownloadState::Available);
|
||||
assert_eq!(msg.get_subject(), "foo");
|
||||
assert!(msg.get_text().contains("[97.66 KiB message]"));
|
||||
t.assert_warn("unencrypted message").await;
|
||||
t.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ async fn test_post_msg_bad_sender() -> Result<()> {
|
||||
let msg_bob = Message::load_from_db(bob, msg_bob.id).await?;
|
||||
assert_eq!(msg_bob.download_state, DownloadState::Done);
|
||||
|
||||
bob.assert_warn("Bad sender").await;
|
||||
bob.assert_warn("Bad sender");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -412,11 +412,11 @@ async fn test_lost_pre_msg_vs_new_member() -> Result<()> {
|
||||
|
||||
chat_id_bob.accept(bob).await?;
|
||||
let sent = bob.send_text(chat_id_bob, "Hi all").await;
|
||||
bob.assert_warn("Missing key for fiona@example.net").await;
|
||||
bob.assert_warn("Missing key for fiona@example.net");
|
||||
alice.recv_msg(&sent).await;
|
||||
fiona.recv_msg_trash(&sent).await; // Undecryptable message
|
||||
fiona.assert_warn("decryption failed").await;
|
||||
fiona.assert_warn("unencrypted message").await;
|
||||
fiona.assert_warn("decryption failed");
|
||||
fiona.assert_warn("unencrypted message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -574,9 +574,7 @@ async fn test_full_download_after_trashed() -> Result<()> {
|
||||
let msg = Message::load_from_db_optional(bob, alice_msg.id).await?;
|
||||
assert!(msg.is_none());
|
||||
|
||||
alice
|
||||
.assert_warn("Pre-message was not downloaded yet so treat as normal message")
|
||||
.await;
|
||||
alice.assert_warn("Pre-message was not downloaded yet so treat as normal message");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -767,10 +765,8 @@ async fn test_webxdc_updates_in_post_message_after_deleted_pre_message() -> Resu
|
||||
.is_none()
|
||||
);
|
||||
|
||||
bob.assert_warn("Pre-message was not downloaded yet so treat as normal message")
|
||||
.await;
|
||||
bob.assert_warn("Received webxdc update, but cannot assign it to message")
|
||||
.await;
|
||||
bob.assert_warn("Pre-message was not downloaded yet so treat as normal message");
|
||||
bob.assert_warn("Received webxdc update, but cannot assign it to message");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1001,12 +997,12 @@ async fn test_chatlist_event_on_post_msg_download() -> Result<()> {
|
||||
assert_eq!(alice.get_last_msg_in(msg.chat_id).await.id, msg.id);
|
||||
|
||||
tcm.section("Alice downloads Post-Message and waits for ChatlistItemChanged event ");
|
||||
alice.evtracker.clear_events();
|
||||
alice.get_evtracker().clear_events();
|
||||
alice.recv_msg_trash(&post_message).await;
|
||||
let msg = Message::load_from_db(alice, msg.id).await?;
|
||||
assert_eq!(msg.download_state, DownloadState::Done);
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|e| {
|
||||
e == &EventType::ChatlistItemChanged {
|
||||
chat_id: Some(msg.chat_id),
|
||||
@@ -1035,12 +1031,12 @@ async fn test_bot_pre_message_notifications() -> Result<()> {
|
||||
.await?;
|
||||
|
||||
// Bob receives pre-message
|
||||
bob.evtracker.clear_events();
|
||||
bob.get_evtracker().clear_events();
|
||||
receive_imf(&bob, pre_message.payload().as_bytes(), false).await?;
|
||||
|
||||
// Verify Bob does NOT get an IncomingMsg event for the pre-message
|
||||
assert!(
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching_opt(&bob, |e| matches!(e, EventType::IncomingMsg { .. }))
|
||||
.await
|
||||
.is_none()
|
||||
@@ -1050,7 +1046,7 @@ async fn test_bot_pre_message_notifications() -> Result<()> {
|
||||
receive_imf(&bob, post_message.payload().as_bytes(), false).await?;
|
||||
|
||||
// Verify Bob DOES get an IncomingMsg event for the complete message
|
||||
bob.evtracker
|
||||
bob.get_evtracker()
|
||||
.get_matching(|e| matches!(e, EventType::IncomingMsg { .. }))
|
||||
.await;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ async fn check_verified_single_chat_protection_not_broken(by_classical_email: bo
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
alice.assert_warn("unencrypted message").await;
|
||||
alice.assert_warn("unencrypted message");
|
||||
let contact = alice.add_or_lookup_contact(&bob).await;
|
||||
assert_eq!(contact.is_verified(&alice).await.unwrap(), true);
|
||||
assert_verified(&alice, &bob).await;
|
||||
@@ -599,12 +599,11 @@ async fn test_verified_lost_member_added() -> Result<()> {
|
||||
let result = send_msg(bob, bob_chat_id, &mut msg).await;
|
||||
assert!(result.is_err());
|
||||
|
||||
bob.assert_warn("Missing key for fiona@example.net").await;
|
||||
fiona.assert_warn("missing key").await;
|
||||
fiona.assert_warn("unencrypted message").await;
|
||||
bob.assert_warn("Missing key for fiona@example.net").await;
|
||||
bob.assert_warn(r#"No recipient keys are available, cannot encrypt to ["fiona@example.net"]"#)
|
||||
.await;
|
||||
bob.assert_warn("Missing key for fiona@example.net");
|
||||
fiona.assert_warn("missing key");
|
||||
fiona.assert_warn("unencrypted message");
|
||||
bob.assert_warn("Missing key for fiona@example.net");
|
||||
bob.assert_warn(r#"No recipient keys are available, cannot encrypt to ["fiona@example.net"]"#);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ async fn test_file_handling() {
|
||||
|
||||
assert!(delete_file(context, Path::new(fn0)).await.is_ok());
|
||||
assert!(!file_exist!(context, &fn0));
|
||||
t.assert_warn("refusing to delete non-file").await;
|
||||
t.assert_warn("refusing to delete non-file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -213,7 +213,7 @@ mod tests {
|
||||
)
|
||||
.await?;
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::WebxdcStatusUpdate { .. }))
|
||||
.await;
|
||||
let updates = alice
|
||||
|
||||
@@ -90,7 +90,7 @@ async fn test_send_webxdc_instance() -> Result<()> {
|
||||
let mut instance = Message::new(Viewtype::Webxdc);
|
||||
instance.set_file_from_bytes(&t, "index.html", b"<html>ola!</html>", None)?;
|
||||
assert!(send_msg(&t, chat_id, &mut instance).await.is_err());
|
||||
t.assert_warn("cannot be opened as zip-file").await;
|
||||
t.assert_warn("cannot be opened as zip-file");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ async fn test_send_invalid_webxdc() -> Result<()> {
|
||||
None,
|
||||
)?;
|
||||
assert!(send_msg(&t, chat_id, &mut instance).await.is_err());
|
||||
t.assert_warn("cannot be opened as zip-file").await;
|
||||
t.assert_warn("cannot be opened as zip-file").await;
|
||||
t.assert_warn("cannot be opened as zip-file");
|
||||
t.assert_warn("cannot be opened as zip-file");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -668,7 +668,7 @@ async fn test_receive_status_update() -> Result<()> {
|
||||
|
||||
async fn expect_status_update_event(t: &TestContext, instance_id: MsgId) -> Result<()> {
|
||||
let event = t
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::WebxdcStatusUpdate { .. }))
|
||||
.await;
|
||||
match event {
|
||||
@@ -1299,7 +1299,7 @@ async fn test_get_webxdc_info() -> Result<()> {
|
||||
let result = msg.get_webxdc_info(&t).await;
|
||||
assert!(result.is_err());
|
||||
|
||||
t.assert_warn("empty name given in manifest").await;
|
||||
t.assert_warn("empty name given in manifest");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1697,7 +1697,7 @@ async fn test_webxdc_reject_updates_from_non_groupmembers() -> Result<()> {
|
||||
status,
|
||||
r#"[{"payload":7,"info":"i","summary":"s","serial":1,"max_serial":1}]"#
|
||||
);
|
||||
alice.assert_warn("not a member of chat").await;
|
||||
alice.assert_warn("not a member of chat");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1708,7 +1708,7 @@ async fn test_webxdc_delete_event() -> Result<()> {
|
||||
let instance = send_webxdc_instance(&alice, chat_id).await?;
|
||||
message::delete_msgs(&alice, &[instance.id]).await?;
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|evt| matches!(evt, EventType::WebxdcInstanceDeleted { .. }))
|
||||
.await;
|
||||
Ok(())
|
||||
@@ -1738,7 +1738,7 @@ async fn change_logging_webxdc() -> Result<()> {
|
||||
|
||||
alice.emit_event(EventType::Info("hi".to_string()));
|
||||
alice
|
||||
.evtracker
|
||||
.get_evtracker()
|
||||
.get_matching(|ev| matches!(*ev, EventType::WebxdcStatusUpdate { .. }))
|
||||
.await;
|
||||
assert!(
|
||||
@@ -1838,7 +1838,7 @@ async fn has_incoming_webxdc_event(
|
||||
expected_msg: Message,
|
||||
expected_text: &str,
|
||||
) -> bool {
|
||||
t.evtracker
|
||||
t.get_evtracker()
|
||||
.get_matching_opt(t, |evt| {
|
||||
if let EventType::IncomingWebxdcNotify { msg_id, text, .. } = evt {
|
||||
*msg_id == expected_msg.id && text == expected_text
|
||||
|
||||
Reference in New Issue
Block a user