mirror of https://github.com/status-im/js-waku.git
test: fail on unhandled rejections and uncaught exceptions
This commit is contained in:
parent
3acc4fc86f
commit
4a9360d4e3
|
@ -12,7 +12,11 @@ import {
|
|||
createEncoder,
|
||||
generateSymmetricKey
|
||||
} 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 { expect } from "chai";
|
||||
|
||||
|
@ -25,6 +29,8 @@ import {
|
|||
|
||||
const TestContentTopic = "/test/1/waku/utf8";
|
||||
|
||||
const TestEncoder = createPlainEncoder({ contentTopic: TestContentTopic });
|
||||
|
||||
describe("Waku Dial [node only]", function () {
|
||||
describe("Interop: NimGoNode", function () {
|
||||
let waku: Waku;
|
||||
|
@ -60,6 +66,39 @@ describe("Waku Dial [node only]", function () {
|
|||
const nimPeerId = await nwaku.getPeerId();
|
||||
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 () {
|
||||
|
|
Loading…
Reference in New Issue