From 4b7cb6da9e088096c3145aca454286b0b9e8fe2f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 23 Sep 2021 10:10:22 +0200 Subject: [PATCH] make backfill limit explicit --- src/matrix/room/timeline/persistence/GapWriter.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/matrix/room/timeline/persistence/GapWriter.js b/src/matrix/room/timeline/persistence/GapWriter.js index d2f93e21..5757370e 100644 --- a/src/matrix/room/timeline/persistence/GapWriter.js +++ b/src/matrix/room/timeline/persistence/GapWriter.js @@ -312,9 +312,9 @@ export function tests() { }; } - async function backfillAndWrite(mocks, fragmentEntry) { + async function backfillAndWrite(mocks, fragmentEntry, limit) { const {txn, timelineMock, gapWriter} = mocks; - const messageResponse = timelineMock.messages(fragmentEntry.token, undefined, fragmentEntry.direction.asApiString()); + const messageResponse = timelineMock.messages(fragmentEntry.token, undefined, fragmentEntry.direction.asApiString(), limit); await gapWriter.writeFragmentFill(fragmentEntry, messageResponse, txn, logger); } @@ -348,7 +348,7 @@ export function tests() { const { timelineMock } = mocks; timelineMock.append(30); const {fragmentEntry} = await syncAndWrite(mocks); - await backfillAndWrite(mocks, fragmentEntry); + await backfillAndWrite(mocks, fragmentEntry, 10); const events = await allFragmentEvents(mocks, fragmentEntry.fragmentId); assert.deepEqual(events.map(e => e.event_id), eventIds(10, 30)); await mocks.txn.complete(); @@ -360,7 +360,7 @@ export function tests() { const {syncResponse, fragmentEntry: firstFragmentEntry} = await syncAndWrite(mocks, { limit: 10 }); timelineMock.append(15); const {fragmentEntry: secondFragmentEntry} = await syncAndWrite(mocks, { previous: syncResponse, limit: 10 }); - await backfillAndWrite(mocks, secondFragmentEntry); + await backfillAndWrite(mocks, secondFragmentEntry, 10); const firstFragment = await fetchFragment(mocks, firstFragmentEntry.fragmentId); const secondFragment = await fetchFragment(mocks, secondFragmentEntry.fragmentId); @@ -378,7 +378,7 @@ export function tests() { const {syncResponse, fragmentEntry: firstFragmentEntry} = await syncAndWrite(mocks, { limit: 10 }); timelineMock.append(20); const {fragmentEntry: secondFragmentEntry} = await syncAndWrite(mocks, { previous: syncResponse, limit: 10 }); - await backfillAndWrite(mocks, secondFragmentEntry); + await backfillAndWrite(mocks, secondFragmentEntry, 10); const firstFragment = await fetchFragment(mocks, firstFragmentEntry.fragmentId); const secondFragment = await fetchFragment(mocks, secondFragmentEntry.fragmentId); @@ -397,7 +397,7 @@ export function tests() { // Mess with the saved token to receive old events in backfill fragmentEntry.token = syncResponse.next_batch; txn.timelineFragments.update(fragmentEntry.fragment); - await backfillAndWrite(mocks, fragmentEntry); + await backfillAndWrite(mocks, fragmentEntry, 10); const fragment = await fetchFragment(mocks, fragmentEntry.fragmentId); assert.notEqual(fragment.nextId, fragment.id); @@ -412,7 +412,7 @@ export function tests() { timelineMock.append(11); const {fragmentEntry: secondFragmentEntry} = await syncAndWrite(mocks, { previous: syncResponse, limit: 10 }); timelineMock.insertAfter(eventId(9), 5); - await backfillAndWrite(mocks, secondFragmentEntry); + await backfillAndWrite(mocks, secondFragmentEntry, 10); const firstEvents = await allFragmentEvents(mocks, firstFragmentEntry.fragmentId); assert.deepEqual(firstEvents.map(e => e.event_id), eventIds(0, 10));