chore: use graceful timeout mechanism (#1841)

* use graceful timeout mechanism

* set max timeout for all hooks

* small fix

* small fix

* use MOCHA_HOOK_MAX_TIMEOUT as default timeoutDuration

* force retry even when the hook fails

* use custom hooks

* fix global timeout problem

* fix unwanted change

* fix enr issue

* force retry on before error as well
This commit is contained in:
Florin Barbu 2024-02-15 08:50:03 +02:00 committed by GitHub
parent a9fb796a7b
commit de5be4413b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
47 changed files with 350 additions and 284 deletions

View File

@ -61,3 +61,5 @@ export const TEST_TIMESTAMPS = [
1949153314000,
undefined
];
export const MOCHA_HOOK_MAX_TIMEOUT = 50_000;

View File

@ -0,0 +1,68 @@
import { Logger } from "@waku/utils";
import { Suite } from "mocha";
import { MOCHA_HOOK_MAX_TIMEOUT } from "../constants";
const log = new Logger("test:mocha-hook");
function withGracefulTimeout(
asyncOperation: () => Promise<void>,
doneCallback: (error?: unknown) => void,
timeoutDuration: number = MOCHA_HOOK_MAX_TIMEOUT
): void {
let operationCompleted = false;
const wrapperOperation: () => Promise<void> = async () => {
try {
await asyncOperation();
if (!operationCompleted) {
operationCompleted = true;
log.info("Mocha hook completed successfully.");
doneCallback();
}
} catch (error) {
if (!operationCompleted) {
operationCompleted = true;
log.error(
"Mocha hook failed. Proceeding to the test so it can retry.",
error
);
doneCallback();
}
}
};
void wrapperOperation();
setTimeout(() => {
if (!operationCompleted) {
log.info(
"Custom timeout reached. Proceeding to the test so it can retry."
);
operationCompleted = true;
doneCallback();
}
}, timeoutDuration);
}
export const beforeEachCustom = function (
suite: Suite,
cb: () => Promise<void>
): void {
const timeoutBefore = suite.timeout();
suite.timeout(MOCHA_HOOK_MAX_TIMEOUT);
suite.beforeEach((done) => {
withGracefulTimeout(cb, done);
});
suite.timeout(timeoutBefore); // restore timeout to the original value
};
export const afterEachCustom = function (
suite: Suite,
cb: () => Promise<void>
): void {
const timeoutBefore = suite.timeout();
suite.timeout(MOCHA_HOOK_MAX_TIMEOUT);
suite.afterEach((done) => {
withGracefulTimeout(cb, done);
});
suite.timeout(timeoutBefore); // restore timeout to the original value
};

View File

@ -5,3 +5,4 @@ export * from "./wait_for_remote_peer_with_codec.js";
export * from "./delay.js";
export * from "./base64_utf8.js";
export * from "./waitForConnections.js";
export * from "./custom_mocha_hooks.js";

View File

@ -4,7 +4,12 @@ import { createLightNode } from "@waku/sdk";
import { createRelayNode } from "@waku/sdk/relay";
import { expect } from "chai";
import { delay, NOISE_KEY_1 } from "../../src/index.js";
import {
afterEachCustom,
beforeEachCustom,
delay,
NOISE_KEY_1
} from "../../src/index.js";
import {
makeLogFileName,
ServiceNode,
@ -22,8 +27,7 @@ describe("Connection state", function () {
let nwaku1PeerId: Multiaddr;
let nwaku2PeerId: Multiaddr;
beforeEach(async () => {
this.timeout(TEST_TIMEOUT);
beforeEachCustom(this, async () => {
waku = await createLightNode({ shardInfo: { shards: [0] } });
nwaku1 = new ServiceNode(makeLogFileName(this.ctx) + "1");
nwaku2 = new ServiceNode(makeLogFileName(this.ctx) + "2");
@ -33,8 +37,7 @@ describe("Connection state", function () {
nwaku2PeerId = await nwaku2.getMultiaddrWithId();
});
afterEach(async () => {
this.timeout(TEST_TIMEOUT);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku1, nwaku2], waku);
});

View File

@ -6,7 +6,7 @@ import { createLightNode } from "@waku/sdk";
import { expect } from "chai";
import sinon, { SinonSpy, SinonStub } from "sinon";
import { delay } from "../../src/index.js";
import { afterEachCustom, beforeEachCustom, delay } from "../../src/index.js";
import { tearDownNodes } from "../../src/index.js";
const DELAY_MS = 1_000;
@ -20,8 +20,7 @@ describe("Dials", function () {
let isPeerTopicConfigured: SinonStub;
let waku: LightNode;
this.beforeEach(async function () {
this.timeout(TEST_TIMEOUT);
beforeEachCustom(this, async () => {
waku = await createLightNode({ shardInfo: { shards: [0] } });
isPeerTopicConfigured = sinon.stub(
waku.connectionManager as any,
@ -30,8 +29,7 @@ describe("Dials", function () {
isPeerTopicConfigured.resolves(true);
});
afterEach(async () => {
this.timeout(TEST_TIMEOUT);
afterEachCustom(this, async () => {
await tearDownNodes([], waku);
isPeerTopicConfigured.restore();
sinon.restore();
@ -40,11 +38,11 @@ describe("Dials", function () {
describe("attemptDial method", function () {
let attemptDialSpy: SinonSpy;
beforeEach(function () {
beforeEachCustom(this, async () => {
attemptDialSpy = sinon.spy(waku.connectionManager as any, "attemptDial");
});
afterEach(function () {
afterEachCustom(this, async () => {
attemptDialSpy.restore();
});
@ -73,7 +71,7 @@ describe("Dials", function () {
describe("dialPeer method", function () {
let peerStoreHasStub: SinonStub;
let dialAttemptsForPeerHasStub: SinonStub;
beforeEach(function () {
beforeEachCustom(this, async () => {
getConnectionsStub = sinon.stub(
(waku.connectionManager as any).libp2p,
"getConnections"
@ -102,7 +100,7 @@ describe("Dials", function () {
dialAttemptsForPeerHasStub.returns(false);
});
afterEach(function () {
afterEachCustom(this, async () => {
dialPeerStub.restore();
getTagNamesForPeerStub.restore();
getConnectionsStub.restore();

View File

@ -10,7 +10,7 @@ import {
import { createLightNode } from "@waku/sdk";
import { expect } from "chai";
import { delay } from "../../src/index.js";
import { afterEachCustom, beforeEachCustom, delay } from "../../src/index.js";
import { tearDownNodes } from "../../src/index.js";
const TEST_TIMEOUT = 20_000;
@ -18,13 +18,11 @@ const TEST_TIMEOUT = 20_000;
describe("Events", function () {
let waku: LightNode;
this.timeout(TEST_TIMEOUT);
beforeEach(async function () {
this.timeout(TEST_TIMEOUT);
beforeEachCustom(this, async () => {
waku = await createLightNode({ shardInfo: { shards: [0] } });
});
afterEach(async () => {
this.timeout(TEST_TIMEOUT);
afterEachCustom(this, async () => {
await tearDownNodes([], waku);
});

View File

@ -10,7 +10,7 @@ import {
import { createLightNode } from "@waku/sdk";
import { expect } from "chai";
import { delay } from "../../src/index.js";
import { afterEachCustom, beforeEachCustom, delay } from "../../src/index.js";
import { tearDownNodes } from "../../src/index.js";
const TEST_TIMEOUT = 20_000;
@ -18,13 +18,11 @@ const TEST_TIMEOUT = 20_000;
describe("Public methods", function () {
let waku: LightNode;
this.timeout(TEST_TIMEOUT);
beforeEach(async function () {
this.timeout(TEST_TIMEOUT);
beforeEachCustom(this, async () => {
waku = await createLightNode({ shardInfo: { shards: [0] } });
});
afterEach(async () => {
this.timeout(TEST_TIMEOUT);
afterEachCustom(this, async () => {
await tearDownNodes([], waku);
});
it("addEventListener with correct event", async function () {

View File

@ -2,17 +2,21 @@ import { createLightNode, LightNode } from "@waku/sdk";
import { expect } from "chai";
import sinon, { SinonSpy } from "sinon";
import { tearDownNodes } from "../src/index.js";
import {
afterEachCustom,
beforeEachCustom,
tearDownNodes
} from "../src/index.js";
describe("Create node", () => {
describe("Create node", function () {
let waku: LightNode;
let consoleInfoSpy: SinonSpy;
beforeEach(() => {
beforeEachCustom(this, async () => {
consoleInfoSpy = sinon.spy(console as any, "info");
});
afterEach(async () => {
afterEachCustom(this, async () => {
consoleInfoSpy.restore();
sinon.restore();
await tearDownNodes([], waku);

View File

@ -6,6 +6,7 @@ import { createRelayNode } from "@waku/sdk/relay";
import { expect } from "chai";
import {
afterEachCustom,
makeLogFileName,
NOISE_KEY_1,
ServiceNode,
@ -16,8 +17,7 @@ describe("ENR Interop: ServiceNode", function () {
let waku: RelayNode;
let nwaku: ServiceNode;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -25,6 +25,8 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
delay,
makeLogFileName,
NOISE_KEY_1,
@ -41,20 +43,18 @@ const TestEncoder = createEncoder({
});
const TestDecoder = createDecoder(TestContentTopic);
describe("Waku Message Ephemeral field", () => {
describe("Waku Message Ephemeral field", function () {
let waku: LightNode;
let nwaku: ServiceNode;
let subscription: IFilterSubscription;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});
beforeEach(async function () {
this.timeout(15_000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({
filter: true,
lightpush: true,

View File

@ -6,7 +6,11 @@ import {
import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import { ServiceNodesFleet } from "../../src/index.js";
import {
afterEachCustom,
beforeEachCustom,
ServiceNodesFleet
} from "../../src/index.js";
import {
runMultipleNodes,
@ -25,14 +29,14 @@ const runTests = (strictCheckNodes: boolean): void => {
let serviceNodes: ServiceNodesFleet;
let subscription: IFilterSubscription;
this.beforeEach(async function () {
this.timeout(15000);
[serviceNodes, waku] = await runMultipleNodes(this, [DefaultPubsubTopic]);
beforeEachCustom(this, async () => {
[serviceNodes, waku] = await runMultipleNodes(this.ctx, [
DefaultPubsubTopic
]);
subscription = await waku.filter.createSubscription();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await teardownNodesWithRedundancy(serviceNodes, waku);
});

View File

@ -9,6 +9,8 @@ import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
delay,
ServiceNodesFleet,
TEST_STRING,
@ -32,14 +34,14 @@ const runTests = (strictCheckNodes: boolean): void => {
let serviceNodes: ServiceNodesFleet;
let subscription: IFilterSubscription;
this.beforeEach(async function () {
this.timeout(15000);
[serviceNodes, waku] = await runMultipleNodes(this, [DefaultPubsubTopic]);
beforeEachCustom(this, async () => {
[serviceNodes, waku] = await runMultipleNodes(this.ctx, [
DefaultPubsubTopic
]);
subscription = await waku.filter.createSubscription();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await teardownNodesWithRedundancy(serviceNodes, waku);
});

View File

@ -17,6 +17,8 @@ import { utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
MessageCollector,
ServiceNode,
@ -58,10 +60,9 @@ describe("Waku Filter V2: Multiple PubsubTopics", function () {
});
const customDecoder2 = createDecoder(customContentTopic2, singleShardInfo2);
this.beforeEach(async function () {
this.timeout(15000);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(
this,
this.ctx,
[customPubsubTopic1, customPubsubTopic2],
shardInfo
);
@ -71,8 +72,7 @@ describe("Waku Filter V2: Multiple PubsubTopics", function () {
messageCollector = new MessageCollector();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});
@ -229,10 +229,9 @@ describe("Waku Filter V2 (Autosharding): Multiple PubsubTopics", function () {
shard: contentTopicToShardIndex(customContentTopic2)
});
this.beforeEach(async function () {
this.timeout(15000);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(
this,
this.ctx,
[autoshardingPubsubTopic1, autoshardingPubsubTopic2],
contentTopicInfo
);
@ -242,8 +241,7 @@ describe("Waku Filter V2 (Autosharding): Multiple PubsubTopics", function () {
messageCollector = new MessageCollector();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});
@ -396,10 +394,9 @@ describe("Waku Filter V2 (Named sharding): Multiple PubsubTopics", function () {
});
const customDecoder2 = createDecoder(customContentTopic2, customPubsubTopic2);
this.beforeEach(async function () {
this.timeout(15000);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(
this,
this.ctx,
[customPubsubTopic1, customPubsubTopic2],
{
clusterId: 3,
@ -410,8 +407,7 @@ describe("Waku Filter V2 (Named sharding): Multiple PubsubTopics", function () {
messageCollector = new MessageCollector();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});

View File

@ -7,6 +7,8 @@ import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
MessageCollector,
ServiceNode,
tearDownNodes
@ -28,15 +30,13 @@ describe("Waku Filter V2: Ping", function () {
let subscription: IFilterSubscription;
let messageCollector: MessageCollector;
this.beforeEach(async function () {
this.timeout(15000);
[nwaku, waku] = await runNodes(this, [DefaultPubsubTopic]);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(this.ctx, [DefaultPubsubTopic]);
subscription = await waku.filter.createSubscription();
messageCollector = new MessageCollector();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -9,6 +9,8 @@ import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
delay,
MessageCollector,
ServiceNode,
@ -32,15 +34,13 @@ describe("Waku Filter V2: FilterPush", function () {
let subscription: IFilterSubscription;
let messageCollector: MessageCollector;
this.beforeEach(async function () {
this.timeout(15000);
[nwaku, waku] = await runNodes(this, [DefaultPubsubTopic]);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(this.ctx, [DefaultPubsubTopic]);
subscription = await waku.filter.createSubscription();
messageCollector = new MessageCollector();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -16,6 +16,8 @@ import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
delay,
generateTestData,
isNwakuAtLeast,
@ -44,18 +46,14 @@ describe("Waku Filter V2: Subscribe: Single Service Node", function () {
let subscription: IFilterSubscription;
let messageCollector: MessageCollector;
this.beforeEach(async function () {
this.timeout(15000);
[nwaku, waku] = await runNodes(this, [DefaultPubsubTopic]);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(this.ctx, [DefaultPubsubTopic]);
subscription = await waku.filter.createSubscription();
messageCollector = new MessageCollector();
// Nwaku subscribe to the default pubsub topic
await nwaku.ensureSubscriptions();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});

View File

@ -5,6 +5,8 @@ import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
generateTestData,
MessageCollector,
ServiceNode,
@ -27,9 +29,8 @@ describe("Waku Filter V2: Unsubscribe", function () {
let subscription: IFilterSubscription;
let messageCollector: MessageCollector;
this.beforeEach(async function () {
this.timeout(15000);
[nwaku, waku] = await runNodes(this, [DefaultPubsubTopic]);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(this.ctx, [DefaultPubsubTopic]);
subscription = await waku.filter.createSubscription();
messageCollector = new MessageCollector();
@ -37,8 +38,7 @@ describe("Waku Filter V2: Unsubscribe", function () {
await nwaku.ensureSubscriptions();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -15,6 +15,8 @@ import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
delay,
generateTestData,
isNwakuAtLeast,
@ -39,18 +41,16 @@ const runTests = (strictCheckNodes: boolean): void => {
let serviceNodes: ServiceNodesFleet;
let subscription: IFilterSubscription;
this.beforeEach(async function () {
this.timeout(15000);
beforeEachCustom(this, async () => {
[serviceNodes, waku] = await runMultipleNodes(
this,
this.ctx,
[DefaultPubsubTopic],
strictCheckNodes
);
subscription = await waku.filter.createSubscription();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await teardownNodesWithRedundancy(serviceNodes, waku);
});

View File

@ -7,7 +7,12 @@ import {
import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import { generateTestData, ServiceNodesFleet } from "../../src/index.js";
import {
afterEachCustom,
beforeEachCustom,
generateTestData,
ServiceNodesFleet
} from "../../src/index.js";
import {
messagePayload,
@ -27,14 +32,14 @@ const runTests = (strictCheckNodes: boolean): void => {
let serviceNodes: ServiceNodesFleet;
let subscription: IFilterSubscription;
this.beforeEach(async function () {
this.timeout(15000);
[serviceNodes, waku] = await runMultipleNodes(this, [DefaultPubsubTopic]);
beforeEachCustom(this, async () => {
[serviceNodes, waku] = await runMultipleNodes(this.ctx, [
DefaultPubsubTopic
]);
subscription = await waku.filter.createSubscription();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await teardownNodesWithRedundancy(serviceNodes, waku);
});

View File

@ -17,7 +17,13 @@ import { expect } from "chai";
import fc from "fast-check";
import Sinon from "sinon";
import { makeLogFileName, ServiceNode, tearDownNodes } from "../src/index.js";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
} from "../src/index.js";
describe("getConnectedPeersForProtocolAndShard", function () {
let waku: LightNode;
@ -25,14 +31,12 @@ describe("getConnectedPeersForProtocolAndShard", function () {
let serviceNode2: ServiceNode;
const contentTopic = "/test/2/waku-light-push/utf8";
this.beforeEach(async function () {
this.timeout(15000);
serviceNode1 = new ServiceNode(makeLogFileName(this) + "1");
serviceNode2 = new ServiceNode(makeLogFileName(this) + "2");
beforeEachCustom(this, async () => {
serviceNode1 = new ServiceNode(makeLogFileName(this.ctx) + "1");
serviceNode2 = new ServiceNode(makeLogFileName(this.ctx) + "2");
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([serviceNode1, serviceNode2], waku);
});
@ -420,8 +424,7 @@ describe("getPeers", function () {
let nonBootstrapPeers: Peer[];
let allPeers: Peer[];
beforeEach(async function () {
this.timeout(10_000);
beforeEachCustom(this, async () => {
waku = await createLightNode();
peerStore = waku.libp2p.peerStore;
connectionManager = waku.libp2p.components.connectionManager;
@ -537,7 +540,7 @@ describe("getPeers", function () {
});
});
this.afterEach(function () {
afterEachCustom(this, async () => {
Sinon.restore();
});

View File

@ -9,6 +9,8 @@ import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
generateRandomUint8Array,
ServiceNodesFleet,
TEST_STRING
@ -33,10 +35,9 @@ const runTests = (strictNodeCheck: boolean): void => {
let waku: LightNode;
let serviceNodes: ServiceNodesFleet;
this.beforeEach(async function () {
this.timeout(15000);
beforeEachCustom(this, async () => {
[serviceNodes, waku] = await runMultipleNodes(
this,
this.ctx,
[DefaultPubsubTopic],
strictNodeCheck,
undefined,
@ -45,8 +46,7 @@ const runTests = (strictNodeCheck: boolean): void => {
);
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await teardownNodesWithRedundancy(serviceNodes, waku);
});

View File

@ -9,6 +9,8 @@ import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
generateRandomUint8Array,
MessageCollector,
ServiceNode,
@ -30,16 +32,14 @@ describe("Waku Light Push: Single Node", function () {
let nwaku: ServiceNode;
let messageCollector: MessageCollector;
this.beforeEach(async function () {
this.timeout(15000);
[nwaku, waku] = await runNodes(this, [DefaultPubsubTopic]);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(this.ctx, [DefaultPubsubTopic]);
messageCollector = new MessageCollector(nwaku);
await nwaku.ensureSubscriptions();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -18,6 +18,8 @@ import { utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
MessageCollector,
ServiceNode,
@ -52,10 +54,9 @@ describe("Waku Light Push : Multiple PubsubTopics", function () {
let nimPeerId: PeerId;
this.beforeEach(async function () {
this.timeout(15000);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(
this,
this.ctx,
[
singleShardInfoToPubsubTopic(singleShardInfo1),
singleShardInfoToPubsubTopic(singleShardInfo2)
@ -66,8 +67,7 @@ describe("Waku Light Push : Multiple PubsubTopics", function () {
nimPeerId = await nwaku.getPeerId();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});
@ -211,10 +211,9 @@ describe("Waku Light Push (Autosharding): Multiple PubsubTopics", function () {
let nimPeerId: PeerId;
this.beforeEach(async function () {
this.timeout(15000);
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(
this,
this.ctx,
[autoshardingPubsubTopic1, autoshardingPubsubTopic2],
shardInfo
);
@ -222,8 +221,7 @@ describe("Waku Light Push (Autosharding): Multiple PubsubTopics", function () {
nimPeerId = await nwaku.getPeerId();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});
@ -368,9 +366,8 @@ describe("Waku Light Push (named sharding): Multiple PubsubTopics", function ()
let nimPeerId: PeerId;
this.beforeEach(async function () {
this.timeout(15000);
[nwaku, waku] = await runNodes(this, [
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(this.ctx, [
autoshardingPubsubTopic1,
autoshardingPubsubTopic2
]);
@ -378,8 +375,7 @@ describe("Waku Light Push (named sharding): Multiple PubsubTopics", function ()
nimPeerId = await nwaku.getPeerId();
});
this.afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});

View File

@ -1,6 +1,6 @@
import { expect } from "chai";
import { makeLogFileName } from "../src/index.js";
import { beforeEachCustom, makeLogFileName } from "../src/index.js";
describe("This", function () {
describe("Is", function () {
@ -11,8 +11,8 @@ describe("This", function () {
describe("Is also", function () {
let testName: string;
beforeEach(function () {
testName = makeLogFileName(this);
beforeEachCustom(this, async () => {
testName = makeLogFileName(this.ctx);
});
it("A test", function () {
expect(testName).to.equal("This_Is_also_A_test");

View File

@ -7,6 +7,8 @@ import chai, { expect } from "chai";
import chaiAsPromised from "chai-as-promised";
import {
afterEachCustom,
beforeEachCustom,
delay,
makeLogFileName,
ServiceNode,
@ -20,13 +22,11 @@ describe("Metadata Protocol", function () {
let waku: LightNode;
let nwaku1: ServiceNode;
beforeEach(function () {
this.timeout(15000);
nwaku1 = new ServiceNode(makeLogFileName(this) + "1");
beforeEachCustom(this, async () => {
nwaku1 = new ServiceNode(makeLogFileName(this.ctx) + "1");
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku1], waku);
});

View File

@ -9,6 +9,8 @@ import { expect } from "chai";
import Sinon, { SinonSpy, SinonStub } from "sinon";
import {
afterEachCustom,
beforeEachCustom,
delay,
makeLogFileName,
ServiceNode,
@ -21,8 +23,7 @@ describe("multiaddr: dialing", function () {
let dialPeerSpy: SinonSpy;
let isPeerTopicConfigured: SinonStub;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});
@ -54,9 +55,8 @@ describe("multiaddr: dialing", function () {
let peerId: PeerId;
let multiaddr: Multiaddr;
beforeEach(async function () {
this.timeout(10_000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start();
waku = await createLightNode();
@ -72,7 +72,7 @@ describe("multiaddr: dialing", function () {
dialPeerSpy = Sinon.spy(waku.connectionManager as any, "dialPeer");
});
afterEach(function () {
afterEachCustom(this, async () => {
dialPeerSpy.restore();
});

View File

@ -16,6 +16,8 @@ import {
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
delay,
makeLogFileName,
ServiceNode,
@ -23,19 +25,18 @@ import {
waitForRemotePeerWithCodec
} from "../src/index.js";
describe("Peer Exchange", () => {
describe("Peer Exchange", function () {
describe("Locally Run Nodes", () => {
let waku: LightNode;
let nwaku1: ServiceNode;
let nwaku2: ServiceNode;
beforeEach(function () {
nwaku1 = new ServiceNode(makeLogFileName(this) + "1");
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
beforeEachCustom(this, async () => {
nwaku1 = new ServiceNode(makeLogFileName(this.ctx) + "1");
nwaku2 = new ServiceNode(makeLogFileName(this.ctx) + "2");
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku1, nwaku2], waku);
});
@ -126,9 +127,9 @@ describe("Peer Exchange", () => {
let nwaku1: ServiceNode;
let nwaku2: ServiceNode;
beforeEach(async function () {
nwaku1 = new ServiceNode(makeLogFileName(this) + "1");
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
beforeEachCustom(this, async () => {
nwaku1 = new ServiceNode(makeLogFileName(this.ctx) + "1");
nwaku2 = new ServiceNode(makeLogFileName(this.ctx) + "2");
});
tests({

View File

@ -8,14 +8,13 @@ import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
import { createLightNode, DefaultPubsubTopic } from "@waku/sdk";
import { expect } from "chai";
import { tearDownNodes } from "../src";
import { afterEachCustom, tearDownNodes } from "../src";
describe("Peer Exchange", () => {
describe("Auto Discovery", function () {
let waku: LightNode;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], waku);
});

View File

@ -18,6 +18,8 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
delay,
NOISE_KEY_1,
NOISE_KEY_2,
@ -31,8 +33,7 @@ describe("Waku Relay", function () {
let waku1: RelayNode;
let waku2: RelayNode;
beforeEach(async function () {
this.timeout(10000);
beforeEachCustom(this, async () => {
log.info("Starting JS Waku instances");
[waku1, waku2] = await Promise.all([
createRelayNode({ staticNoiseKey: NOISE_KEY_1 }).then((waku) =>
@ -53,8 +54,7 @@ describe("Waku Relay", function () {
log.info("before each hook done");
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], [waku1, waku2]);
});

View File

@ -6,7 +6,9 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
base64ToUtf8,
beforeEachCustom,
delay,
makeLogFileName,
NOISE_KEY_1,
@ -23,14 +25,13 @@ describe("Waku Relay, Interop", function () {
let waku: RelayNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(30000);
beforeEachCustom(this, async () => {
waku = await createRelayNode({
staticNoiseKey: NOISE_KEY_1
});
await waku.start();
nwaku = new ServiceNode(this.test?.ctx?.currentTest?.title + "");
nwaku = new ServiceNode(this.ctx.test?.ctx?.currentTest?.title + "");
await nwaku.start({ relay: true });
await waku.dial(await nwaku.getMultiaddrWithId());
@ -40,8 +41,7 @@ describe("Waku Relay, Interop", function () {
await nwaku.ensureSubscriptions();
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});
@ -108,7 +108,7 @@ describe("Waku Relay, Interop", function () {
let waku2: RelayNode;
let nwaku: ServiceNode;
afterEach(async function () {
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, [waku1, waku2]);
});

View File

@ -21,6 +21,7 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
MessageCollector,
NOISE_KEY_1,
NOISE_KEY_2,
@ -67,8 +68,7 @@ describe("Waku Relay, multiple pubsub topics", function () {
const customDecoder2 = createDecoder(customContentTopic2, singleShardInfo2);
const shardInfoBothShards: ShardInfo = { clusterId: 3, shards: [1, 2] };
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], [waku1, waku2, waku3]);
});
@ -360,8 +360,7 @@ describe("Waku Relay (Autosharding), multiple pubsub topics", function () {
contentTopics: [customContentTopic1, customContentTopic2]
};
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], [waku1, waku2, waku3]);
});
@ -671,8 +670,7 @@ describe("Waku Relay (named sharding), multiple pubsub topics", function () {
});
const customDecoder2 = createDecoder(customContentTopic2, customPubsubTopic2);
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], [waku1, waku2, waku3]);
});

View File

@ -5,6 +5,8 @@ import { utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
delay,
generateRandomUint8Array,
MessageCollector,
@ -29,8 +31,7 @@ describe("Waku Relay, Publish", function () {
let waku2: RelayNode;
let messageCollector: MessageCollector;
beforeEach(async function () {
this.timeout(10000);
beforeEachCustom(this, async () => {
log.info("Starting JS Waku instances");
[waku1, waku2] = await Promise.all([
createRelayNode({
@ -52,8 +53,7 @@ describe("Waku Relay, Publish", function () {
await waku2.relay.subscribe([TestDecoder], messageCollector.callback);
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], [waku1, waku2]);
});

View File

@ -5,6 +5,8 @@ import { utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
generateTestData,
MessageCollector,
NOISE_KEY_1,
@ -28,8 +30,7 @@ describe("Waku Relay, Subscribe", function () {
let waku2: RelayNode;
let messageCollector: MessageCollector;
beforeEach(async function () {
this.timeout(10000);
beforeEachCustom(this, async () => {
log.info("Starting JS Waku instances");
[waku1, waku2] = await Promise.all([
createRelayNode({
@ -46,11 +47,10 @@ describe("Waku Relay, Subscribe", function () {
});
await waku1.dial(waku2.libp2p.peerId);
log.info("before each hook done");
messageCollector = new MessageCollector(this.nwaku);
messageCollector = new MessageCollector(this.ctx.nwaku);
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], [waku1, waku2]);
});

View File

@ -17,6 +17,8 @@ import chaiAsPromised from "chai-as-promised";
import Sinon, { SinonSpy } from "sinon";
import {
afterEachCustom,
beforeEachCustom,
delay,
makeLogFileName,
ServiceNode,
@ -35,15 +37,13 @@ describe("Static Sharding: Peer Management", function () {
let dialPeerSpy: SinonSpy;
const clusterId = 18;
beforeEach(async function () {
this.timeout(15000);
nwaku1 = new ServiceNode(makeLogFileName(this) + "1");
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
nwaku3 = new ServiceNode(makeLogFileName(this) + "3");
beforeEachCustom(this, async () => {
nwaku1 = new ServiceNode(makeLogFileName(this.ctx) + "1");
nwaku2 = new ServiceNode(makeLogFileName(this.ctx) + "2");
nwaku3 = new ServiceNode(makeLogFileName(this.ctx) + "3");
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku1, nwaku2, nwaku3], waku);
dialPeerSpy && dialPeerSpy.restore();
});
@ -216,15 +216,13 @@ describe("Autosharding: Peer Management", function () {
let dialPeerSpy: SinonSpy;
beforeEach(async function () {
this.timeout(15000);
nwaku1 = new ServiceNode(makeLogFileName(this) + "1_auto");
nwaku2 = new ServiceNode(makeLogFileName(this) + "2_auto");
nwaku3 = new ServiceNode(makeLogFileName(this) + "3_auto");
beforeEachCustom(this, async () => {
nwaku1 = new ServiceNode(makeLogFileName(this.ctx) + "1_auto");
nwaku2 = new ServiceNode(makeLogFileName(this.ctx) + "2_auto");
nwaku3 = new ServiceNode(makeLogFileName(this.ctx) + "3_auto");
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku1, nwaku2, nwaku3], waku);
dialPeerSpy && dialPeerSpy.restore();
});

View File

@ -17,6 +17,8 @@ import {
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
@ -37,18 +39,16 @@ const singleShardInfo2: SingleShardInfo = { clusterId: 0, shard: 3 };
const ContentTopic = "/waku/2/content/test.js";
const ContentTopic2 = "/myapp/1/latest/proto";
describe("Static Sharding: Running Nodes", () => {
describe("Static Sharding: Running Nodes", function () {
let waku: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15_000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});
@ -112,18 +112,16 @@ describe("Static Sharding: Running Nodes", () => {
});
});
describe("Autosharding: Running Nodes", () => {
describe("Autosharding: Running Nodes", function () {
let waku: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15_000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -5,6 +5,8 @@ import { bytesToUtf8 } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
@ -25,15 +27,13 @@ describe("Waku Store, cursor", function () {
let waku2: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
await nwaku.ensureSubscriptions();
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, [waku, waku2]);
});

View File

@ -3,6 +3,8 @@ import { IMessage, type LightNode } from "@waku/interfaces";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
@ -21,16 +23,14 @@ describe("Waku Store, error handling", function () {
let waku: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
await nwaku.ensureSubscriptions();
waku = await startAndConnectLightNode(nwaku);
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -19,6 +19,8 @@ import { expect } from "chai";
import { equals } from "uint8arrays/equals";
import {
afterEachCustom,
beforeEachCustom,
delay,
makeLogFileName,
MessageCollector,
@ -48,15 +50,13 @@ describe("Waku Store, general", function () {
let waku2: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
await nwaku.ensureSubscriptions();
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, [waku, waku2]);
});

View File

@ -9,6 +9,8 @@ import {
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
NOISE_KEY_1,
ServiceNode,
@ -39,9 +41,8 @@ describe("Waku Store, custom pubsub topic", function () {
let nwaku: ServiceNode;
let nwaku2: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({
store: true,
pubsubTopic: [customShardedPubsubTopic1, customShardedPubsubTopic2],
@ -54,8 +55,7 @@ describe("Waku Store, custom pubsub topic", function () {
]);
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});
@ -215,9 +215,8 @@ describe.skip("Waku Store (Autosharding), custom pubsub topic", function () {
contentTopics: [customContentTopic1, customContentTopic2]
};
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({
store: true,
pubsubTopic: [autoshardingPubsubTopic1, autoshardingPubsubTopic2],
@ -230,8 +229,7 @@ describe.skip("Waku Store (Autosharding), custom pubsub topic", function () {
]);
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});
@ -350,15 +348,13 @@ describe("Waku Store (named sharding), custom pubsub topic", function () {
customShardedPubsubTopic2
);
beforeEach(async function () {
this.timeout(15000);
beforeEachCustom(this, async () => {
const shardInfo = singleShardInfosToShardInfo([
customShardInfo1,
customShardInfo2
]);
nwaku = new ServiceNode(makeLogFileName(this));
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({
store: true,
relay: true,
@ -377,8 +373,7 @@ describe("Waku Store (named sharding), custom pubsub topic", function () {
);
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([nwaku, nwaku2], waku);
});

View File

@ -4,6 +4,8 @@ import { DefaultPubsubTopic } from "@waku/interfaces";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
@ -23,15 +25,13 @@ describe("Waku Store, order", function () {
let waku: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
await nwaku.ensureSubscriptions();
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -3,6 +3,8 @@ import type { LightNode } from "@waku/interfaces";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
@ -20,15 +22,13 @@ describe("Waku Store, page size", function () {
let waku: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
await nwaku.ensureSubscriptions();
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -3,6 +3,8 @@ import type { IMessage, LightNode } from "@waku/interfaces";
import { DefaultPubsubTopic } from "@waku/interfaces";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
@ -21,15 +23,13 @@ describe("Waku Store, sorting", function () {
let waku: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
await nwaku.ensureSubscriptions();
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -2,6 +2,8 @@ import type { IMessage, LightNode } from "@waku/interfaces";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
@ -19,15 +21,13 @@ describe("Waku Store, time filter", function () {
let waku: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({ store: true, lightpush: true, relay: true });
await nwaku.ensureSubscriptions();
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -11,6 +11,8 @@ import chai, { expect } from "chai";
import chaiAsPromised from "chai-as-promised";
import {
afterEachCustom,
beforeEachCustom,
delay,
makeLogFileName,
NOISE_KEY_1,
@ -24,13 +26,12 @@ const TestContentTopic = "/test/1/waku-filter";
const TestEncoder = createEncoder({ contentTopic: TestContentTopic });
const TestDecoder = createDecoder(TestContentTopic);
describe("Util: toAsyncIterator: Filter", () => {
describe("Util: toAsyncIterator: Filter", function () {
let waku: LightNode;
let nwaku: ServiceNode;
beforeEach(async function () {
this.timeout(15000);
nwaku = new ServiceNode(makeLogFileName(this));
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({
filter: true,
lightpush: true,
@ -45,8 +46,7 @@ describe("Util: toAsyncIterator: Filter", () => {
await waitForRemotePeer(waku, [Protocols.Filter, Protocols.LightPush]);
});
afterEach(async function () {
this.timeout(10000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -6,6 +6,7 @@ import { createRelayNode } from "@waku/sdk/relay";
import { expect } from "chai";
import {
afterEachCustom,
delay,
makeLogFileName,
NOISE_KEY_1,
@ -18,8 +19,7 @@ describe("Wait for remote peer", function () {
let waku2: LightNode;
let nwaku: ServiceNode;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, [waku1, waku2]);
});

View File

@ -4,14 +4,18 @@ import { LightNode } from "@waku/interfaces";
import { createLightNode } from "@waku/sdk";
import { expect } from "chai";
import { makeLogFileName, ServiceNode, tearDownNodes } from "../src/index.js";
import {
afterEachCustom,
makeLogFileName,
ServiceNode,
tearDownNodes
} from "../src/index.js";
describe("Use static and several ENR trees for bootstrap", function () {
let waku: LightNode;
let nwaku: ServiceNode;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});

View File

@ -21,6 +21,8 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
makeLogFileName,
NOISE_KEY_1,
NOISE_KEY_2,
@ -37,8 +39,7 @@ describe("Waku Dial [node only]", function () {
let waku: LightNode;
let nwaku: ServiceNode;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});
@ -102,8 +103,7 @@ describe("Waku Dial [node only]", function () {
let waku: LightNode;
let nwaku: ServiceNode;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes(nwaku, waku);
});
@ -158,17 +158,16 @@ describe("Waku Dial [node only]", function () {
});
});
describe("Decryption Keys", () => {
afterEach(function () {
if (this.currentTest?.state === "failed") {
console.log(`Test failed, log file name is ${makeLogFileName(this)}`);
describe("Decryption Keys", function () {
afterEachCustom(this, async () => {
if (this.ctx.currentTest?.state === "failed") {
console.log(`Test failed, log file name is ${makeLogFileName(this.ctx)}`);
}
});
let waku1: RelayNode;
let waku2: RelayNode;
beforeEach(async function () {
this.timeout(5000);
beforeEachCustom(this, async () => {
[waku1, waku2] = await Promise.all([
createRelayNode({ staticNoiseKey: NOISE_KEY_1 }).then((waku) =>
waku.start().then(() => waku)
@ -190,8 +189,7 @@ describe("Decryption Keys", () => {
]);
});
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], [waku1, waku2]);
});
@ -228,12 +226,11 @@ describe("Decryption Keys", () => {
});
});
describe("User Agent", () => {
describe("User Agent", function () {
let waku1: Waku;
let waku2: Waku;
afterEach(async function () {
this.timeout(15000);
afterEachCustom(this, async () => {
await tearDownNodes([], [waku1, waku2]);
});