-
Notifications
You must be signed in to change notification settings - Fork 52
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 shared history visibility over federation #716
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,3 +249,51 @@ func TestNetworkPartitionOrdering(t *testing.T) { | |
}, | ||
}) | ||
} | ||
|
||
// Tests that /sync v2 returns the correct timeline for the following situation _over federation_: | ||
// - Alice and Bob in a room. | ||
// - Bob leaves the room. | ||
// - Alice sends a message. | ||
// - Bob joins the room. | ||
// - The next sync response should include a timeline which ends with [BOB_LEAVE, ALICE_MSG, BOB_JOIN]. | ||
// | ||
// In practice, it seems Synapse can respond with [BOB_LEAVE, BOB_JOIN], despite the room being shared history visibility. | ||
func TestSyncDeliversAllTimelineEventsInSharedHistoryRooms(t *testing.T) { | ||
deployment := complement.Deploy(t, 2) | ||
defer deployment.Destroy(t) | ||
|
||
// alice and bob in a room | ||
alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) | ||
bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) | ||
roomID := alice.MustCreateRoom(t, map[string]interface{}{ | ||
"preset": "public_chat", | ||
}) | ||
bob.MustJoinRoom(t, roomID, []string{"hs1"}) | ||
_, nextBatch := bob.MustSync(t, client.SyncReq{}) | ||
|
||
// bob leaves and alice sends a message | ||
bob.MustLeaveRoom(t, roomID) | ||
eventID := alice.SendEventSynced(t, roomID, b.Event{ | ||
Type: "m.room.message", | ||
Content: map[string]interface{}{ | ||
"msgtype": "m.text", | ||
"body": "Sent when Bob has left", | ||
}, | ||
}) | ||
_, nextBatch = bob.MustSync(t, client.SyncReq{Since: nextBatch}) | ||
|
||
// bob rejoins and syncs, he should see this message | ||
bob.MustJoinRoom(t, roomID, []string{"hs1"}) | ||
syncResponse, _ := bob.MustSync(t, client.SyncReq{Since: nextBatch}) | ||
timeline := syncResponse.Get(fmt.Sprintf("rooms.join.%s.timeline.events", client.GjsonEscape(roomID))) | ||
t.Logf("timeline => %v", timeline.Raw) | ||
timelineArray := timeline.Array() | ||
must.NotEqual(t, len(timelineArray), 0, "no timeline for room "+roomID) | ||
must.Equal(t, len(timelineArray) >= 3, true, "need at least 3 timeline events for the room") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't print the number of events there are, which makes seeing how Synapse is failing hard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The raw timeline is logged on
|
||
// last event is the join | ||
must.MatchGJSON(t, timelineArray[len(timelineArray)-1], match.JSONKeyEqual("content.membership", "join")) | ||
// 2nd to last is the message | ||
must.MatchGJSON(t, timelineArray[len(timelineArray)-2], match.JSONKeyEqual("event_id", eventID)) | ||
// 3rd to last is the leave | ||
must.MatchGJSON(t, timelineArray[len(timelineArray)-3], match.JSONKeyEqual("content.membership", "leave")) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be perfectly valid to return just
BOB_JOIN
here, which I thought we did