mirror of https://github.com/waku-org/js-waku.git
Ensure store waku calls returns messages in chronological order
Oldest at the start of the list.
This commit is contained in:
parent
433f0432b3
commit
0e9b0b1b74
|
@ -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(),
|
||||||
|
|
|
@ -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);
|
||||||
expect(
|
for (let index = 0; index < 2; index++) {
|
||||||
messages?.findIndex((msg) => {
|
expect(
|
||||||
return msg.utf8Payload() === 'Message 0';
|
messages?.findIndex((msg) => {
|
||||||
})
|
return msg.utf8Payload() === `Message ${index}`;
|
||||||
).to.not.eq(-1);
|
})
|
||||||
expect(
|
).to.eq(index);
|
||||||
messages?.findIndex((msg) => {
|
}
|
||||||
return msg.utf8Payload() === 'Message 14';
|
|
||||||
})
|
|
||||||
).to.not.eq(-1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue