Skip to content

Commit

Permalink
Verify we only return state events that we pass in
Browse files Browse the repository at this point in the history
Synapse change added in matrix-org/synapse#10552
  • Loading branch information
MadLittleMods committed Aug 10, 2021
1 parent 637ac8f commit b06fc95
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/msc2716_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,39 @@ func TestBackfillingHistory(t *testing.T) {
})
})

t.Run("Batch send endpoint only returns state events that we passed in via state_events_at_start", func(t *testing.T) {
t.Parallel()

roomID := as.CreateRoom(t, createPublicRoomOpts)
alice.JoinRoom(t, roomID, nil)

// Create the "live" event we are going to insert our backfilled events next to
eventIDsBefore := createMessagesInRoom(t, alice, roomID, 1)
eventIdBefore := eventIDsBefore[0]
timeAfterEventBefore := time.Now()

// Insert a backfilled event
batchSendRes := batchSendHistoricalMessages(
t,
as,
roomID,
eventIdBefore,
"",
createJoinStateEventsForBackfillRequest([]string{virtualUserID}, timeAfterEventBefore),
createMessageEventsForBackfillRequest([]string{virtualUserID}, timeAfterEventBefore, 1),
// Status
200,
)
batchSendResBody := client.ParseJSON(t, batchSendRes)
stateEventIDs := client.GetJSONFieldStringArray(t, batchSendResBody, "state_events")

// We only expect 1 state event to be returned because we only passed in 1
// event into `?state_events_at_start`
if len(stateEventIDs) != 1 {
t.Fatalf("Expected only 1 state event to be returned but received %d: %s", len(stateEventIDs), stateEventIDs)
}
})

t.Run("Unrecognised prev_event ID will throw an error", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -336,6 +369,11 @@ func TestBackfillingHistory(t *testing.T) {
)
})

t.Run("TODO: Trying to send insertion event with same `next_chunk_id` will reject", func(t *testing.T) {
t.Skip("Skipping until implemented")
// (room_id, next_chunk_id) should be unique
})

t.Run("Should be able to backfill into private room", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -386,6 +424,10 @@ func TestBackfillingHistory(t *testing.T) {
// TODO: Try adding avatar and displayName and see if historical messages get this info
})

t.Run("TODO: What happens when you point multiple chunks at the same insertion event?", func(t *testing.T) {
t.Skip("Skipping until implemented")
})

t.Run("Historical messages are visible when joining on federated server - auto-generated base insertion event", func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit b06fc95

Please sign in to comment.