test: fail on unhandled rejections and uncaught exceptions

This commit is contained in:
fryorcraken.eth 2023-09-20 15:12:32 +10:00
parent 3acc4fc86f
commit 4a9360d4e3
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 40 additions and 1 deletions

View File

@ -12,7 +12,11 @@ import {
createEncoder, createEncoder,
generateSymmetricKey generateSymmetricKey
} from "@waku/message-encryption/symmetric"; } from "@waku/message-encryption/symmetric";
import { createLightNode, createRelayNode } from "@waku/sdk"; import {
createLightNode,
createEncoder as createPlainEncoder,
createRelayNode
} from "@waku/sdk";
import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes"; import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai"; import { expect } from "chai";
@ -25,6 +29,8 @@ import {
const TestContentTopic = "/test/1/waku/utf8"; const TestContentTopic = "/test/1/waku/utf8";
const TestEncoder = createPlainEncoder({ contentTopic: TestContentTopic });
describe("Waku Dial [node only]", function () { describe("Waku Dial [node only]", function () {
describe("Interop: NimGoNode", function () { describe("Interop: NimGoNode", function () {
let waku: Waku; let waku: Waku;
@ -60,6 +66,39 @@ describe("Waku Dial [node only]", function () {
const nimPeerId = await nwaku.getPeerId(); const nimPeerId = await nwaku.getPeerId();
expect(await waku.libp2p.peerStore.has(nimPeerId)).to.be.true; expect(await waku.libp2p.peerStore.has(nimPeerId)).to.be.true;
}); });
it("Does not throw an exception when node disconnects", async function () {
this.timeout(20_000);
process.on("unhandledRejection", (e) =>
expect.fail("unhandledRejection", e)
);
process.on("uncaughtException", (e) =>
expect.fail("uncaughtException", e)
);
nwaku = new NimGoNode(makeLogFileName(this));
await nwaku.start({
filter: true,
store: true,
lightpush: true
});
const multiAddrWithId = await nwaku.getMultiaddrWithId();
waku = await createLightNode({
staticNoiseKey: NOISE_KEY_1
});
await waku.start();
await waku.dial(multiAddrWithId);
await nwaku.stop();
try {
await waku.lightPush?.send(TestEncoder, {
payload: utf8ToBytes("hello world")
});
} catch (e) {
// We are not checking this exception
}
});
}); });
describe("Bootstrap", function () { describe("Bootstrap", function () {