Ensure store waku calls returns messages in chronological order

Oldest at the start of the list.
This commit is contained in:
Franck Royer 2021-04-13 14:58:21 +10:00
parent 433f0432b3
commit 0e9b0b1b74
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 9 additions and 12 deletions

View File

@ -14,7 +14,7 @@ export class HistoryRPC {
const pagingInfo = { const pagingInfo = {
pageSize: 10, pageSize: 10,
cursor, cursor,
direction: proto.Direction.DIRECTION_BACKWARD_UNSPECIFIED, direction: proto.Direction.DIRECTION_FORWARD,
}; };
return new HistoryRPC({ return new HistoryRPC({
requestId: uuid(), requestId: uuid(),

View File

@ -63,7 +63,7 @@ describe('Waku Store', () => {
expect(result).to.not.eq(-1); 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); this.timeout(5_000);
for (let i = 0; i < 15; i++) { for (let i = 0; i < 15; i++) {
@ -80,15 +80,12 @@ describe('Waku Store', () => {
const messages = await waku.store.queryHistory(nimPeerId); const messages = await waku.store.queryHistory(nimPeerId);
expect(messages?.length).eq(15); expect(messages?.length).eq(15);
for (let index = 0; index < 2; index++) {
expect( expect(
messages?.findIndex((msg) => { messages?.findIndex((msg) => {
return msg.utf8Payload() === 'Message 0'; return msg.utf8Payload() === `Message ${index}`;
}) })
).to.not.eq(-1); ).to.eq(index);
expect( }
messages?.findIndex((msg) => {
return msg.utf8Payload() === 'Message 14';
})
).to.not.eq(-1);
}); });
}); });