Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for joining a room already in partial state #567

Merged
merged 8 commits into from
Feb 10, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/federation_room_join_partial_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,50 @@ func TestPartialStateJoin(t *testing.T) {
must.MatchResponse(t, response, spec)
})

// we should be able to join a room that is already joined & resyncing
t.Run("CanFastJoinDuringPartialStateJoin", func(t *testing.T) {
alice := deployment.RegisterUser(t, "hs1", "t44alice", "secret", false)
bob := deployment.RegisterUser(t, "hs1", "t44bob", "secret", false)

server := createTestServer(
t,
deployment,
federation.HandleTransactionRequests(nil, nil),
)
cancel := server.Listen()
defer cancel()
serverRoom := createTestRoom(t, server, alice.GetDefaultRoomVersion(t))

psjResult := beginPartialStateJoin(t, server, serverRoom, alice)
defer psjResult.Destroy(t)

alice.Client.Timeout = 2 * time.Second
paths := []string{"_matrix", "client", "v3", "rooms", serverRoom.RoomID, "send", "m.room.message", "0"}
res := alice.MustDoFunc(t, "PUT", paths, client.WithJSONBody(t, map[string]interface{}{
"msgtype": "m.text",
"body": "Hello world!",
}))
body := gjson.ParseBytes(client.ParseJSON(t, res))
eventID := body.Get("event_id").Str
t.Logf("Alice sent event event ID %s", eventID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might be able to remove this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed---we don't use the eventID anywhere else; Alice waits to see Bob's join.

squahtx marked this conversation as resolved.
Show resolved Hide resolved

bob.JoinRoom(t, serverRoom.RoomID, []string{server.ServerName()})
alice.MustSyncUntil(t,
client.SyncReq{
Filter: buildLazyLoadingSyncFilter(nil),
},
client.SyncJoinedTo(bob.UserID, serverRoom.RoomID),
)
t.Logf("Alice saw Bob's join")
bob.MustSyncUntil(t,
client.SyncReq{
Filter: buildLazyLoadingSyncFilter(nil),
},
client.SyncJoinedTo(bob.UserID, serverRoom.RoomID),
)
t.Logf("Bob saw Bob's join")
})

t.Run("Leaving during resync is seen after the resync", func(t *testing.T) {
// Before testing that leaves during resyncs are seen during resyncs, sanity
// check that leaves during resyncs appear after the resync.
Expand Down