diff --git a/packages/beacon-node/test/e2e/network/gossipsub.test.ts b/packages/beacon-node/test/e2e/network/gossipsub.test.ts index 92e9271fdeea..9a97619125c6 100644 --- a/packages/beacon-node/test/e2e/network/gossipsub.test.ts +++ b/packages/beacon-node/test/e2e/network/gossipsub.test.ts @@ -40,8 +40,14 @@ function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void { // eslint-disable-next-line @typescript-eslint/explicit-function-return-type async function mockModules(gossipHandlersPartial?: Partial) { - const [netA] = await getNetworkForTest("A", config, {opts: {useWorker}, gossipHandlersPartial}); - const [netB, closeB] = await getNetworkForTest("B", config, {opts: {useWorker}, gossipHandlersPartial}); + const [netA] = await getNetworkForTest(`gossipsub-${useWorker ? "worker" : "main"}-A`, config, { + opts: {useWorker}, + gossipHandlersPartial, + }); + const [netB, closeB] = await getNetworkForTest(`gossipsub-${useWorker ? "worker" : "main"}-B`, config, { + opts: {useWorker}, + gossipHandlersPartial, + }); afterEachCallbacks.push(async () => { // await closeA(); diff --git a/packages/beacon-node/test/e2e/network/mdns.test.ts b/packages/beacon-node/test/e2e/network/mdns.test.ts index 7903b5ad3c45..91c01f81a44f 100644 --- a/packages/beacon-node/test/e2e/network/mdns.test.ts +++ b/packages/beacon-node/test/e2e/network/mdns.test.ts @@ -120,7 +120,7 @@ describe.skip("mdns", function () { // eslint-disable-next-line @typescript-eslint/explicit-function-return-type async function createTestNodesAB() { - return Promise.all([createTestNode("A"), createTestNode("B")]); + return Promise.all([createTestNode("mdns-A"), createTestNode("mdns-B")]); } it("should connect two peers on a LAN", async function () { diff --git a/packages/beacon-node/test/e2e/network/network.test.ts b/packages/beacon-node/test/e2e/network/network.test.ts index 9080ae7e5374..bdbc68424dbd 100644 --- a/packages/beacon-node/test/e2e/network/network.test.ts +++ b/packages/beacon-node/test/e2e/network/network.test.ts @@ -24,13 +24,18 @@ function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void { const afterEachCallbacks: (() => Promise | void)[] = []; afterEach(async () => { - await Promise.all(afterEachCallbacks.map((cb) => cb())); - afterEachCallbacks.splice(0, afterEachCallbacks.length); + while (afterEachCallbacks.length > 0) { + const callback = afterEachCallbacks.pop(); + if (callback) await callback(); + } }); let controller: AbortController; beforeEach(() => (controller = new AbortController())); - afterEach(() => controller.abort()); + afterEach(() => { + controller.abort(); + sinon.restore(); + }); // eslint-disable-next-line @typescript-eslint/explicit-function-return-type async function createTestNode(nodeName: string) { @@ -38,24 +43,25 @@ function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void { afterEachCallbacks.push(async () => { await closeAll(); - sinon.restore(); }); return network; } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - async function createTestNodesAB() { - return Promise.all([createTestNode("A"), createTestNode("B")]); + async function createTestNodesAB(): Promise<[Network, Network]> { + return Promise.all([ + createTestNode(`network-${useWorker ? "worker" : "main"}-A`), + createTestNode(`network-${useWorker ? "worker" : "main"}-A`), + ]); } it("Disconnect peer", async () => { - const network = await createTestNode("A"); + const network = await createTestNode(`network-${useWorker ? "worker" : "main"}-DP`); await network.disconnectPeer(getValidPeerId().toString()); }); it("return getNetworkIdentity", async () => { - const network = await createTestNode("A"); + const network = await createTestNode(`network-${useWorker ? "worker" : "main"}-NI`); const networkIdentity = await network.getNetworkIdentity(); expect(networkIdentity.peerId).equals(network.peerId.toString()); }); @@ -124,7 +130,7 @@ function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void { }); it("Should subscribe to gossip core topics on demand", async () => { - const netA = await createTestNode("A"); + const netA = await createTestNode(`network-${useWorker ? "worker" : "main"}-CT`); expect(await getTopics(netA)).deep.equals([]); diff --git a/packages/beacon-node/test/e2e/network/reqresp.test.ts b/packages/beacon-node/test/e2e/network/reqresp.test.ts index 0df24a0a569d..acbf799bb013 100644 --- a/packages/beacon-node/test/e2e/network/reqresp.test.ts +++ b/packages/beacon-node/test/e2e/network/reqresp.test.ts @@ -55,8 +55,14 @@ function runTests(this: Mocha.Suite, {useWorker}: {useWorker: boolean}): void { getReqRespHandler?: GetReqRespHandlerFn, opts?: ReqRespBeaconNodeOpts ): Promise<[Network, Network, PeerIdStr, PeerIdStr]> { - const [netA, closeA] = await getNetworkForTest("A", config, {getReqRespHandler, opts: {...opts, useWorker}}); - const [netB, closeB] = await getNetworkForTest("B", config, {getReqRespHandler, opts: {...opts, useWorker}}); + const [netA, closeA] = await getNetworkForTest(`reqresp-${useWorker ? "worker" : "main"}-A`, config, { + getReqRespHandler, + opts: {...opts, useWorker}, + }); + const [netB, closeB] = await getNetworkForTest(`reqresp-${useWorker ? "worker" : "main"}-B`, config, { + getReqRespHandler, + opts: {...opts, useWorker}, + }); afterEachCallbacks.push(async () => { await closeA();