From 42725aa9c1b055838c9782af411bab9928609b15 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Mon, 9 Oct 2023 17:21:30 +0200 Subject: [PATCH] Fix the test path --- packages/beacon-node/package.json | 4 ++-- .../test/e2e/api/lodestar/lodestar.test.ts | 19 +++++-------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/packages/beacon-node/package.json b/packages/beacon-node/package.json index a8825911a48b..bf9a0596e90c 100644 --- a/packages/beacon-node/package.json +++ b/packages/beacon-node/package.json @@ -77,10 +77,10 @@ "lint:fix": "yarn run lint --fix", "pretest": "yarn run check-types", "test": "yarn test:unit && yarn test:e2e", - "test:unit:minimal": "vitest --run 'test/unit/**/*.test.ts'", + "test:unit:minimal": "vitest --run --dir test/unit/", "test:unit:mainnet": "LODESTAR_PRESET=mainnet nyc --cache-dir .nyc_output/.cache -e .ts mocha 'test/unit-mainnet/**/*.test.ts'", "test:unit": "yarn test:unit:minimal && yarn test:unit:mainnet", - "test:e2e": "LODESTAR_PRESET=minimal yarn vitest --run test/e2e/", + "test:e2e": "LODESTAR_PRESET=minimal vitest --run --single-thread --dir test/e2e", "test:sim": "mocha 'test/sim/**/*.test.ts'", "test:sim:merge-interop": "mocha 'test/sim/merge-interop.test.ts'", "test:sim:mergemock": "mocha 'test/sim/mergemock.test.ts'", diff --git a/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts b/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts index bec2ef0c1f72..27db4c6fe117 100644 --- a/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts +++ b/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts @@ -8,9 +8,11 @@ import {LogLevel, testLogger, TestLoggerOpts} from "../../../utils/logger.js"; import {getDevBeaconNode} from "../../../utils/node/beacon.js"; import {waitForEvent} from "../../../utils/events/resolver.js"; import {ClockEvent} from "../../../../src/util/clock.js"; +import {BeaconNode} from "../../../../src/index.js"; describe("api / impl / validator", function () { describe("getLiveness endpoint", function () { + let bn: BeaconNode | undefined; const SECONDS_PER_SLOT = 2; const ALTAIR_FORK_EPOCH = 0; const validatorCount = 8; @@ -23,13 +25,8 @@ describe("api / impl / validator", function () { const genesisSlotsDelay = 5; const timeout = (SLOTS_PER_EPOCH + genesisSlotsDelay) * testParams.SECONDS_PER_SLOT * 1000; - const afterEachCallbacks: (() => Promise | void)[] = []; - afterEach(async () => { - while (afterEachCallbacks.length > 0) { - const callback = afterEachCallbacks.pop(); - if (callback) await callback(); - } + if (bn) await bn.close(); }); it("Should return validator indices that are live", async function () { @@ -39,7 +36,7 @@ describe("api / impl / validator", function () { const loggerNodeA = testLogger("Node-A"); - const bn = await getDevBeaconNode({ + bn = await getDevBeaconNode({ params: testParams, options: { sync: {isSingleNode: true}, @@ -49,9 +46,6 @@ describe("api / impl / validator", function () { validatorCount, logger: loggerNodeA, }); - afterEachCallbacks.push(async () => { - await bn.close(); - }); // live indices at epoch of consideration, epoch 0 bn.chain.seenBlockProposers.add(0, 1); @@ -90,7 +84,7 @@ describe("api / impl / validator", function () { const testLoggerOpts: TestLoggerOpts = {level: LogLevel.info}; const loggerNodeA = testLogger("Node-A", testLoggerOpts); - const bn = await getDevBeaconNode({ + bn = await getDevBeaconNode({ params: testParams, options: { sync: {isSingleNode: true}, @@ -100,9 +94,6 @@ describe("api / impl / validator", function () { validatorCount, logger: loggerNodeA, }); - afterEachCallbacks.push(async () => { - await bn.close(); - }); await waitForEvent(bn.chain.clock, ClockEvent.epoch, timeout); // wait for epoch 1 await waitForEvent(bn.chain.clock, ClockEvent.epoch, timeout); // wait for epoch 2