Skip to content

Commit

Permalink
Test you can rejoin even if resync didn't complete
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Feb 17, 2023
1 parent 43b37a7 commit e7488d7
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion tests/federation_room_join_partial_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3575,9 +3575,53 @@ func TestPartialStateJoin(t *testing.T) {
client.SyncLeftFrom(alice.UserID, serverRoom.RoomID),
)
})

t.Run("succeeds, then rejoin succeeds without resync completing", func(t *testing.T) {
t.Log("Alice begins a partial join to a room")
alice := deployment.RegisterUser(t, "hs1", "t48alice", "secret", false)
handleTransactions := federation.HandleTransactionRequests(
// Accept all PDUs and EDUs
func(e *gomatrixserverlib.Event) {},
func(e gomatrixserverlib.EDU) {},
)
server := createTestServer(t, deployment, handleTransactions)
cancel := server.Listen()
defer cancel()

serverRoom := createTestRoom(t, server, alice.GetDefaultRoomVersion(t))
t.Log("Alice partial-joins her room")
psjResult := beginPartialStateJoin(t, server, serverRoom, alice)
defer psjResult.Destroy(t)

t.Log("Alice waits to see her join")
aliceNextBatch := alice.MustSyncUntil(
t,
client.SyncReq{Filter: buildLazyLoadingSyncFilter(nil)},
client.SyncJoinedTo(alice.UserID, serverRoom.RoomID),
)

t.Log("Alice leaves the room")
alice.LeaveRoom(t, serverRoom.RoomID)

t.Log("Alice sees Alice's leave")
aliceNextBatch = alice.MustSyncUntil(
t,
client.SyncReq{Since: aliceNextBatch, Filter: buildLazyLoadingSyncFilter(nil)},
client.SyncLeftFrom(alice.UserID, serverRoom.RoomID),
)

// The resync has not completed because we have not called psjResult.FinishStateRequest()
t.Log("Alice rejoins her room")
alice.JoinRoom(t, serverRoom.RoomID, []string{server.ServerName()})
aliceNextBatch = alice.MustSyncUntil(
t,
client.SyncReq{Since: aliceNextBatch, Filter: buildLazyLoadingSyncFilter(nil)},
client.SyncJoinedTo(alice.UserID, serverRoom.RoomID),
)

})
// TODO: tests which assert that:
// - Join+Leave+Join works
// - Join+Leave+Rejoin works
// - Join + remote kick works
// - Join + remote ban works, then cannot rejoin
})
Expand Down

0 comments on commit e7488d7

Please sign in to comment.