Skip to content

Commit

Permalink
Maybe use MustSyncUntil?
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Jan 19, 2023
1 parent 05b53bc commit 84c8878
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions tests/federation_room_join_partial_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,26 +228,21 @@ func TestPartialStateJoin(t *testing.T) {
// release the federation /state response
psjResult.FinishStateRequest()

t.Log("8. Have Alice eager-sync. She should see the remote room.")
response, eagerSyncToken = alice.MustSync(t, getEagerSyncReq())

roomRes := response.Get(syncJoinedRoomPath)
if !roomRes.Exists() {
t.Fatal("Sync should now include the joined room since resync is over")
t.Log("8. Have Alice eager-sync. She should see the remote room, including" +
"Charlie and Derek.")
remoteMembershipFor := func(localpart string) func(result gjson.Result) bool {
return func(result gjson.Result) bool {
return result.Get("type").Str == "m.room.member" && result.Get("state_key").Str == server.UserID(localpart)
}
}

// check that the state includes both charlie and derek.
matcher := match.JSONCheckOffAllowUnwanted("state.events",
[]interface{}{
"m.room.member|" + server.UserID("charlie"),
"m.room.member|" + server.UserID("derek"),
}, func(result gjson.Result) interface{} {
return strings.Join([]string{result.Map()["type"].Str, result.Map()["state_key"].Str}, "|")
}, nil,
_ = alice.MustSyncUntil(
t,
getEagerSyncReq(),
client.SyncJoinedTo(alice.UserID, serverRoom.RoomID),
client.SyncStateHas(serverRoom.RoomID, remoteMembershipFor("charlie")),
client.SyncStateHas(serverRoom.RoomID, remoteMembershipFor("derek")),
)
if err := matcher([]byte(roomRes.Raw)); err != nil {
t.Errorf("Did not find expected state events in /sync response: %s", err)
}
}

t.Run("EagerInitialSyncDuringPartialStateJoin", func(t *testing.T) {
Expand Down

0 comments on commit 84c8878

Please sign in to comment.