diff --git a/src/lib/waku_store/history_rpc.ts b/src/lib/waku_store/history_rpc.ts index 5985434328..ff4a8ede4f 100644 --- a/src/lib/waku_store/history_rpc.ts +++ b/src/lib/waku_store/history_rpc.ts @@ -14,7 +14,7 @@ export class HistoryRPC { const pagingInfo = { pageSize: 10, cursor, - direction: proto.Direction.DIRECTION_BACKWARD_UNSPECIFIED, + direction: proto.Direction.DIRECTION_FORWARD, }; return new HistoryRPC({ requestId: uuid(), diff --git a/src/lib/waku_store/index.spec.ts b/src/lib/waku_store/index.spec.ts index 5319f48226..ccc21a89ac 100644 --- a/src/lib/waku_store/index.spec.ts +++ b/src/lib/waku_store/index.spec.ts @@ -63,7 +63,7 @@ describe('Waku Store', () => { expect(result).to.not.eq(-1); }); - it('Retrieves all history element through paging', async function () { + it('Retrieves all historical elements in chronological order through paging', async function () { this.timeout(5_000); for (let i = 0; i < 15; i++) { @@ -80,15 +80,12 @@ describe('Waku Store', () => { const messages = await waku.store.queryHistory(nimPeerId); expect(messages?.length).eq(15); - expect( - messages?.findIndex((msg) => { - return msg.utf8Payload() === 'Message 0'; - }) - ).to.not.eq(-1); - expect( - messages?.findIndex((msg) => { - return msg.utf8Payload() === 'Message 14'; - }) - ).to.not.eq(-1); + for (let index = 0; index < 2; index++) { + expect( + messages?.findIndex((msg) => { + return msg.utf8Payload() === `Message ${index}`; + }) + ).to.eq(index); + } }); });