mirror of
https://github.com/logos-messaging/logos-delivery-js.git
synced 2026-08-02 10:33:14 +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
99 lines
2.3 KiB
TypeScript
99 lines
2.3 KiB
TypeScript
import type { LightNode } from "@waku/interfaces";
|
|
import { expect } from "chai";
|
|
|
|
import {
|
|
afterEachCustom,
|
|
beforeEachCustom,
|
|
ServiceNode,
|
|
tearDownNodes
|
|
} from "../../src/index.js";
|
|
|
|
import {
|
|
runStoreNodes,
|
|
sendMessages,
|
|
TestDecoder,
|
|
TestShardInfo
|
|
} from "./utils.js";
|
|
|
|
describe("Waku Store, page size", 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);
|
|
});
|
|
|
|
[
|
|
[0, 110],
|
|
[1, 4],
|
|
[3, 20],
|
|
[10, 10],
|
|
[11, 10],
|
|
[19, 20],
|
|
[110, 120]
|
|
].forEach(([pageSize, messageCount]) => {
|
|
it(`Passing page size ${pageSize} when there are ${messageCount} messages`, async function () {
|
|
await sendMessages(
|
|
nwaku,
|
|
messageCount,
|
|
TestDecoder.contentTopic,
|
|
TestDecoder.pubsubTopic
|
|
);
|
|
|
|
// Determine effectivePageSize for test expectations
|
|
let effectivePageSize = pageSize;
|
|
if (pageSize === 0) {
|
|
effectivePageSize = 20;
|
|
} else if (pageSize > 100) {
|
|
effectivePageSize = 100;
|
|
}
|
|
|
|
let messagesRetrieved = 0;
|
|
for await (const query of waku.store.queryGenerator([TestDecoder], {
|
|
paginationLimit: pageSize
|
|
})) {
|
|
// Calculate expected page size
|
|
const expectedPageSize = Math.min(
|
|
effectivePageSize,
|
|
messageCount - messagesRetrieved
|
|
);
|
|
expect(query.length).eq(expectedPageSize);
|
|
|
|
for await (const msg of query) {
|
|
if (msg) {
|
|
messagesRetrieved++;
|
|
}
|
|
}
|
|
}
|
|
|
|
expect(messagesRetrieved).eq(messageCount);
|
|
});
|
|
});
|
|
|
|
// Possible issue here because pageSize differs across implementations
|
|
it("Default pageSize", async function () {
|
|
await sendMessages(
|
|
nwaku,
|
|
20,
|
|
TestDecoder.contentTopic,
|
|
TestDecoder.pubsubTopic
|
|
);
|
|
|
|
let messagesRetrieved = 0;
|
|
for await (const query of waku.store.queryGenerator([TestDecoder])) {
|
|
expect(query.length).eq(20);
|
|
for await (const msg of query) {
|
|
if (msg) {
|
|
messagesRetrieved++;
|
|
}
|
|
}
|
|
}
|
|
expect(messagesRetrieved).eq(20);
|
|
});
|
|
});
|