@@ -213,10 +213,20 @@ func TestJumpToDateEndpoint(t *testing.T) {
213213 mustCheckEventisReturnedForTime (t , remoteCharlie , roomID , eventB .AfterTimestamp , "b" , eventB .EventID )
214214
215215 // Get a pagination token from eventB
216- contextRes := remoteCharlie .MustDo (t , "GET" , []string {"_matrix" , "client" , "r0" , "rooms" , roomID , "context" , eventB .EventID }, client .WithContentType ("application/json" ), client .WithQueries (url.Values {
217- "limit" : []string {"0" },
218- }))
216+ contextRes := remoteCharlie .MustDo (t , "GET" , []string {"_matrix" , "client" , "r0" , "rooms" , roomID , "context" , eventB .EventID },
217+ client .WithContentType ("application/json" ), client .WithQueries (url.Values {
218+ "limit" : []string {"0" },
219+ }),
220+ )
219221 contextResResBody := client .ParseJSON (t , contextRes )
222+ // Remember: Tokens are positions between events. Normally, you would use the
223+ // `start` token to paginate backwards with but for the sake of the test we want
224+ // to paginate `/messages` and want see both A and B in the response; so we use
225+ // the `end` token. The `end` token comes after B.
226+ //
227+ // start end
228+ // | |
229+ // [A] <-- ▼ [B] ▼ <--- [remoteCharlie join]
220230 paginationToken := client .GetJSONFieldStr (t , contextResResBody , "end" )
221231
222232 // Hit `/messages` until `eventA` has been backfilled and replicated across
@@ -226,12 +236,15 @@ func TestJumpToDateEndpoint(t *testing.T) {
226236 return ev .Get ("event_id" ).Str == eventA .EventID
227237 })
228238
229- // Paginate backwards from eventB
230- messagesRes := remoteCharlie .MustDo (t , "GET" , []string {"_matrix" , "client" , "r0" , "rooms" , roomID , "messages" }, client .WithContentType ("application/json" ), client .WithQueries (url.Values {
231- "dir" : []string {"b" },
232- "limit" : []string {"100" },
233- "from" : []string {paginationToken },
234- }))
239+ // Paginate backwards from the point after eventB
240+ messagesRes := remoteCharlie .MustDo (t , "GET" , []string {"_matrix" , "client" , "r0" , "rooms" , roomID , "messages" },
241+ client .WithContentType ("application/json" ),
242+ client .WithQueries (url.Values {
243+ "dir" : []string {"b" },
244+ "limit" : []string {"100" },
245+ "from" : []string {paginationToken },
246+ }),
247+ )
235248
236249 // Make sure both messages are visible
237250 must .MatchResponse (t , messagesRes , match.HTTPResponse {
0 commit comments