mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-10 01:33:13 +00:00
* remove public pubsub field and redundant util * add hangUp and improve dial operations, improve keepAliveManager and remove unused method, move utils and add tests * improve public dial method to start keep alive checks * move dial method * implement discovery dialer * implement discovery dialer with queue with tests * add discovery dialer e2e tests, change local discovery log tag, update other tests * remove comment * add issue link, remove only * implement shard reader component * create evetns module, remove unused connection manager events and related tests * implement network indicator * implement connection limiter, change public API of connection manager, implement recovery strategy * decouple keep alive maanger * add connection manager js-doc * refactor keep alive manager, cover with tests * add tests for connection manager main facade * add tests for connection limiter * add e2e tests for connection manager modules pass js-waku config during test node init remove dns discovery for js-waku * restructure dialing tests * address last e2e tests * address review * add logging for main methods * decouple pure dialer class, update network monitor with specific metrics * remove console.log * remove usage of protocols * update sdk package tests * add connect await promise * add debug for e2e tests * enable only packages tests * use only one file * revert debugging * up interface for netwrok manager * add logs * add more logs * add more logs * add another logs * remove .only * remove log statements * skip the test with follow up
226 lines
6.1 KiB
TypeScript
226 lines
6.1 KiB
TypeScript
import { createDecoder } from "@waku/core";
|
|
import { IMessage, type LightNode } from "@waku/interfaces";
|
|
import { determinePubsubTopic } from "@waku/utils";
|
|
import { expect } from "chai";
|
|
|
|
import {
|
|
afterEachCustom,
|
|
beforeEachCustom,
|
|
ServiceNode,
|
|
tearDownNodes
|
|
} from "../../src/index.js";
|
|
|
|
import {
|
|
processQueriedMessages,
|
|
runStoreNodes,
|
|
TestContentTopic1,
|
|
TestDecoder,
|
|
TestDecoder2,
|
|
TestShardInfo
|
|
} from "./utils.js";
|
|
|
|
describe("Waku Store, error handling", 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);
|
|
});
|
|
|
|
it("Query Generator, Wrong PubsubTopic", async function () {
|
|
const wrongDecoder = createDecoder(TestContentTopic1, "WrongPubsubTopic");
|
|
|
|
try {
|
|
for await (const msgPromises of waku.store.queryGenerator([
|
|
wrongDecoder
|
|
])) {
|
|
void msgPromises;
|
|
}
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes(
|
|
`Pubsub topic ${wrongDecoder.pubsubTopic} has not been configured on this instance.`
|
|
)
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query Generator, Multiple PubsubTopics", async function () {
|
|
try {
|
|
for await (const msgPromises of waku.store.queryGenerator([
|
|
TestDecoder,
|
|
TestDecoder2
|
|
])) {
|
|
void msgPromises;
|
|
}
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes(
|
|
"API does not support querying multiple pubsub topics at once"
|
|
)
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query Generator, No Decoder", async function () {
|
|
try {
|
|
for await (const msgPromises of waku.store.queryGenerator([])) {
|
|
void msgPromises;
|
|
}
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes("No decoders provided")
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query Generator, No message returned", async function () {
|
|
const WrongTestPubsubTopic = determinePubsubTopic("/test/1/wrong/utf8");
|
|
const messages = await processQueriedMessages(
|
|
waku,
|
|
[TestDecoder],
|
|
WrongTestPubsubTopic
|
|
);
|
|
expect(messages?.length).eq(0);
|
|
});
|
|
|
|
it("Query with Ordered Callback, Wrong PubsubTopic", async function () {
|
|
const wrongDecoder = createDecoder(TestContentTopic1, "WrongPubsubTopic");
|
|
try {
|
|
await waku.store.queryWithOrderedCallback([wrongDecoder], async () => {});
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes(
|
|
`Pubsub topic ${wrongDecoder.pubsubTopic} has not been configured on this instance.`
|
|
)
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query with Ordered Callback, Multiple PubsubTopics", async function () {
|
|
try {
|
|
await waku.store.queryWithOrderedCallback(
|
|
[TestDecoder, TestDecoder2],
|
|
async () => {}
|
|
);
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes(
|
|
"API does not support querying multiple pubsub topics at once"
|
|
)
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query with Ordered Callback, No Decoder", async function () {
|
|
try {
|
|
await waku.store.queryWithOrderedCallback([], async () => {});
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes("No decoders provided")
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query with Ordered Callback, No message returned", async function () {
|
|
const messages: IMessage[] = [];
|
|
await waku.store.queryWithOrderedCallback([TestDecoder], async (msg) => {
|
|
messages.push(msg);
|
|
});
|
|
expect(messages?.length).eq(0);
|
|
});
|
|
|
|
it("Query with Promise Callback, Wrong PubsubTopic", async function () {
|
|
const wrongDecoder = createDecoder(TestContentTopic1, "WrongPubsubTopic");
|
|
try {
|
|
await waku.store.queryWithPromiseCallback([wrongDecoder], async () => {});
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes(
|
|
`Pubsub topic ${wrongDecoder.pubsubTopic} has not been configured on this instance.`
|
|
)
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query with Promise Callback, Multiple PubsubTopics", async function () {
|
|
try {
|
|
await waku.store.queryWithPromiseCallback(
|
|
[TestDecoder, TestDecoder2],
|
|
async () => {}
|
|
);
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes(
|
|
"API does not support querying multiple pubsub topics at once"
|
|
)
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query with Promise Callback, No Decoder", async function () {
|
|
try {
|
|
await waku.store.queryWithPromiseCallback([], async () => {});
|
|
throw new Error("QueryGenerator was successful but was expected to fail");
|
|
} catch (err) {
|
|
if (
|
|
!(err instanceof Error) ||
|
|
!err.message.includes("No decoders provided")
|
|
) {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
|
|
it("Query with Promise Callback, No message returned", async function () {
|
|
const messages: IMessage[] = [];
|
|
await waku.store.queryWithPromiseCallback(
|
|
[TestDecoder],
|
|
async (msgPromise) => {
|
|
const msg = await msgPromise;
|
|
if (msg) {
|
|
messages.push(msg);
|
|
}
|
|
}
|
|
);
|
|
expect(messages?.length).eq(0);
|
|
});
|
|
});
|