From bbd3f61bc454fb7bff59f5e988999487b6abf6c0 Mon Sep 17 00:00:00 2001 From: fbarbu15 Date: Thu, 21 Sep 2023 11:29:27 +0300 Subject: [PATCH 1/2] increase timeout and use tearDownNodes --- packages/tests/tests/utils.spec.ts | 17 +++++++++-------- packages/tests/tests/waku.node.spec.ts | 11 ++++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/tests/tests/utils.spec.ts b/packages/tests/tests/utils.spec.ts index fc31cbc8a1..fa97efeaa7 100644 --- a/packages/tests/tests/utils.spec.ts +++ b/packages/tests/tests/utils.spec.ts @@ -17,7 +17,12 @@ import chai, { expect } from "chai"; import chaiAsPromised from "chai-as-promised"; import sinon from "sinon"; -import { delay, makeLogFileName, NOISE_KEY_1 } from "../src/index.js"; +import { + delay, + makeLogFileName, + NOISE_KEY_1, + tearDownNodes +} from "../src/index.js"; import { NimGoNode } from "../src/node/node.js"; chai.use(chaiAsPromised); @@ -43,13 +48,9 @@ describe("Util: toAsyncIterator: Filter", () => { await waitForRemotePeer(waku, [Protocols.Filter, Protocols.LightPush]); }); - afterEach(async () => { - try { - await nwaku.stop(); - await waku.stop(); - } catch (err) { - console.log("Failed to stop", err); - } + afterEach(async function () { + this.timeout(10000); + tearDownNodes([nwaku], [waku]); }); it("creates an iterator", async function () { diff --git a/packages/tests/tests/waku.node.spec.ts b/packages/tests/tests/waku.node.spec.ts index ff5ba04796..839d680996 100644 --- a/packages/tests/tests/waku.node.spec.ts +++ b/packages/tests/tests/waku.node.spec.ts @@ -16,7 +16,12 @@ import { createLightNode, createRelayNode } from "@waku/sdk"; import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes"; import { expect } from "chai"; -import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2 } from "../src/index.js"; +import { + makeLogFileName, + NOISE_KEY_1, + NOISE_KEY_2, + tearDownNodes +} from "../src/index.js"; import { NimGoNode } from "../src/node/node.js"; const TestContentTopic = "/test/1/waku/utf8"; @@ -63,8 +68,8 @@ describe("Waku Dial [node only]", function () { let nwaku: NimGoNode; afterEach(async function () { - !!nwaku && (await nwaku.stop()); - !!waku && waku.stop().catch((e) => console.log("Waku failed to stop", e)); + this.timeout(10000); + tearDownNodes([nwaku], [waku]); }); it("Passing an array", async function () { From aa195a75ed57c5604b119755043e9244c70be462 Mon Sep 17 00:00:00 2001 From: fbarbu15 Date: Tue, 10 Oct 2023 10:18:01 +0300 Subject: [PATCH 2/2] fix unsubscribes test --- packages/tests/tests/utils.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/tests/tests/utils.spec.ts b/packages/tests/tests/utils.spec.ts index 45f814a71e..89c77ebd8a 100644 --- a/packages/tests/tests/utils.spec.ts +++ b/packages/tests/tests/utils.spec.ts @@ -100,6 +100,8 @@ describe("Util: toAsyncIterator: Filter", () => { payload: utf8ToBytes("This should be received") }); + await delay(400); + await stop(); await waku.lightPush.send(TestEncoder, {