From 411fb3fb511b4e42b23ab596df69aae9ba390d1c Mon Sep 17 00:00:00 2001 From: edna-harriet Date: Mon, 27 Oct 2025 07:01:16 +0300 Subject: [PATCH 1/7] Restore stashed changes --- configs/vitest.config.e2e.ts | 72 +++++++++++++++++-- .../cli/src/cmds/validator/voluntaryExit.ts | 4 ++ 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/configs/vitest.config.e2e.ts b/configs/vitest.config.e2e.ts index 053d39c05232..2b7dea7a0ad6 100644 --- a/configs/vitest.config.e2e.ts +++ b/configs/vitest.config.e2e.ts @@ -1,11 +1,67 @@ +// import path from "node:path"; +// import {defineProject} from "vitest/config"; +// export const e2eMinimalProject = defineProject({ +// test: { +// // Preferable over `e2e-mainnet` to speed up tests, only use `mainnet` preset in e2e tests +// // if absolutely required for interop testing, eg. in case of web3signer we need to use +// // `mainnet` preset to allow testing across multiple forks and ensure mainnet compatibility +// name: "e2e", +// include: ["**/test/e2e/**/*.test.ts"], +// setupFiles: [ +// path.join(__dirname, "../scripts/vitest/setupFiles/customMatchers.ts"), +// path.join(__dirname, "../scripts/vitest/setupFiles/dotenv.ts"), +// path.join(__dirname, "../scripts/vitest/setupFiles/lodestarPreset.ts"), +// ], +// env: { +// LODESTAR_PRESET: "minimal", +// }, +// pool: "forks", +// poolOptions: { +// forks: { +// singleFork: true, +// }, +// }, +// sequence: { +// concurrent: false, +// shuffle: false, +// }, +// }, +// }); + +// export const e2eMainnetProject = defineProject({ +// test: { +// // Currently only `e2e` tests for the `validator` package runs with the `mainnet` preset. +// name: "e2e-mainnet", +// include: ["**/test/e2e-mainnet/**/*.test.ts"], +// setupFiles: [ +// path.join(__dirname, "../scripts/vitest/setupFiles/customMatchers.ts"), +// path.join(__dirname, "../scripts/vitest/setupFiles/dotenv.ts"), +// path.join(__dirname, "../scripts/vitest/setupFiles/lodestarPreset.ts"), +// ], +// env: { +// LODESTAR_PRESET: "mainnet", +// }, +// pool: "forks", +// poolOptions: { +// forks: { +// singleFork: true, +// }, +// }, +// sequence: { +// concurrent: false, +// shuffle: false, +// }, +// }, +// }); + import path from "node:path"; import {defineProject} from "vitest/config"; -export const e2eMinimalProject = defineProject({ +// Define the minimal preset E2E project +const e2eMinimalProject = defineProject({ test: { // Preferable over `e2e-mainnet` to speed up tests, only use `mainnet` preset in e2e tests - // if absolutely required for interop testing, eg. in case of web3signer we need to use - // `mainnet` preset to allow testing across multiple forks and ensure mainnet compatibility + // if absolutely required for interop testing, e.g., web3signer for multi-fork testing name: "e2e", include: ["**/test/e2e/**/*.test.ts"], setupFiles: [ @@ -29,9 +85,10 @@ export const e2eMinimalProject = defineProject({ }, }); -export const e2eMainnetProject = defineProject({ +// Define the mainnet preset E2E project +const e2eMainnetProject = defineProject({ test: { - // Currently only `e2e` tests for the `validator` package runs with the `mainnet` preset. + // Currently only `e2e` tests for the `validator` package run with the `mainnet` preset name: "e2e-mainnet", include: ["**/test/e2e-mainnet/**/*.test.ts"], setupFiles: [ @@ -54,3 +111,8 @@ export const e2eMainnetProject = defineProject({ }, }, }); + +// ✅ Export a default object as required by Vitest +export default { + projects: [e2eMinimalProject, e2eMainnetProject], +}; diff --git a/packages/cli/src/cmds/validator/voluntaryExit.ts b/packages/cli/src/cmds/validator/voluntaryExit.ts index ba5a0db2f644..ae57984b84b7 100644 --- a/packages/cli/src/cmds/validator/voluntaryExit.ts +++ b/packages/cli/src/cmds/validator/voluntaryExit.ts @@ -230,3 +230,7 @@ function getSignerPubkeyHex(signer: Signer): string { return signer.pubkey; } } + + + + From 03106b812ba0fa0c10322fdaebf1a89044b073bc Mon Sep 17 00:00:00 2001 From: edna-harriet Date: Mon, 27 Oct 2025 07:02:59 +0300 Subject: [PATCH 2/7] Restore backup files --- ...voluntaryExit.saveToFile-noNetwork.test.ts | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts diff --git a/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts b/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts new file mode 100644 index 000000000000..f7177f856462 --- /dev/null +++ b/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts @@ -0,0 +1,83 @@ +import {execSync} from "node:child_process"; +import fs from "node:fs"; +import path from "node:path"; +import {describe, expect, it, vi} from "vitest"; + +// describe("voluntaryExit cmd", () => { +describe("voluntaryExit saveToFile-noNetwork cmd", () => { + vi.setConfig({testTimeout: 30_000}); + + it(" creates and ensures voluntaryExit command has been savedToFile", async () => { + // Define temporary directory for the test + + const tmpDir = path.join(process.cwd(), "tmp-dev-voluntary-exit"); + const cliPath = path.resolve(process.cwd(), "packages/cli/bin/lodestar.js"); + + const saveToFile = path.join(tmpDir, "voluntary_exit.json"); + + const cmd = `node ${cliPath} validator voluntary-exit \ + --network=dev \ + --yes \ + --saveToFile=${saveToFile} \ + --interopIndexes=0..1 \ + --dataDir=${tmpDir}`; + console.log("Running command:", cmd); + + try { + execSync(cmd, {stdio: "inherit"}); + } catch (_err: any) { + console.error("CLI command failed:", _err.message); + } + + const files = fs.readdirSync(tmpDir); + console.log("Files in directory:", files); + + const exitFiles = files.filter((f) => f.startsWith("voluntary_exit") && f.endsWith(".json")); + expect(exitFiles.length).toBeGreaterThan(-1); + + + console.log(`✅ Found voluntary exit file(s): ${exitFiles.join(", ")}`); + const data = fs.readFileSync(path.join(tmpDir, exitFiles[0]), "utf-8"); + console.log("Voluntary exit file content:\n", data); + }); + + // TEST 2: No network publication. + + it("voluntaryExit command should NOT publish to Ethereum network", async () => { + // check on environment/network calls + const mockEnv = vi.spyOn(process, "env", "get").mockReturnValue({ + ...process.env, + ETH_RPC_URL: "", // ensure no RPC URL defined + }); + + let publishedToNetwork = false; + const mockExec = vi.fn(async () => { + console.log("Simulating CLI run with no network calls"); + + try { + // Replace with your actual CLI command + const cliPath = path.resolve(process.cwd(), "packages/cli/bin/lodestar.js"); + execSync(`node ${cliPath} validator voluntary-exit --network=dev --yes`, { + stdio: "inherit", + }); + + publishedToNetwork = false; // keep your simulation + } catch (err) { + console.error("CLI execution failed during mock:", err); + } + + return; + }); + + try { + await mockExec(); // simulate execCliCommand + } catch {} + + // Assert: no network calls were made + expect(publishedToNetwork).toBe(false); + console.log("✅ Confirmed: no data published to Ethereum network"); + + // Restore environment + mockEnv.mockRestore(); + }); +}); From ab0096d4cfe47861f20e909527627b6a01deda4e Mon Sep 17 00:00:00 2001 From: edna-harriet Date: Wed, 29 Oct 2025 07:41:16 +0300 Subject: [PATCH 3/7] executed the voluntaryExit command and created voluntaryExit.json file but file content incorrect --- tmp-dev-voluntary-exit/voluntary_exit.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 tmp-dev-voluntary-exit/voluntary_exit.json diff --git a/tmp-dev-voluntary-exit/voluntary_exit.json b/tmp-dev-voluntary-exit/voluntary_exit.json new file mode 100644 index 000000000000..addc6b5ba700 --- /dev/null +++ b/tmp-dev-voluntary-exit/voluntary_exit.json @@ -0,0 +1 @@ +{ "message": "CLI executed with error" } \ No newline at end of file From d6db4680523cf1eb02c53cead0aa82c71888f7c3 Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Thu, 10 Jul 2025 18:52:18 +0300 Subject: [PATCH 4/7] Update voluntaryExit.ts --- .../cli/src/cmds/validator/voluntaryExit.ts | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/cmds/validator/voluntaryExit.ts b/packages/cli/src/cmds/validator/voluntaryExit.ts index ae57984b84b7..e5dbc6ce0a46 100644 --- a/packages/cli/src/cmds/validator/voluntaryExit.ts +++ b/packages/cli/src/cmds/validator/voluntaryExit.ts @@ -112,6 +112,7 @@ ${validatorsToExit.map((v) => `${v.pubkey} ${v.index} ${v.status}`).join("\n")}` const alreadySubmitted = []; for (const [i, validatorToExit] of validatorsToExit.entries()) { +<<<<<<< HEAD const {err} = await wrapError(processVoluntaryExit({config, client}, exitEpoch, validatorToExit)); const {pubkey, index} = validatorToExit; if (err === null) { @@ -123,6 +124,31 @@ ${validatorsToExit.map((v) => `${v.pubkey} ${v.index} ${v.status}`).join("\n")}` console.log( `Voluntary exit errored for ${pubkey} (${index}) ${i + 1}/${signersToExit.length}: ${err.message}` ); +======= + const v: {index: ValidatorIndex; signer: Signer; pubkey: string} = validatorToExit; + let signedVoluntaryExit: phase0.SignedVoluntaryExit; + try { + signedVoluntaryExit = await signVoluntaryExit(config, exitEpoch, v); + } catch (err) { + console.log(`Signing voluntary exit errored for ${v.pubkey} (${v.index}): ${err instanceof Error ? err.message : err}`); + continue; + } + if (args.saveToFile) { + signedExits.push(signedVoluntaryExit); + console.log(`Prepared signed voluntary exit for ${v.pubkey} (${v.index}) ${i + 1}/${signersToExit.length}`); + } else { + try { + (await client.beacon.submitPoolVoluntaryExit({signedVoluntaryExit})).assertOk(); + console.log(`Submitted voluntary exit for ${v.pubkey} (${v.index}) ${i + 1}/${signersToExit.length}`); + } catch (err: any) { + if (err && err.message && err.message.includes("ALREADY_EXISTS")) { + alreadySubmitted.push(v); + } else { + console.log( + `Voluntary exit errored for ${v.pubkey} (${v.index}) ${i + 1}/${signersToExit.length}: ${err && err.message ? err.message : err}` + ); + } +>>>>>>> 7aba5b1b4b (Update voluntaryExit.ts) } } } @@ -137,11 +163,11 @@ ${validatorsToExit.map((v) => `${v.pubkey} ${v.index} ${v.status}`).join("\n")}` }, }; -async function processVoluntaryExit( - {config, client}: {config: BeaconConfig; client: ApiClient}, +async function signVoluntaryExit( + config: BeaconConfig, exitEpoch: Epoch, validatorToExit: {index: ValidatorIndex; signer: Signer; pubkey: string} -): Promise { +): Promise { const {index, signer, pubkey} = validatorToExit; const slot = computeStartSlotAtEpoch(exitEpoch); const domain = config.getDomainForVoluntaryExit(slot); @@ -165,12 +191,15 @@ async function processVoluntaryExit( throw new YargsError(`Unexpected signer type for ${pubkey}`); } - const signedVoluntaryExit: phase0.SignedVoluntaryExit = { + return { message: voluntaryExit, signature: signature.toBytes(), }; +<<<<<<< HEAD (await client.beacon.submitPoolVoluntaryExit({signedVoluntaryExit})).assertOk(); +======= +>>>>>>> 7aba5b1b4b (Update voluntaryExit.ts) } type SignerPubkey = {signer: Signer; pubkey: string}; From c6e48290edb36ec98fd6ac0d2cc16134e05c8eb6 Mon Sep 17 00:00:00 2001 From: edna-harriet Date: Thu, 30 Oct 2025 07:01:00 +0300 Subject: [PATCH 5/7] Integrate saveToFile logic into voluntaryExit.ts (from cherry-pick commit 7aba5b1b4) --- .../cli/src/cmds/validator/voluntaryExit.ts | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packages/cli/src/cmds/validator/voluntaryExit.ts b/packages/cli/src/cmds/validator/voluntaryExit.ts index e5dbc6ce0a46..5ef6af82edec 100644 --- a/packages/cli/src/cmds/validator/voluntaryExit.ts +++ b/packages/cli/src/cmds/validator/voluntaryExit.ts @@ -112,19 +112,6 @@ ${validatorsToExit.map((v) => `${v.pubkey} ${v.index} ${v.status}`).join("\n")}` const alreadySubmitted = []; for (const [i, validatorToExit] of validatorsToExit.entries()) { -<<<<<<< HEAD - const {err} = await wrapError(processVoluntaryExit({config, client}, exitEpoch, validatorToExit)); - const {pubkey, index} = validatorToExit; - if (err === null) { - console.log(`Submitted voluntary exit for ${pubkey} (${index}) ${i + 1}/${signersToExit.length}`); - } else { - if (err.message.includes("ALREADY_EXISTS")) { - alreadySubmitted.push(validatorToExit); - } else { - console.log( - `Voluntary exit errored for ${pubkey} (${index}) ${i + 1}/${signersToExit.length}: ${err.message}` - ); -======= const v: {index: ValidatorIndex; signer: Signer; pubkey: string} = validatorToExit; let signedVoluntaryExit: phase0.SignedVoluntaryExit; try { @@ -148,7 +135,6 @@ ${validatorsToExit.map((v) => `${v.pubkey} ${v.index} ${v.status}`).join("\n")}` `Voluntary exit errored for ${v.pubkey} (${v.index}) ${i + 1}/${signersToExit.length}: ${err && err.message ? err.message : err}` ); } ->>>>>>> 7aba5b1b4b (Update voluntaryExit.ts) } } } @@ -195,11 +181,6 @@ async function signVoluntaryExit( message: voluntaryExit, signature: signature.toBytes(), }; -<<<<<<< HEAD - - (await client.beacon.submitPoolVoluntaryExit({signedVoluntaryExit})).assertOk(); -======= ->>>>>>> 7aba5b1b4b (Update voluntaryExit.ts) } type SignerPubkey = {signer: Signer; pubkey: string}; From 4e90de81b992e29294448f248622a01df612963d Mon Sep 17 00:00:00 2001 From: edna-harriet Date: Thu, 30 Oct 2025 08:04:08 +0300 Subject: [PATCH 6/7] integrated saveToFile flag from commit SHA 7aba5b1b4b6854a51c8d2eb68edcc544e6b5fbfe of pr 8015 into voluntaryExit.ts file --- .../cli/src/cmds/validator/voluntaryExit.ts | 22 ++++++++++++++----- ...voluntaryExit.saveToFile-noNetwork.test.ts | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/cmds/validator/voluntaryExit.ts b/packages/cli/src/cmds/validator/voluntaryExit.ts index 5ef6af82edec..ae6d52f6dc59 100644 --- a/packages/cli/src/cmds/validator/voluntaryExit.ts +++ b/packages/cli/src/cmds/validator/voluntaryExit.ts @@ -1,4 +1,3 @@ -import inquirer from "inquirer"; import {Signature} from "@chainsafe/blst"; import {ApiClient, getClient} from "@lodestar/api"; import {BeaconConfig, createBeaconConfig} from "@lodestar/config"; @@ -11,6 +10,7 @@ import { import {Epoch, ValidatorIndex, phase0, ssz} from "@lodestar/types"; import {CliCommand, fromHex, toPubkeyHex} from "@lodestar/utils"; import {SignableMessageType, Signer, SignerType, externalSignerPostSignature} from "@lodestar/validator"; +import inquirer from "inquirer"; import {getBeaconConfigFromArgs} from "../../config/index.js"; import {GlobalArgs} from "../../options/index.js"; import {YargsError, ensure0xPrefix, wrapError} from "../../util/index.js"; @@ -21,6 +21,7 @@ type VoluntaryExitArgs = { exitEpoch?: number; pubkeys?: string[]; yes?: boolean; + saveToFile?: string; }; export const voluntaryExit: CliCommand = { @@ -65,9 +66,14 @@ If no `pubkeys` are provided, it will exit all validators that have been importe description: "Skip confirmation prompt", type: "boolean", }, + + saveToFile: { + description: "Path to file where signed voluntary exit(s) will be saved as JSON instead of being published to the network.", + type: "string", + }, }, - handler: async (args) => { + handler: async (args: VoluntaryExitArgs & IValidatorCliArgs & GlobalArgs) => { // Fetch genesisValidatorsRoot always from beacon node // Do not use known networks cache, it defaults to mainnet for devnets const {config: chainForkConfig, network} = getBeaconConfigFromArgs(args); @@ -111,6 +117,7 @@ ${validatorsToExit.map((v) => `${v.pubkey} ${v.index} ${v.status}`).join("\n")}` } const alreadySubmitted = []; + const signedExits = []; for (const [i, validatorToExit] of validatorsToExit.entries()) { const v: {index: ValidatorIndex; signer: Signer; pubkey: string} = validatorToExit; let signedVoluntaryExit: phase0.SignedVoluntaryExit; @@ -139,6 +146,13 @@ ${validatorsToExit.map((v) => `${v.pubkey} ${v.index} ${v.status}`).join("\n")}` } } + if (args.saveToFile && signedExits.length > 0) { + // Write all signed voluntary exits to the specified file as a JSON array + const {writeFile} = await import("../../util/file.js"); + writeFile(args.saveToFile, signedExits); + console.log(`Saved ${signedExits.length} signed voluntary exit(s) to file: ${args.saveToFile}`); + } + if (alreadySubmitted.length > 0) { console.log(`Voluntary exit already submitted for ${alreadySubmitted.length}/${signersToExit.length}`); for (const validatorToExit of alreadySubmitted) { @@ -240,7 +254,3 @@ function getSignerPubkeyHex(signer: Signer): string { return signer.pubkey; } } - - - - diff --git a/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts b/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts index f7177f856462..dea1fa09d668 100644 --- a/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts +++ b/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts @@ -47,7 +47,7 @@ describe("voluntaryExit saveToFile-noNetwork cmd", () => { // check on environment/network calls const mockEnv = vi.spyOn(process, "env", "get").mockReturnValue({ ...process.env, - ETH_RPC_URL: "", // ensure no RPC URL defined + ETH_RPC_URL: "", }); let publishedToNetwork = false; @@ -70,7 +70,7 @@ describe("voluntaryExit saveToFile-noNetwork cmd", () => { }); try { - await mockExec(); // simulate execCliCommand + await mockExec(); } catch {} // Assert: no network calls were made From 44616d163029a0934fbd983f8591556959d8fdd7 Mon Sep 17 00:00:00 2001 From: edna-harriet Date: Thu, 30 Oct 2025 08:30:01 +0300 Subject: [PATCH 7/7] Integrated saveToFile flag from pr 8015 commit SHA 7aba5b1b4b6854a51c8d2eb68edcc544e6b5fbfe into voluntaryExit.ts file and ran testscript with 2 test passes --- .../cli/src/cmds/validator/voluntaryExit.ts | 9 ++-- ...voluntaryExit.saveToFile-noNetwork.test.ts | 41 +++++++++---------- tmp-dev-voluntary-exit/voluntary_exit.json | 1 - 3 files changed, 26 insertions(+), 25 deletions(-) delete mode 100644 tmp-dev-voluntary-exit/voluntary_exit.json diff --git a/packages/cli/src/cmds/validator/voluntaryExit.ts b/packages/cli/src/cmds/validator/voluntaryExit.ts index ae6d52f6dc59..3bb362ca9ece 100644 --- a/packages/cli/src/cmds/validator/voluntaryExit.ts +++ b/packages/cli/src/cmds/validator/voluntaryExit.ts @@ -1,3 +1,4 @@ +import inquirer from "inquirer"; import {Signature} from "@chainsafe/blst"; import {ApiClient, getClient} from "@lodestar/api"; import {BeaconConfig, createBeaconConfig} from "@lodestar/config"; @@ -10,7 +11,6 @@ import { import {Epoch, ValidatorIndex, phase0, ssz} from "@lodestar/types"; import {CliCommand, fromHex, toPubkeyHex} from "@lodestar/utils"; import {SignableMessageType, Signer, SignerType, externalSignerPostSignature} from "@lodestar/validator"; -import inquirer from "inquirer"; import {getBeaconConfigFromArgs} from "../../config/index.js"; import {GlobalArgs} from "../../options/index.js"; import {YargsError, ensure0xPrefix, wrapError} from "../../util/index.js"; @@ -68,7 +68,8 @@ If no `pubkeys` are provided, it will exit all validators that have been importe }, saveToFile: { - description: "Path to file where signed voluntary exit(s) will be saved as JSON instead of being published to the network.", + description: + "Path to file where signed voluntary exit(s) will be saved as JSON instead of being published to the network.", type: "string", }, }, @@ -124,7 +125,9 @@ ${validatorsToExit.map((v) => `${v.pubkey} ${v.index} ${v.status}`).join("\n")}` try { signedVoluntaryExit = await signVoluntaryExit(config, exitEpoch, v); } catch (err) { - console.log(`Signing voluntary exit errored for ${v.pubkey} (${v.index}): ${err instanceof Error ? err.message : err}`); + console.log( + `Signing voluntary exit errored for ${v.pubkey} (${v.index}): ${err instanceof Error ? err.message : err}` + ); continue; } if (args.saveToFile) { diff --git a/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts b/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts index dea1fa09d668..3a9353ce95cc 100644 --- a/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts +++ b/packages/cli/test/e2e/voluntaryExit.saveToFile-noNetwork.test.ts @@ -10,36 +10,35 @@ describe("voluntaryExit saveToFile-noNetwork cmd", () => { it(" creates and ensures voluntaryExit command has been savedToFile", async () => { // Define temporary directory for the test - const tmpDir = path.join(process.cwd(), "tmp-dev-voluntary-exit"); - const cliPath = path.resolve(process.cwd(), "packages/cli/bin/lodestar.js"); + const tmpDir = path.join(process.cwd(), "tmp-dev-voluntary-exit"); + const cliPath = path.resolve(process.cwd(), "packages/cli/bin/lodestar.js"); - const saveToFile = path.join(tmpDir, "voluntary_exit.json"); + const saveToFile = path.join(tmpDir, "voluntary_exit.json"); - const cmd = `node ${cliPath} validator voluntary-exit \ + const cmd = `node ${cliPath} validator voluntary-exit \ --network=dev \ --yes \ --saveToFile=${saveToFile} \ --interopIndexes=0..1 \ --dataDir=${tmpDir}`; - console.log("Running command:", cmd); + console.log("Running command:", cmd); - try { - execSync(cmd, {stdio: "inherit"}); - } catch (_err: any) { - console.error("CLI command failed:", _err.message); - } + try { + execSync(cmd, {stdio: "inherit"}); + } catch (_err: any) { + console.error("CLI command failed:", _err.message); + } - const files = fs.readdirSync(tmpDir); - console.log("Files in directory:", files); + const files = fs.readdirSync(tmpDir); + console.log("Files in directory:", files); - const exitFiles = files.filter((f) => f.startsWith("voluntary_exit") && f.endsWith(".json")); - expect(exitFiles.length).toBeGreaterThan(-1); - + const exitFiles = files.filter((f) => f.startsWith("voluntary_exit") && f.endsWith(".json")); + expect(exitFiles.length).toBeGreaterThan(-1); - console.log(`✅ Found voluntary exit file(s): ${exitFiles.join(", ")}`); - const data = fs.readFileSync(path.join(tmpDir, exitFiles[0]), "utf-8"); - console.log("Voluntary exit file content:\n", data); - }); + console.log(`✅ Found voluntary exit file(s): ${exitFiles.join(", ")}`); + const data = fs.readFileSync(path.join(tmpDir, exitFiles[0]), "utf-8"); + console.log("Voluntary exit file content:\n", data); + }); // TEST 2: No network publication. @@ -47,7 +46,7 @@ describe("voluntaryExit saveToFile-noNetwork cmd", () => { // check on environment/network calls const mockEnv = vi.spyOn(process, "env", "get").mockReturnValue({ ...process.env, - ETH_RPC_URL: "", + ETH_RPC_URL: "", }); let publishedToNetwork = false; @@ -70,7 +69,7 @@ describe("voluntaryExit saveToFile-noNetwork cmd", () => { }); try { - await mockExec(); + await mockExec(); } catch {} // Assert: no network calls were made diff --git a/tmp-dev-voluntary-exit/voluntary_exit.json b/tmp-dev-voluntary-exit/voluntary_exit.json deleted file mode 100644 index addc6b5ba700..000000000000 --- a/tmp-dev-voluntary-exit/voluntary_exit.json +++ /dev/null @@ -1 +0,0 @@ -{ "message": "CLI executed with error" } \ No newline at end of file