@@ -38,24 +38,24 @@ const timeBetweenMessages = time.Millisecond
38
38
39
39
var (
40
40
insertionEventType = "org.matrix.msc2716.insertion"
41
- chunkEventType = "org.matrix.msc2716.chunk "
41
+ batchEventType = "org.matrix.msc2716.batch "
42
42
markerEventType = "org.matrix.msc2716.marker"
43
43
44
44
historicalContentField = "org.matrix.msc2716.historical"
45
- nextChunkIDContentField = "org.matrix.msc2716.next_chunk_id "
45
+ nextBatchIDContentField = "org.matrix.msc2716.next_batch_id "
46
46
markerInsertionContentField = "org.matrix.msc2716.marker.insertion"
47
47
)
48
48
49
49
var createPublicRoomOpts = map [string ]interface {}{
50
50
"preset" : "public_chat" ,
51
51
"name" : "the hangout spot" ,
52
- "room_version" : "org.matrix.msc2716 " ,
52
+ "room_version" : "org.matrix.msc2716v3 " ,
53
53
}
54
54
55
55
var createPrivateRoomOpts = map [string ]interface {}{
56
56
"preset" : "private_chat" ,
57
57
"name" : "the hangout spot" ,
58
- "room_version" : "org.matrix.msc2716 " ,
58
+ "room_version" : "org.matrix.msc2716v3 " ,
59
59
}
60
60
61
61
func TestBackfillingHistory (t * testing.T ) {
@@ -82,9 +82,9 @@ func TestBackfillingHistory(t *testing.T) {
82
82
t .Run ("parallel" , func (t * testing.T ) {
83
83
// Test that the message events we insert between A and B come back in the correct order from /messages
84
84
//
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
88
88
t .Run ("Backfilled historical events resolve with proper state in correct order" , func (t * testing.T ) {
89
89
t .Parallel ()
90
90
@@ -111,7 +111,7 @@ func TestBackfillingHistory(t *testing.T) {
111
111
// inserted history later.
112
112
eventIDsAfter := createMessagesInRoom (t , alice , roomID , 2 )
113
113
114
- // Insert the most recent chunk of backfilled history
114
+ // Insert the most recent batch of backfilled history
115
115
insertTime0 := timeAfterEventBefore .Add (timeBetweenMessages * 3 )
116
116
batchSendRes := batchSendHistoricalMessages (
117
117
t ,
@@ -127,19 +127,19 @@ func TestBackfillingHistory(t *testing.T) {
127
127
batchSendResBody0 := client .ParseJSON (t , batchSendRes )
128
128
insertionEventID0 := client .GetJSONFieldStr (t , batchSendResBody0 , "insertion_event_id" )
129
129
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 " )
131
131
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 " )
133
133
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
136
136
insertTime1 := timeAfterEventBefore
137
137
batchSendRes1 := batchSendHistoricalMessages (
138
138
t ,
139
139
as ,
140
140
roomID ,
141
141
eventIdBefore ,
142
- nextChunkID0 ,
142
+ nextBatchID0 ,
143
143
createJoinStateEventsForBackfillRequest ([]string {virtualUserID }, insertTime1 ),
144
144
createMessageEventsForBackfillRequest ([]string {virtualUserID }, insertTime1 , 3 ),
145
145
// Status
@@ -148,23 +148,23 @@ func TestBackfillingHistory(t *testing.T) {
148
148
batchSendResBody1 := client .ParseJSON (t , batchSendRes1 )
149
149
insertionEventID1 := client .GetJSONFieldStr (t , batchSendResBody1 , "insertion_event_id" )
150
150
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 " )
152
152
153
153
var expectedEventIDOrder []string
154
154
expectedEventIDOrder = append (expectedEventIDOrder , eventIDsBefore ... )
155
155
expectedEventIDOrder = append (expectedEventIDOrder , insertionEventID1 )
156
156
expectedEventIDOrder = append (expectedEventIDOrder , historicalEventIDs1 ... )
157
- expectedEventIDOrder = append (expectedEventIDOrder , chunkEventID1 )
157
+ expectedEventIDOrder = append (expectedEventIDOrder , batchEventID1 )
158
158
expectedEventIDOrder = append (expectedEventIDOrder , insertionEventID0 )
159
159
expectedEventIDOrder = append (expectedEventIDOrder , historicalEventIDs0 ... )
160
- expectedEventIDOrder = append (expectedEventIDOrder , chunkEventID0 )
160
+ expectedEventIDOrder = append (expectedEventIDOrder , batchEventID0 )
161
161
expectedEventIDOrder = append (expectedEventIDOrder , baseInsertionEventID0 )
162
162
expectedEventIDOrder = append (expectedEventIDOrder , eventIDsAfter ... )
163
163
// Order events from newest to oldest
164
164
expectedEventIDOrder = reversed (expectedEventIDOrder )
165
165
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
168
168
if len (expectedEventIDOrder ) != 15 {
169
169
t .Fatalf ("Expected eventID list should be length 15 but saw %d: %s" , len (expectedEventIDOrder ), expectedEventIDOrder )
170
170
}
@@ -206,7 +206,7 @@ func TestBackfillingHistory(t *testing.T) {
206
206
}
207
207
})
208
208
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 ) {
210
210
t .Parallel ()
211
211
212
212
roomID := as .CreateRoom (t , createPublicRoomOpts )
@@ -355,7 +355,7 @@ func TestBackfillingHistory(t *testing.T) {
355
355
)
356
356
})
357
357
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 ) {
359
359
t .Parallel ()
360
360
361
361
roomID := as .CreateRoom (t , createPublicRoomOpts )
@@ -370,7 +370,7 @@ func TestBackfillingHistory(t *testing.T) {
370
370
as ,
371
371
roomID ,
372
372
eventIdBefore ,
373
- "XXX_DOES_NOT_EXIST_CHUNK_ID " ,
373
+ "XXX_DOES_NOT_EXIST_BATCH_ID " ,
374
374
createJoinStateEventsForBackfillRequest ([]string {virtualUserID }, timeAfterEventBefore ),
375
375
createMessageEventsForBackfillRequest ([]string {virtualUserID }, timeAfterEventBefore , 1 ),
376
376
// Status
@@ -402,9 +402,9 @@ func TestBackfillingHistory(t *testing.T) {
402
402
)
403
403
})
404
404
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 ) {
406
406
t .Skip ("Skipping until implemented" )
407
- // (room_id, next_chunk_id ) should be unique
407
+ // (room_id, next_batch_id ) should be unique
408
408
})
409
409
410
410
t .Run ("Should be able to backfill into private room" , func (t * testing.T ) {
@@ -457,7 +457,7 @@ func TestBackfillingHistory(t *testing.T) {
457
457
// TODO: Try adding avatar and displayName and see if historical messages get this info
458
458
})
459
459
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 ) {
461
461
t .Skip ("Skipping until implemented" )
462
462
})
463
463
@@ -525,11 +525,11 @@ func TestBackfillingHistory(t *testing.T) {
525
525
timeAfterEventBefore := time .Now ()
526
526
527
527
// Create insertion event in the normal DAG
528
- chunkId := "mynextchunkid123 "
528
+ batchID := "mynextBatchID123 "
529
529
insertionEvent := b.Event {
530
530
Type : insertionEventType ,
531
531
Content : map [string ]interface {}{
532
- nextChunkIDContentField : chunkId ,
532
+ nextBatchIDContentField : batchID ,
533
533
historicalContentField : true ,
534
534
},
535
535
}
@@ -551,7 +551,7 @@ func TestBackfillingHistory(t *testing.T) {
551
551
as ,
552
552
roomID ,
553
553
eventIdBefore ,
554
- chunkId ,
554
+ batchID ,
555
555
createJoinStateEventsForBackfillRequest ([]string {virtualUserID }, timeAfterEventBefore ),
556
556
createMessageEventsForBackfillRequest ([]string {virtualUserID }, timeAfterEventBefore , 2 ),
557
557
// Status
@@ -809,7 +809,7 @@ func TestBackfillingHistory(t *testing.T) {
809
809
})
810
810
})
811
811
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 ) {
813
813
t .Parallel ()
814
814
815
815
roomID := as .CreateRoom (t , createUnsupportedMSC2716RoomOpts )
@@ -834,14 +834,14 @@ func TestBackfillingHistory(t *testing.T) {
834
834
)
835
835
batchSendResBody := client .ParseJSON (t , batchSendRes )
836
836
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 " )
838
838
baseInsertionEventID := client .GetJSONFieldStr (t , batchSendResBody , "base_insertion_event_id" )
839
839
840
840
// Send the marker event
841
841
markerEventID := sendMarkerAndEnsureBackfilled (t , as , alice , roomID , baseInsertionEventID )
842
842
843
843
redactEventID (t , alice , roomID , insertionEventID , 403 )
844
- redactEventID (t , alice , roomID , chunkEventID , 403 )
844
+ redactEventID (t , alice , roomID , batchEventID , 403 )
845
845
redactEventID (t , alice , roomID , markerEventID , 403 )
846
846
})
847
847
})
@@ -914,7 +914,7 @@ func fetchUntilMessagesResponseHas(t *testing.T, c *client.CSAPI, roomID string,
914
914
func isRelevantEvent (r gjson.Result ) bool {
915
915
return len (r .Get ("content" ).Get ("body" ).Str ) > 0 ||
916
916
r .Get ("type" ).Str == insertionEventType ||
917
- r .Get ("type" ).Str == chunkEventType ||
917
+ r .Get ("type" ).Str == batchEventType ||
918
918
r .Get ("type" ).Str == markerEventType
919
919
}
920
920
@@ -1088,7 +1088,7 @@ func createMessageEventsForBackfillRequest(
1088
1088
"origin_server_ts" : insertOriginServerTs + (timeBetweenMessagesMS * uint64 (i )),
1089
1089
"content" : map [string ]interface {}{
1090
1090
"msgtype" : "m.text" ,
1091
- "body" : fmt .Sprintf ("Historical %d (chunk =%d)" , i , chunkCount ),
1091
+ "body" : fmt .Sprintf ("Historical %d (batch =%d)" , i , batchCount ),
1092
1092
historicalContentField : true ,
1093
1093
},
1094
1094
}
@@ -1119,14 +1119,14 @@ func redactEventID(t *testing.T, c *client.CSAPI, roomID, eventID string, expect
1119
1119
}
1120
1120
}
1121
1121
1122
- var chunkCount int64 = 0
1122
+ var batchCount int64 = 0
1123
1123
1124
1124
func batchSendHistoricalMessages (
1125
1125
t * testing.T ,
1126
1126
c * client.CSAPI ,
1127
1127
roomID string ,
1128
1128
insertAfterEventId string ,
1129
- chunkID string ,
1129
+ batchID string ,
1130
1130
stateEventsAtStart []map [string ]interface {},
1131
1131
events []map [string ]interface {},
1132
1132
expectedStatus int ,
@@ -1135,9 +1135,9 @@ func batchSendHistoricalMessages(
1135
1135
1136
1136
query := make (url.Values , 2 )
1137
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 )
1138
+ // If provided, connect the batch to the last insertion point
1139
+ if batchID != "" {
1140
+ query .Add ("batch_id " , batchID )
1141
1141
}
1142
1142
1143
1143
res = c .DoFunc (
@@ -1156,7 +1156,7 @@ func batchSendHistoricalMessages(
1156
1156
t .Fatalf ("msc2716.batchSendHistoricalMessages got %d HTTP status code from batch send response but want %d" , res .StatusCode , expectedStatus )
1157
1157
}
1158
1158
1159
- chunkCount ++
1159
+ batchCount ++
1160
1160
1161
1161
return res
1162
1162
}
0 commit comments