From a3aa199a435f4e2506bb70f3801dcc68c2a94bdd Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 13 Jul 2022 11:39:30 +0100 Subject: [PATCH] Try to mitigate races with joining `allowed_room` --- tests/restricted_rooms_test.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/restricted_rooms_test.go b/tests/restricted_rooms_test.go index 487aa883..2009b1e3 100644 --- a/tests/restricted_rooms_test.go +++ b/tests/restricted_rooms_test.go @@ -77,8 +77,29 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a }) t.Run("Join should succeed when joined to allowed room", func(t *testing.T) { - // Join the allowed room, attempt to join the room again, which now should succeed. + // Join the allowed room. bob.JoinRoom(t, allowed_room, []string{"hs1"}) + + // Confirm that we joined the allowed room by changing displayname and + // waiting for confirmation in the /sync response. (This is an attempt + // to mitigate race conditions between Synapse workers. We want to + // ensure that the worker serving the join to `room` knows we are joined + // to `allowed_room`.) + bob.SendEventSynced( + t, + allowed_room, + b.Event{ + Type: "m.room.member", + Sender: bob.UserID, + StateKey: &bob.UserID, + Content: map[string]interface{}{ + "membership": "join", + "displayname": "Bobby", + }, + }, + ) + + // We should now be able to join the restricted room. bob.JoinRoom(t, room, []string{"hs1"}) // Joining the same room again should work fine (e.g. to change your display name).