@@ -38,24 +38,24 @@ const timeBetweenMessages = time.Millisecond
3838
3939var (
4040 insertionEventType = "org.matrix.msc2716.insertion"
41- chunkEventType = "org.matrix.msc2716.chunk "
41+ batchEventType = "org.matrix.msc2716.batch "
4242 markerEventType = "org.matrix.msc2716.marker"
4343
4444 historicalContentField = "org.matrix.msc2716.historical"
45- nextChunkIDContentField = "org.matrix.msc2716.next_chunk_id "
45+ nextBatchIDContentField = "org.matrix.msc2716.next_batch_id "
4646 markerInsertionContentField = "org.matrix.msc2716.marker.insertion"
4747)
4848
4949var createPublicRoomOpts = map [string ]interface {}{
5050 "preset" : "public_chat" ,
5151 "name" : "the hangout spot" ,
52- "room_version" : "org.matrix.msc2716 " ,
52+ "room_version" : "org.matrix.msc2716v3 " ,
5353}
5454
5555var createPrivateRoomOpts = map [string ]interface {}{
5656 "preset" : "private_chat" ,
5757 "name" : "the hangout spot" ,
58- "room_version" : "org.matrix.msc2716 " ,
58+ "room_version" : "org.matrix.msc2716v3 " ,
5959}
6060
6161func TestBackfillingHistory (t * testing.T ) {
@@ -82,9 +82,9 @@ func TestBackfillingHistory(t *testing.T) {
8282 t .Run ("parallel" , func (t * testing.T ) {
8383 // Test that the message events we insert between A and B come back in the correct order from /messages
8484 //
85- // Final timeline output: ( [n] = historical chunk )
86- // (oldest) A, B, [insertion, c, d, e, chunk ] [insertion, f, g, h, chunk , insertion], I, J (newest)
87- // historical chunk 1 historical chunk 0
85+ // Final timeline output: ( [n] = historical batch )
86+ // (oldest) A, B, [insertion, c, d, e, batch ] [insertion, f, g, h, batch , insertion], I, J (newest)
87+ // historical batch 1 historical batch 0
8888 t .Run ("Backfilled historical events resolve with proper state in correct order" , func (t * testing.T ) {
8989 t .Parallel ()
9090
@@ -111,7 +111,7 @@ func TestBackfillingHistory(t *testing.T) {
111111 // inserted history later.
112112 eventIDsAfter := createMessagesInRoom (t , alice , roomID , 2 )
113113
114- // Insert the most recent chunk of backfilled history
114+ // Insert the most recent batch of backfilled history
115115 insertTime0 := timeAfterEventBefore .Add (timeBetweenMessages * 3 )
116116 batchSendRes := batchSendHistoricalMessages (
117117 t ,
@@ -127,19 +127,19 @@ func TestBackfillingHistory(t *testing.T) {
127127 batchSendResBody0 := client .ParseJSON (t , batchSendRes )
128128 insertionEventID0 := client .GetJSONFieldStr (t , batchSendResBody0 , "insertion_event_id" )
129129 historicalEventIDs0 := client .GetJSONFieldStringArray (t , batchSendResBody0 , "event_ids" )
130- chunkEventID0 := client .GetJSONFieldStr (t , batchSendResBody0 , "chunk_event_id " )
130+ batchEventID0 := client .GetJSONFieldStr (t , batchSendResBody0 , "batch_event_id " )
131131 baseInsertionEventID0 := client .GetJSONFieldStr (t , batchSendResBody0 , "base_insertion_event_id" )
132- nextChunkID0 := client .GetJSONFieldStr (t , batchSendResBody0 , "next_chunk_id " )
132+ nextBatchID0 := client .GetJSONFieldStr (t , batchSendResBody0 , "next_batch_id " )
133133
134- // Insert another older chunk of backfilled history from the same user.
135- // Make sure the meta data and joins still work on the subsequent chunk
134+ // Insert another older batch of backfilled history from the same user.
135+ // Make sure the meta data and joins still work on the subsequent batch
136136 insertTime1 := timeAfterEventBefore
137137 batchSendRes1 := batchSendHistoricalMessages (
138138 t ,
139139 as ,
140140 roomID ,
141141 eventIdBefore ,
142- nextChunkID0 ,
142+ nextBatchID0 ,
143143 createJoinStateEventsForBackfillRequest ([]string {virtualUserID }, insertTime1 ),
144144 createMessageEventsForBackfillRequest ([]string {virtualUserID }, insertTime1 , 3 ),
145145 // Status
@@ -148,23 +148,23 @@ func TestBackfillingHistory(t *testing.T) {
148148 batchSendResBody1 := client .ParseJSON (t , batchSendRes1 )
149149 insertionEventID1 := client .GetJSONFieldStr (t , batchSendResBody1 , "insertion_event_id" )
150150 historicalEventIDs1 := client .GetJSONFieldStringArray (t , batchSendResBody1 , "event_ids" )
151- chunkEventID1 := client .GetJSONFieldStr (t , batchSendResBody1 , "chunk_event_id " )
151+ batchEventID1 := client .GetJSONFieldStr (t , batchSendResBody1 , "batch_event_id " )
152152
153153 var expectedEventIDOrder []string
154154 expectedEventIDOrder = append (expectedEventIDOrder , eventIDsBefore ... )
155155 expectedEventIDOrder = append (expectedEventIDOrder , insertionEventID1 )
156156 expectedEventIDOrder = append (expectedEventIDOrder , historicalEventIDs1 ... )
157- expectedEventIDOrder = append (expectedEventIDOrder , chunkEventID1 )
157+ expectedEventIDOrder = append (expectedEventIDOrder , batchEventID1 )
158158 expectedEventIDOrder = append (expectedEventIDOrder , insertionEventID0 )
159159 expectedEventIDOrder = append (expectedEventIDOrder , historicalEventIDs0 ... )
160- expectedEventIDOrder = append (expectedEventIDOrder , chunkEventID0 )
160+ expectedEventIDOrder = append (expectedEventIDOrder , batchEventID0 )
161161 expectedEventIDOrder = append (expectedEventIDOrder , baseInsertionEventID0 )
162162 expectedEventIDOrder = append (expectedEventIDOrder , eventIDsAfter ... )
163163 // Order events from newest to oldest
164164 expectedEventIDOrder = reversed (expectedEventIDOrder )
165165
166- // (oldest) A, B, [insertion, c, d, e, chunk ] [insertion, f, g, h, chunk , insertion], I, J (newest)
167- // historical chunk 1 historical chunk 0
166+ // (oldest) A, B, [insertion, c, d, e, batch ] [insertion, f, g, h, batch , insertion], I, J (newest)
167+ // historical batch 1 historical batch 0
168168 if len (expectedEventIDOrder ) != 15 {
169169 t .Fatalf ("Expected eventID list should be length 15 but saw %d: %s" , len (expectedEventIDOrder ), expectedEventIDOrder )
170170 }
@@ -206,7 +206,7 @@ func TestBackfillingHistory(t *testing.T) {
206206 }
207207 })
208208
209- t .Run ("Backfilled historical events from multiple users in the same chunk " , func (t * testing.T ) {
209+ t .Run ("Backfilled historical events from multiple users in the same batch " , func (t * testing.T ) {
210210 t .Parallel ()
211211
212212 roomID := as .CreateRoom (t , createPublicRoomOpts )
@@ -355,7 +355,7 @@ func TestBackfillingHistory(t *testing.T) {
355355 )
356356 })
357357
358- t .Run ("Unrecognised chunk_id will throw an error" , func (t * testing.T ) {
358+ t .Run ("Unrecognised batch_id will throw an error" , func (t * testing.T ) {
359359 t .Parallel ()
360360
361361 roomID := as .CreateRoom (t , createPublicRoomOpts )
@@ -370,7 +370,7 @@ func TestBackfillingHistory(t *testing.T) {
370370 as ,
371371 roomID ,
372372 eventIdBefore ,
373- "XXX_DOES_NOT_EXIST_CHUNK_ID " ,
373+ "XXX_DOES_NOT_EXIST_BATCH_ID " ,
374374 createJoinStateEventsForBackfillRequest ([]string {virtualUserID }, timeAfterEventBefore ),
375375 createMessageEventsForBackfillRequest ([]string {virtualUserID }, timeAfterEventBefore , 1 ),
376376 // Status
@@ -402,9 +402,9 @@ func TestBackfillingHistory(t *testing.T) {
402402 )
403403 })
404404
405- t .Run ("TODO: Trying to send insertion event with same `next_chunk_id ` will reject" , func (t * testing.T ) {
405+ t .Run ("TODO: Trying to send insertion event with same `next_batch_id ` will reject" , func (t * testing.T ) {
406406 t .Skip ("Skipping until implemented" )
407- // (room_id, next_chunk_id ) should be unique
407+ // (room_id, next_batch_id ) should be unique
408408 })
409409
410410 t .Run ("Should be able to backfill into private room" , func (t * testing.T ) {
@@ -457,7 +457,7 @@ func TestBackfillingHistory(t *testing.T) {
457457 // TODO: Try adding avatar and displayName and see if historical messages get this info
458458 })
459459
460- t .Run ("TODO: What happens when you point multiple chunks at the same insertion event?" , func (t * testing.T ) {
460+ t .Run ("TODO: What happens when you point multiple batches at the same insertion event?" , func (t * testing.T ) {
461461 t .Skip ("Skipping until implemented" )
462462 })
463463
@@ -525,11 +525,11 @@ func TestBackfillingHistory(t *testing.T) {
525525 timeAfterEventBefore := time .Now ()
526526
527527 // Create insertion event in the normal DAG
528- chunkId := "mynextchunkid123 "
528+ batchID := "mynextBatchID123 "
529529 insertionEvent := b.Event {
530530 Type : insertionEventType ,
531531 Content : map [string ]interface {}{
532- nextChunkIDContentField : chunkId ,
532+ nextBatchIDContentField : batchID ,
533533 historicalContentField : true ,
534534 },
535535 }
@@ -551,7 +551,7 @@ func TestBackfillingHistory(t *testing.T) {
551551 as ,
552552 roomID ,
553553 eventIdBefore ,
554- chunkId ,
554+ batchID ,
555555 createJoinStateEventsForBackfillRequest ([]string {virtualUserID }, timeAfterEventBefore ),
556556 createMessageEventsForBackfillRequest ([]string {virtualUserID }, timeAfterEventBefore , 2 ),
557557 // Status
@@ -809,7 +809,7 @@ func TestBackfillingHistory(t *testing.T) {
809809 })
810810 })
811811
812- t .Run ("Not allowed to redact MSC2716 insertion, chunk , marker events" , func (t * testing.T ) {
812+ t .Run ("Not allowed to redact MSC2716 insertion, batch , marker events" , func (t * testing.T ) {
813813 t .Parallel ()
814814
815815 roomID := as .CreateRoom (t , createUnsupportedMSC2716RoomOpts )
@@ -834,14 +834,14 @@ func TestBackfillingHistory(t *testing.T) {
834834 )
835835 batchSendResBody := client .ParseJSON (t , batchSendRes )
836836 insertionEventID := client .GetJSONFieldStr (t , batchSendResBody , "insertion_event_id" )
837- chunkEventID := client .GetJSONFieldStr (t , batchSendResBody , "chunk_event_id " )
837+ batchEventID := client .GetJSONFieldStr (t , batchSendResBody , "batch_event_id " )
838838 baseInsertionEventID := client .GetJSONFieldStr (t , batchSendResBody , "base_insertion_event_id" )
839839
840840 // Send the marker event
841841 markerEventID := sendMarkerAndEnsureBackfilled (t , as , alice , roomID , baseInsertionEventID )
842842
843843 redactEventID (t , alice , roomID , insertionEventID , 403 )
844- redactEventID (t , alice , roomID , chunkEventID , 403 )
844+ redactEventID (t , alice , roomID , batchEventID , 403 )
845845 redactEventID (t , alice , roomID , markerEventID , 403 )
846846 })
847847 })
@@ -914,7 +914,7 @@ func fetchUntilMessagesResponseHas(t *testing.T, c *client.CSAPI, roomID string,
914914func isRelevantEvent (r gjson.Result ) bool {
915915 return len (r .Get ("content" ).Get ("body" ).Str ) > 0 ||
916916 r .Get ("type" ).Str == insertionEventType ||
917- r .Get ("type" ).Str == chunkEventType ||
917+ r .Get ("type" ).Str == batchEventType ||
918918 r .Get ("type" ).Str == markerEventType
919919}
920920
@@ -1088,7 +1088,7 @@ func createMessageEventsForBackfillRequest(
10881088 "origin_server_ts" : insertOriginServerTs + (timeBetweenMessagesMS * uint64 (i )),
10891089 "content" : map [string ]interface {}{
10901090 "msgtype" : "m.text" ,
1091- "body" : fmt .Sprintf ("Historical %d (chunk =%d)" , i , chunkCount ),
1091+ "body" : fmt .Sprintf ("Historical %d (batch =%d)" , i , batchCount ),
10921092 historicalContentField : true ,
10931093 },
10941094 }
@@ -1119,25 +1119,25 @@ func redactEventID(t *testing.T, c *client.CSAPI, roomID, eventID string, expect
11191119 }
11201120}
11211121
1122- var chunkCount int64 = 0
1122+ var batchCount int64 = 0
11231123
11241124func batchSendHistoricalMessages (
11251125 t * testing.T ,
11261126 c * client.CSAPI ,
11271127 roomID string ,
11281128 insertAfterEventId string ,
1129- chunkID string ,
1129+ batchID string ,
11301130 stateEventsAtStart []map [string ]interface {},
11311131 events []map [string ]interface {},
11321132 expectedStatus int ,
11331133) (res * http.Response ) {
11341134 t .Helper ()
11351135
11361136 query := make (url.Values , 2 )
1137- query .Add ("prev_event " , insertAfterEventId )
1138- // If provided, connect the chunk to the last insertion point
1139- if chunkID != "" {
1140- query .Add ("chunk_id " , chunkID )
1137+ query .Add ("prev_event_id " , insertAfterEventId )
1138+ // If provided, connect the batch to the last insertion point
1139+ if batchID != "" {
1140+ query .Add ("batch_id " , batchID )
11411141 }
11421142
11431143 res = c .DoFunc (
@@ -1156,7 +1156,7 @@ func batchSendHistoricalMessages(
11561156 t .Fatalf ("msc2716.batchSendHistoricalMessages got %d HTTP status code from batch send response but want %d" , res .StatusCode , expectedStatus )
11571157 }
11581158
1159- chunkCount ++
1159+ batchCount ++
11601160
11611161 return res
11621162}
0 commit comments