Skip to content

Commit 4bd1444

Browse files
authored
Merge pull request #204 from matrix-org/kegan/TestRoomKeyIsCycledOnMemberLeaving
Deflake TestRoomKeyIsCycledOnMemberLeaving
2 parents 95425e7 + b89f6dc commit 4bd1444

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/room_keys_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package tests
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/matrix-org/gomatrixserverlib/spec"
76
"strings"
87
"testing"
98
"time"
109

10+
"github.com/matrix-org/gomatrixserverlib/spec"
11+
1112
"github.com/matrix-org/complement-crypto/internal/api"
1213
"github.com/matrix-org/complement-crypto/internal/cc"
1314
"github.com/matrix-org/complement-crypto/internal/deploy/callback"
@@ -254,8 +255,12 @@ func TestRoomKeyIsCycledOnMemberLeaving(t *testing.T) {
254255
// now Charlie is going to leave the room, causing his user ID to appear in device_lists.left
255256
// which should trigger a new room key to be sent (on message send)
256257
tc.Charlie.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "leave"}, client.WithJSONBody(t, map[string]any{}))
258+
// wait until Alice sees the leave event.
259+
// She will send the test message so we need to make sure she knows the member list has changed.
260+
alice.WaitUntilEventInRoom(t, roomID, api.CheckEventHasMembership(tc.Charlie.UserID, "leave")).Waitf(t, 5*time.Second, "alice did not see charlie leave")
257261

258-
// we don't know how long it will take for the device list update to be processed, so wait 1s
262+
// Seeing the leave event isn't enough.
263+
// We don't know how long it will take for the device list update to be processed, so wait 1s
259264
time.Sleep(time.Second)
260265

261266
// now send another message from Alice, who should negotiate a new room key

0 commit comments

Comments
 (0)