mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-25 10:35:51 +00:00
test: do not run two set of nodes
`runNodes` was called twice for custom pubsub test.
This commit is contained in:
parent
3b1f0adb43
commit
fff5d66d2f
@ -23,34 +23,36 @@ const TestEncoder = createEncoder({
|
|||||||
contentTopic: TestContentTopic,
|
contentTopic: TestContentTopic,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function runNodes(
|
||||||
|
context: Mocha.Context,
|
||||||
|
pubSubTopic?: string
|
||||||
|
): Promise<[NimGoNode, LightNode]> {
|
||||||
|
const nwakuOptional = pubSubTopic ? { topics: pubSubTopic } : {};
|
||||||
|
const nwaku = new NimGoNode(makeLogFileName(context));
|
||||||
|
await nwaku.start({
|
||||||
|
lightpush: true,
|
||||||
|
relay: true,
|
||||||
|
...nwakuOptional,
|
||||||
|
});
|
||||||
|
|
||||||
|
const waku = await createLightNode({
|
||||||
|
pubSubTopic,
|
||||||
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
|
});
|
||||||
|
await waku.start();
|
||||||
|
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
|
await waitForRemotePeer(waku, [Protocols.LightPush]);
|
||||||
|
|
||||||
|
return [nwaku, waku];
|
||||||
|
}
|
||||||
|
|
||||||
describe("Waku Light Push [node only]", () => {
|
describe("Waku Light Push [node only]", () => {
|
||||||
let waku: LightNode;
|
let waku: LightNode;
|
||||||
let nwaku: NimGoNode;
|
let nwaku: NimGoNode;
|
||||||
|
|
||||||
const runNodes = async (
|
|
||||||
context: Mocha.Context,
|
|
||||||
pubSubTopic?: string
|
|
||||||
): Promise<void> => {
|
|
||||||
const nwakuOptional = pubSubTopic ? { topics: pubSubTopic } : {};
|
|
||||||
nwaku = new NimGoNode(makeLogFileName(context));
|
|
||||||
await nwaku.start({
|
|
||||||
lightpush: true,
|
|
||||||
relay: true,
|
|
||||||
...nwakuOptional,
|
|
||||||
});
|
|
||||||
|
|
||||||
waku = await createLightNode({
|
|
||||||
pubSubTopic,
|
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
|
||||||
});
|
|
||||||
await waku.start();
|
|
||||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
|
||||||
await waitForRemotePeer(waku, [Protocols.LightPush]);
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.timeout(15_000);
|
this.timeout(15_000);
|
||||||
await runNodes(this);
|
[nwaku, waku] = await runNodes(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async function () {
|
afterEach(async function () {
|
||||||
@ -108,12 +110,29 @@ describe("Waku Light Push [node only]", () => {
|
|||||||
expect(pushResponse.recipients.length).to.eq(0);
|
expect(pushResponse.recipients.length).to.eq(0);
|
||||||
expect(pushResponse.error).to.eq(SendError.SIZE_TOO_BIG);
|
expect(pushResponse.error).to.eq(SendError.SIZE_TOO_BIG);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("Push on custom pubsub topic", async function () {
|
describe("Waku Light Push [node only] - custom pubsub topic", () => {
|
||||||
|
let waku: LightNode;
|
||||||
|
let nwaku: NimGoNode;
|
||||||
|
const customPubSubTopic = "/waku/2/custom-dapp/proto";
|
||||||
|
|
||||||
|
beforeEach(async function () {
|
||||||
this.timeout(15_000);
|
this.timeout(15_000);
|
||||||
|
[nwaku, waku] = await runNodes(this, customPubSubTopic);
|
||||||
|
});
|
||||||
|
|
||||||
const customPubSubTopic = "/waku/2/custom-dapp/proto";
|
afterEach(async function () {
|
||||||
await runNodes(this, customPubSubTopic);
|
try {
|
||||||
|
nwaku?.stop();
|
||||||
|
waku?.stop();
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to stop nodes: ", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Push message", async function () {
|
||||||
|
this.timeout(15_000);
|
||||||
|
|
||||||
const nimPeerId = await nwaku.getPeerId();
|
const nimPeerId = await nwaku.getPeerId();
|
||||||
const messageText = "Light Push works!";
|
const messageText = "Light Push works!";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user