From 08113906a4febe7e42a5ec10c638f83cbd879fef Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 16 Apr 2026 11:53:15 +0000 Subject: [PATCH] fix(aztec): respect TEST_ACCOUNTS env var in local network mode The `TEST_ACCOUNTS` env var was ignored when running `aztec start --local-network` because `testAccounts` was hardcoded to `true` in `aztec_start_action.ts`. This adds a proper CLI option bound to the env var (defaulting to `true`) and fixes the namespace extraction which was silently broken due to Commander camelCasing the prefix. Co-Authored-By: Claude Opus 4.6 (1M context) --- yarn-project/aztec/src/cli/aztec_start_action.ts | 3 +-- .../aztec/src/cli/aztec_start_options.test.ts | 15 +++++++++++++++ yarn-project/aztec/src/cli/aztec_start_options.ts | 6 ++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/yarn-project/aztec/src/cli/aztec_start_action.ts b/yarn-project/aztec/src/cli/aztec_start_action.ts index 7a3c3331a4a4..7b03c921e83e 100644 --- a/yarn-project/aztec/src/cli/aztec_start_action.ts +++ b/yarn-project/aztec/src/cli/aztec_start_action.ts @@ -27,8 +27,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg let config: ChainConfig | undefined = undefined; if (options.localNetwork) { - const localNetwork = extractNamespacedOptions(options, 'local-network'); - localNetwork.testAccounts = true; + const localNetwork = extractNamespacedOptions(options, 'localNetwork'); userLog(`${splash}\n${github}\n\n`); userLog(`Setting up Aztec local network ${packageVersion ?? 'unknown'}, please stand by...`); diff --git a/yarn-project/aztec/src/cli/aztec_start_options.test.ts b/yarn-project/aztec/src/cli/aztec_start_options.test.ts index 057e459467bc..befe8bedf91a 100644 --- a/yarn-project/aztec/src/cli/aztec_start_options.test.ts +++ b/yarn-project/aztec/src/cli/aztec_start_options.test.ts @@ -94,6 +94,21 @@ describe('aztec_start_options commander integration', () => { expect(typeof opts.port).toBe('number'); }); + it('respects TEST_ACCOUNTS env var for local network', () => { + process.env.TEST_ACCOUNTS = 'false'; + const cmd = buildCommandWith(['LOCAL_NETWORK']); + cmd.parse(['node', 'cli']); + const opts = cmd.opts(); + expect(opts['localNetwork.testAccounts']).toBe(false); + }); + + it('defaults testAccounts to true for local network', () => { + const cmd = buildCommandWith(['LOCAL_NETWORK']); + cmd.parse(['node', 'cli']); + const opts = cmd.opts(); + expect(opts['localNetwork.testAccounts']).toBe(true); + }); + it('parses optional boolean flag values', () => { const cmd = buildCommandWith(['P2P SUBSYSTEM']); diff --git a/yarn-project/aztec/src/cli/aztec_start_options.ts b/yarn-project/aztec/src/cli/aztec_start_options.ts index 3034ceea504c..b4c85349f9cb 100644 --- a/yarn-project/aztec/src/cli/aztec_start_options.ts +++ b/yarn-project/aztec/src/cli/aztec_start_options.ts @@ -129,6 +129,12 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = { defaultValue: DefaultMnemonic, env: 'MNEMONIC', }, + { + flag: '--local-network.testAccounts', + description: 'Deploy test accounts on local network start', + env: 'TEST_ACCOUNTS', + ...booleanConfigHelper(true), + }, ], API: [ {