From dbee69d2963f6cc65c660b66164e3b1b03a1aca1 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Mon, 18 Sep 2023 21:38:36 +0200 Subject: [PATCH] Update few e2e tests after code review --- .../test/e2e/api/impl/config.test.ts | 2 -- .../test/e2e/api/impl/getBlobSidecars.test.ts | 35 ------------------- .../e2e/api/impl/lightclient/endpoint.test.ts | 9 +++-- .../test/e2e/api/lodestar/lodestar.test.ts | 3 +- .../test/e2e/chain/bls/multithread.test.ts | 2 ++ .../e2e/doppelganger/doppelganger.test.ts | 1 + .../e2e/eth1/eth1ForBlockProduction.test.ts | 1 + .../e2e/eth1/eth1MergeBlockTracker.test.ts | 1 + .../test/e2e/eth1/eth1Provider.test.ts | 1 + .../beacon-node/test/e2e/eth1/stream.test.ts | 1 + .../beacon-node/test/e2e/network/mdns.test.ts | 1 + .../test/e2e/network/onWorker/workerEcho.ts | 13 ------- .../e2e/network/onWorker/workerEchoHandler.ts | 35 ------------------- 13 files changed, 13 insertions(+), 92 deletions(-) delete mode 100644 packages/beacon-node/test/e2e/api/impl/getBlobSidecars.test.ts delete mode 100644 packages/beacon-node/test/e2e/network/onWorker/workerEcho.ts delete mode 100644 packages/beacon-node/test/e2e/network/onWorker/workerEchoHandler.ts diff --git a/packages/beacon-node/test/e2e/api/impl/config.test.ts b/packages/beacon-node/test/e2e/api/impl/config.test.ts index e4fa5b29211e..9ba196310e47 100644 --- a/packages/beacon-node/test/e2e/api/impl/config.test.ts +++ b/packages/beacon-node/test/e2e/api/impl/config.test.ts @@ -17,8 +17,6 @@ const CONSTANT_NAMES_SKIP_LIST = new Set([ ]); describe("api / impl / config", function () { - this.timeout(60 * 1000); - it("Ensure all constants are exposed", async () => { const constantNames = await downloadRemoteConstants(ethereumConsensusSpecsTests.specVersion); diff --git a/packages/beacon-node/test/e2e/api/impl/getBlobSidecars.test.ts b/packages/beacon-node/test/e2e/api/impl/getBlobSidecars.test.ts deleted file mode 100644 index 60b960f85acb..000000000000 --- a/packages/beacon-node/test/e2e/api/impl/getBlobSidecars.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import {expect} from "chai"; -import {config} from "@lodestar/config/default"; -import {ssz} from "@lodestar/types"; -import {GENESIS_SLOT} from "@lodestar/params"; - -import {setupApiImplTestServer, ApiImplTestModules} from "../../../unit/api/impl/index.test.js"; -import {zeroProtoBlock} from "../../../utils/mocks/chain.js"; - -describe("getBlobSideCar", function () { - let server: ApiImplTestModules; - - before(function () { - server = setupApiImplTestServer(); - }); - - // TODO: Write actual tests against the real BeaconChain class, this test is useless - it.skip("getBlobSideCar From BlobSidecars", async () => { - const block = config.getForkTypes(GENESIS_SLOT).SignedBeaconBlock.defaultValue(); - const blobSidecars = ssz.deneb.BlobSidecars.defaultValue(); - const wrappedBlobSidecars = { - blockRoot: ssz.Root.defaultValue(), - slot: block.message.slot, - blobSidecars, - }; - - server.forkChoiceStub.getFinalizedBlock.returns(zeroProtoBlock); - - server.dbStub.blockArchive.get.resolves(block); - server.dbStub.blobSidecars.get.resolves(wrappedBlobSidecars); - - const returnedBlobSideCars = await server.blockApi.getBlobSidecars("genesis"); - - expect(returnedBlobSideCars.data).to.equal(blobSidecars); - }); -}); diff --git a/packages/beacon-node/test/e2e/api/impl/lightclient/endpoint.test.ts b/packages/beacon-node/test/e2e/api/impl/lightclient/endpoint.test.ts index 716c4d196367..c0a91096f25b 100644 --- a/packages/beacon-node/test/e2e/api/impl/lightclient/endpoint.test.ts +++ b/packages/beacon-node/test/e2e/api/impl/lightclient/endpoint.test.ts @@ -31,7 +31,7 @@ describe("lightclient api", function () { let validators: Validator[]; const afterEachCallbacks: (() => Promise | void)[] = []; - this.beforeEach(async () => { + before(async () => { bn = await getDevBeaconNode({ params: chainConfig, options: { @@ -41,7 +41,7 @@ describe("lightclient api", function () { rest: { enabled: true, port: restPort, - api: ["lightclient"], + // api: ["lightclient"], }, }, chain: {blsVerifyAllMainThread: true}, @@ -64,7 +64,7 @@ describe("lightclient api", function () { afterEachCallbacks.push(() => Promise.all(validators.map((validator) => validator.close()))); }); - afterEach(async () => { + after(async () => { while (afterEachCallbacks.length > 0) { const callback = afterEachCallbacks.pop(); if (callback) await callback(); @@ -120,10 +120,9 @@ describe("lightclient api", function () { it("getCommitteeRoot() for the 1st period", async function () { await waitForBestUpdate(); - const lightclient = getClient({baseUrl: `http://127.0.0.1:${restPort}`}, {config}).lightclient; + const {lightclient, beacon: client} = getClient({baseUrl: `http://127.0.0.1:${restPort}`}, {config}); const committeeRes = await lightclient.getCommitteeRoot(0, 1); ApiError.assert(committeeRes); - const client = getClient({baseUrl: `http://127.0.0.1:${restPort}`}, {config}).beacon; const validatorResponse = await client.getStateValidators("head"); ApiError.assert(validatorResponse); const pubkeys = validatorResponse.response.data.map((v) => v.validator.pubkey); 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 2a79daae914c..852413ac4c89 100644 --- a/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts +++ b/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts @@ -38,8 +38,7 @@ describe("api / impl / validator", function () { const genesisValidatorsRoot = Buffer.alloc(32, 0xaa); const config = createBeaconConfig(chainConfig, genesisValidatorsRoot); - const testLoggerOpts: TestLoggerOpts = {level: LogLevel.info}; - const loggerNodeA = testLogger("Node-A", testLoggerOpts); + const loggerNodeA = testLogger("Node-A"); const bn = await getDevBeaconNode({ params: testParams, diff --git a/packages/beacon-node/test/e2e/chain/bls/multithread.test.ts b/packages/beacon-node/test/e2e/chain/bls/multithread.test.ts index 27ea9e094382..3bf32d05702e 100644 --- a/packages/beacon-node/test/e2e/chain/bls/multithread.test.ts +++ b/packages/beacon-node/test/e2e/chain/bls/multithread.test.ts @@ -78,6 +78,7 @@ describe("chain / bls / multithread queue", function () { expect(isValid).to.deep.equal([true, true, true], `sig set ${i} returned invalid`); } } + await pool.close(); } for (const priority of [true, false]) { @@ -122,6 +123,7 @@ describe("chain / bls / multithread queue", function () { for (const [i, isValid] of isValidArr.entries()) { expect(isValid).to.equal(true, `sig set ${i} returned invalid`); } + await pool.close(); }); } }); diff --git a/packages/beacon-node/test/e2e/doppelganger/doppelganger.test.ts b/packages/beacon-node/test/e2e/doppelganger/doppelganger.test.ts index 610072ebafe3..65c6eb387393 100644 --- a/packages/beacon-node/test/e2e/doppelganger/doppelganger.test.ts +++ b/packages/beacon-node/test/e2e/doppelganger/doppelganger.test.ts @@ -21,6 +21,7 @@ import {BeaconNode} from "../../../src/node/index.js"; // // Attempting to do both 1. and 2. in this e2e test more expensive than necessary. // Unit tests in the validator cover 2., so some test in lodestar package should cover 1. +// https://github.com/ChainSafe/lodestar/issues/5967 describe.skip("doppelganger / doppelganger test", function () { const afterEachCallbacks: (() => Promise | void)[] = []; afterEach(async () => { diff --git a/packages/beacon-node/test/e2e/eth1/eth1ForBlockProduction.test.ts b/packages/beacon-node/test/e2e/eth1/eth1ForBlockProduction.test.ts index cb537b14563f..1c67788e3fb6 100644 --- a/packages/beacon-node/test/e2e/eth1/eth1ForBlockProduction.test.ts +++ b/packages/beacon-node/test/e2e/eth1/eth1ForBlockProduction.test.ts @@ -27,6 +27,7 @@ const pyrmontDepositsDataRoot = [ "0x61cef7d8a3f7c590a2dc066ae1c95def5ce769b3e9471fdb34f36f7a7246965e", ]; +// https://github.com/ChainSafe/lodestar/issues/5967 describe.skip("eth1 / Eth1Provider", function () { this.timeout("2 min"); diff --git a/packages/beacon-node/test/e2e/eth1/eth1MergeBlockTracker.test.ts b/packages/beacon-node/test/e2e/eth1/eth1MergeBlockTracker.test.ts index 67d392500cd5..868a06724894 100644 --- a/packages/beacon-node/test/e2e/eth1/eth1MergeBlockTracker.test.ts +++ b/packages/beacon-node/test/e2e/eth1/eth1MergeBlockTracker.test.ts @@ -15,6 +15,7 @@ import {getGoerliRpcUrl} from "../../testParams.js"; // This test is constantly failing. We must unblock PR so this issue is a TODO to debug it and re-enable latter. // It's OKAY to disable temporarily since this functionality is tested indirectly by the sim merge tests. // See https://github.com/ChainSafe/lodestar/issues/4197 +// https://github.com/ChainSafe/lodestar/issues/5967 describe.skip("eth1 / Eth1MergeBlockTracker", function () { this.timeout("2 min"); diff --git a/packages/beacon-node/test/e2e/eth1/eth1Provider.test.ts b/packages/beacon-node/test/e2e/eth1/eth1Provider.test.ts index c5c94f49712c..52f9dd4f264d 100644 --- a/packages/beacon-node/test/e2e/eth1/eth1Provider.test.ts +++ b/packages/beacon-node/test/e2e/eth1/eth1Provider.test.ts @@ -8,6 +8,7 @@ import {Eth1Provider, parseEth1Block} from "../../../src/eth1/provider/eth1Provi import {Eth1Block} from "../../../src/eth1/interface.js"; import {getGoerliRpcUrl} from "../../testParams.js"; +// https://github.com/ChainSafe/lodestar/issues/5967 describe.skip("eth1 / Eth1Provider", function () { this.timeout("2 min"); diff --git a/packages/beacon-node/test/e2e/eth1/stream.test.ts b/packages/beacon-node/test/e2e/eth1/stream.test.ts index ca4d48a302cc..372f9abdb935 100644 --- a/packages/beacon-node/test/e2e/eth1/stream.test.ts +++ b/packages/beacon-node/test/e2e/eth1/stream.test.ts @@ -6,6 +6,7 @@ import {Eth1Provider} from "../../../src/eth1/provider/eth1Provider.js"; import {getGoerliRpcUrl} from "../../testParams.js"; import {Eth1Options} from "../../../src/eth1/options.js"; +// https://github.com/ChainSafe/lodestar/issues/5967 describe.skip("Eth1 streams", function () { this.timeout("2 min"); diff --git a/packages/beacon-node/test/e2e/network/mdns.test.ts b/packages/beacon-node/test/e2e/network/mdns.test.ts index f08e57a25045..a18e939cfda5 100644 --- a/packages/beacon-node/test/e2e/network/mdns.test.ts +++ b/packages/beacon-node/test/e2e/network/mdns.test.ts @@ -24,6 +24,7 @@ import {memoOnce} from "../../utils/cache.js"; let port = 9000; const mu = "/ip4/127.0.0.1/tcp/0"; +// https://github.com/ChainSafe/lodestar/issues/5967 // eslint-disable-next-line mocha/no-skipped-tests describe.skip("mdns", function () { this.timeout(50000); diff --git a/packages/beacon-node/test/e2e/network/onWorker/workerEcho.ts b/packages/beacon-node/test/e2e/network/onWorker/workerEcho.ts deleted file mode 100644 index a448a8821792..000000000000 --- a/packages/beacon-node/test/e2e/network/onWorker/workerEcho.ts +++ /dev/null @@ -1,13 +0,0 @@ -import worker from "node:worker_threads"; -import {expose} from "@chainsafe/threads/worker"; - -const parentPort = worker.parentPort; -if (!parentPort) throw Error("parentPort must be defined"); - -parentPort.on("message", (data) => { - parentPort.postMessage(data); -}); - -expose(() => { - // -}); diff --git a/packages/beacon-node/test/e2e/network/onWorker/workerEchoHandler.ts b/packages/beacon-node/test/e2e/network/onWorker/workerEchoHandler.ts deleted file mode 100644 index 0b84ace618f1..000000000000 --- a/packages/beacon-node/test/e2e/network/onWorker/workerEchoHandler.ts +++ /dev/null @@ -1,35 +0,0 @@ -import worker_threads from "node:worker_threads"; -import {spawn, Worker} from "@chainsafe/threads"; - -export type EchoWorker = { - send(data: T): Promise; - close(): Promise; -}; - -export async function getEchoWorker(): Promise { - const workerThreadjs = new Worker("./workerEcho.js"); - const worker = workerThreadjs as unknown as worker_threads.Worker; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - await spawn(workerThreadjs, { - // A Lodestar Node may do very expensive task at start blocking the event loop and causing - // the initialization to timeout. The number below is big enough to almost disable the timeout - timeout: 5 * 60 * 1000, - // TODO: types are broken on spawn, which claims that `NetworkWorkerApi` does not satifies its contrains - }); - - return { - send(data: T): Promise { - return new Promise((resolve, reject) => { - worker.once("message", (data) => resolve(data)); - worker.once("messageerror", reject); - worker.once("error", reject); - worker.postMessage(data); - }); - }, - - async close() { - await workerThreadjs.terminate(); - }, - }; -}