mirror of
https://github.com/logos-messaging/logos-delivery-js.git
synced 2026-03-09 19:23:18 +00:00
* feat: write proto * chore: move store v2 to a subdir * chore: update v3 proto * feat: create custom RPC * feat: implement storev3 core * chore: set store v3 as default * chore: move v2 related code * chore: update v2 imports * feat: add store-v3 sdk implementation * fix: rebase * chore: add ts-doc for store query request params * chore: update tests for new API * fix: use nanoseconds instead of millisecond for timerange * chore: improve store * chore: remove store v2 * chore: update tests * chore: fix legacy imports & proto * tests: remove manual reversal as its part of the API, update incorrect cursor error msg * chore: update default page size * chore: account for MAX_PAGE_SIZE from nwaku * fix: test * fix: sorting tests
118 lines
2.9 KiB
TypeScript
118 lines
2.9 KiB
TypeScript
import { DecodedMessage } from "@waku/core";
|
|
import type { IMessage, LightNode } from "@waku/interfaces";
|
|
import { expect } from "chai";
|
|
|
|
import {
|
|
afterEachCustom,
|
|
beforeEachCustom,
|
|
ServiceNode,
|
|
tearDownNodes
|
|
} from "../../src/index.js";
|
|
|
|
import {
|
|
runStoreNodes,
|
|
sendMessages,
|
|
TestDecoder,
|
|
TestShardInfo,
|
|
totalMsgs
|
|
} from "./utils.js";
|
|
|
|
describe("Waku Store, order", function () {
|
|
this.timeout(15000);
|
|
let waku: LightNode;
|
|
let nwaku: ServiceNode;
|
|
|
|
beforeEachCustom(this, async () => {
|
|
[nwaku, waku] = await runStoreNodes(this.ctx, TestShardInfo);
|
|
});
|
|
|
|
afterEachCustom(this, async () => {
|
|
await tearDownNodes(nwaku, waku);
|
|
});
|
|
|
|
[true, false].forEach((pageDirection) => {
|
|
it(`Query Generator - ${pageDirection}`, async function () {
|
|
await sendMessages(
|
|
nwaku,
|
|
totalMsgs,
|
|
TestDecoder.contentTopic,
|
|
TestDecoder.pubsubTopic
|
|
);
|
|
|
|
const messages: IMessage[] = [];
|
|
for await (const query of waku.store.queryGenerator([TestDecoder], {
|
|
paginationForward: pageDirection
|
|
})) {
|
|
for await (const msg of query) {
|
|
if (msg) {
|
|
messages.push(msg as DecodedMessage);
|
|
}
|
|
}
|
|
}
|
|
|
|
const expectedPayloads = Array.from(Array(totalMsgs).keys());
|
|
|
|
expect(messages?.length).eq(totalMsgs);
|
|
const payloads = messages.map((msg) => msg.payload[0]!);
|
|
expect(payloads).to.deep.eq(expectedPayloads);
|
|
});
|
|
});
|
|
|
|
[true, false].forEach((pageDirection) => {
|
|
it(`Promise Callback - ${pageDirection}`, async function () {
|
|
await sendMessages(
|
|
nwaku,
|
|
totalMsgs,
|
|
TestDecoder.contentTopic,
|
|
TestDecoder.pubsubTopic
|
|
);
|
|
|
|
const messages: IMessage[] = [];
|
|
await waku.store.queryWithPromiseCallback(
|
|
[TestDecoder],
|
|
async (msgPromise) => {
|
|
const msg = await msgPromise;
|
|
if (msg) {
|
|
messages.push(msg);
|
|
}
|
|
},
|
|
{
|
|
paginationForward: pageDirection
|
|
}
|
|
);
|
|
|
|
const expectedPayloads = Array.from(Array(totalMsgs).keys());
|
|
|
|
expect(messages?.length).eq(totalMsgs);
|
|
const payloads = messages.map((msg) => msg.payload[0]!);
|
|
expect(payloads).to.deep.eq(expectedPayloads);
|
|
});
|
|
});
|
|
|
|
[true, false].forEach((pageDirection) => {
|
|
it(`Ordered Callback - ${pageDirection}`, async function () {
|
|
await sendMessages(
|
|
nwaku,
|
|
totalMsgs,
|
|
TestDecoder.contentTopic,
|
|
TestDecoder.pubsubTopic
|
|
);
|
|
|
|
const messages: IMessage[] = [];
|
|
await waku.store.queryWithOrderedCallback(
|
|
[TestDecoder],
|
|
async (msg) => {
|
|
messages.push(msg);
|
|
},
|
|
{
|
|
paginationForward: pageDirection
|
|
}
|
|
);
|
|
|
|
expect(messages?.length).eq(totalMsgs);
|
|
const payloads = messages.map((msg) => msg.payload[0]!);
|
|
expect(payloads).to.deep.eq(Array.from(Array(totalMsgs).keys()));
|
|
});
|
|
});
|
|
});
|