Skip to content

Commit eff9d80

Browse files
Merge pull request #168 from matrix-org/madlittlemods/synapse-10432-switch-to-chunk-events
Adapt MSC2716 implementation to use chunk events
2 parents e44c083 + d14c166 commit eff9d80

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

tests/msc2716_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const timeBetweenMessages = time.Millisecond
3737

3838
var (
3939
insertionEventType = "org.matrix.msc2716.insertion"
40+
chunkEventType = "org.matrix.msc2716.chunk"
4041
markerEventType = "org.matrix.msc2716.marker"
4142

4243
historicalContentField = "org.matrix.msc2716.historical"
@@ -69,8 +70,8 @@ func TestBackfillingHistory(t *testing.T) {
6970
// Test that the message events we insert between A and B come back in the correct order from /messages
7071
//
7172
// Final timeline output: ( [n] = historical chunk )
72-
// (oldest) A, B, [insertion, c, d, e] [insertion, f, g, h, insertion], I, J (newest)
73-
// chunk 1 chunk 0
73+
// (oldest) A, B, [insertion, c, d, e, chunk] [insertion, f, g, h, chunk, insertion], I, J (newest)
74+
// historical chunk 1 historical chunk 0
7475
t.Run("Backfilled historical events resolve with proper state in correct order", func(t *testing.T) {
7576
t.Parallel()
7677

@@ -142,10 +143,10 @@ func TestBackfillingHistory(t *testing.T) {
142143
// Order events from newest to oldest
143144
expectedEventIDOrder = reversed(expectedEventIDOrder)
144145

145-
// 2 eventIDsBefore + [1 insertion event + 2 historical events + 1 insertion event] + [2 historical events + 1 insertion event] + 2 eventIDsAfter
146-
// ^ chunk1 ^ chunk2
147-
if len(expectedEventIDOrder) != 13 {
148-
t.Fatalf("Expected eventID list should be length 13 but saw %d: %s", len(expectedEventIDOrder), expectedEventIDOrder)
146+
// (oldest) A, B, [insertion, c, d, e, chunk] [insertion, f, g, h, chunk, insertion], I, J (newest)
147+
// historical chunk 1 historical chunk 0
148+
if len(expectedEventIDOrder) != 15 {
149+
t.Fatalf("Expected eventID list should be length 15 but saw %d: %s", len(expectedEventIDOrder), expectedEventIDOrder)
149150
}
150151

151152
messagesRes := alice.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, client.WithContentType("application/json"), client.WithQueries(url.Values{
@@ -520,8 +521,8 @@ func TestBackfillingHistory(t *testing.T) {
520521
historicalEventIDs := getEventsFromBatchSendResponseBody(t, batchSendResBody)
521522
baseInsertionEventID := historicalEventIDs[len(historicalEventIDs)-1]
522523

523-
// [1 insertion event + 2 historical events + 1 insertion event]
524-
if len(historicalEventIDs) != 4 {
524+
// [1 insertion event + 2 historical events + 1 chunk event + 1 insertion event]
525+
if len(historicalEventIDs) != 5 {
525526
t.Fatalf("Expected eventID list should be length 15 but saw %d: %s", len(historicalEventIDs), historicalEventIDs)
526527
}
527528

@@ -699,7 +700,10 @@ func fetchUntilMessagesResponseHas(t *testing.T, c *client.CSAPI, roomID string,
699700
}
700701

701702
func isRelevantEvent(r gjson.Result) bool {
702-
return len(r.Get("content").Get("body").Str) > 0 || r.Get("type").Str == insertionEventType || r.Get("type").Str == markerEventType
703+
return len(r.Get("content").Get("body").Str) > 0 ||
704+
r.Get("type").Str == insertionEventType ||
705+
r.Get("type").Str == chunkEventType ||
706+
r.Get("type").Str == markerEventType
703707
}
704708

705709
func getRelevantEventDebugStringsFromMessagesResponse(t *testing.T, body []byte) (eventIDsFromResponse []string) {

0 commit comments

Comments
 (0)