Skip to content

Commit 0e30dd8

Browse files
committed
fix: fix flaky tests::verified_chats::test_verified_chat_editor_reordering and receive_imf::receive_imf_tests::test_two_group_securejoins
Flakiness was introduced in e7348a4. This change removes a call to joining_chat_id() which created a chat, now we check for existing group chat without creating it if it does not exist.
1 parent c001a9a commit 0e30dd8

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/securejoin/bob.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,26 @@ pub(super) async fn start_protocol(context: &Context, invite: QrInvite) -> Resul
6565
)
6666
.await?;
6767

68-
// Chat ID of the group we are joining, unused otherwise.
69-
let group_chat_id = joining_chat_id(context, &invite, chat_id).await?;
70-
if matches!(invite, QrInvite::Group { .. })
71-
&& is_contact_in_chat(context, group_chat_id, ContactId::SELF).await?
72-
{
68+
// `group_chat_id` is `Some` if group chat
69+
// already exists and we are in the chat.
70+
let group_chat_id = match invite {
71+
QrInvite::Group { ref grpid, .. } => {
72+
if let Some((group_chat_id, _blocked)) =
73+
chat::get_chat_id_by_grpid(context, grpid).await?
74+
{
75+
if is_contact_in_chat(context, group_chat_id, ContactId::SELF).await? {
76+
Some(group_chat_id)
77+
} else {
78+
None
79+
}
80+
} else {
81+
None
82+
}
83+
}
84+
QrInvite::Contact { .. } => None,
85+
};
86+
87+
if let Some(group_chat_id) = group_chat_id {
7388
// If QR code is a group invite
7489
// and we are already in the chat,
7590
// nothing needs to be done.

test-data/golden/two_group_securejoins

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Msg#6004: info (Contact#Contact#Info): alice@example.org invited you to join thi
44

55
Waiting for the device of alice@example.org to reply… [NOTICED][INFO]
66
Msg#6006: info (Contact#Contact#Info): alice@example.org replied, waiting for being added to the group… [NOTICED][INFO]
7-
Msg#6002: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO]
7+
Msg#6003: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO]
88
Msg#6008🔒: (Contact#Contact#6001): Member Me added by alice@example.org. [FRESH][INFO]
99
--------------------------------------------------------------------------------

test-data/golden/verified_chats_editor_reordering

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Msg#3004: info (Contact#Contact#Info): alice@example.org invited you to join thi
44

55
Waiting for the device of alice@example.org to reply… [NOTICED][INFO]
66
Msg#3006: info (Contact#Contact#Info): alice@example.org replied, waiting for being added to the group… [NOTICED][INFO]
7-
Msg#3002: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO]
7+
Msg#3003: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO]
88
Msg#3008🔒: (Contact#Contact#3002): [FRESH]
99
Msg#3009: info (Contact#Contact#Info): Member bob@example.net added. [NOTICED][INFO]
1010
Msg#3010🔒: (Contact#Contact#3001): Member Me added by alice@example.org. [FRESH][INFO]

0 commit comments

Comments
 (0)