From 1725cbd652a753c95c117a88b08a17a40ee04b1e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Jul 2026 13:32:01 +0000 Subject: [PATCH] Fix flakey TestOnRejoinBobCanSeeButNotDecryptHistoryInPublicRoom Remove the arbitrary 1-second sleep after Bob's rejoin that was giving time for key forwarding to complete (causing the undecryptable event to be decrypted before the assertion). Replace direct MustGetEvent call with the proper waiter pattern (consistent with other tests in the file) that waits for the backpaginated event to appear in the timeline before checking its decryption state. --- tests/membership_acls_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/membership_acls_test.go b/tests/membership_acls_test.go index 0901db8..e87fa2b 100644 --- a/tests/membership_acls_test.go +++ b/tests/membership_acls_test.go @@ -188,12 +188,13 @@ func TestOnRejoinBobCanSeeButNotDecryptHistoryInPublicRoom(t *testing.T) { tc.Bob.MustJoinRoom(t, roomID, []spec.ServerName{clientTypeA.HS}) waiter = bob.WaitUntilEventInRoom(t, roomID, api.CheckEventHasMembership(bob.UserID(), "join")) waiter.Waitf(t, 5*time.Second, "bob did not see own join") - // this is required for some reason else tests fail - time.Sleep(time.Second) - // bob hits scrollback and should see but not be able to decrypt the message + // bob hits scrollback and should see but not be able to decrypt the message. + // Set up a waiter for the event before backpaginating, so we know when it's available. + waiter = bob.WaitUntilEventInRoom(t, roomID, api.CheckEventHasEventID(evID)) bob.MustBackpaginate(t, roomID, 5) - // TODO: jJ runs fail as the timeline omits the event e.g it has leave,join and not leave,msg,join. + waiter.Waitf(t, 5*time.Second, "bob did not see backpaginated message") + ev := bob.MustGetEvent(t, roomID, evID) must.NotEqual(t, ev.Text, onlyAliceBody, "bob was able to decrypt a message from before he was joined") must.Equal(t, ev.FailedToDecrypt, true, "message not marked as failed to decrypt")