From 9ff45f69af562db4cec69c6231659476667f1cf9 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Thu, 11 Apr 2024 09:29:46 +0100 Subject: [PATCH] fix: don't run e2e tests against wrong anvil (#5686) This PR fixes an issue when running e2e tests locally against an already running instance of aztec --- yarn-project/end-to-end/src/fixtures/utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index e9fcce89357..af9158fdd10 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -330,12 +330,20 @@ export async function setup( let anvil: Anvil | undefined; + // spawn an anvil instance if one isn't already running + // and we're not connecting to a remote PXE if (!config.rpcUrl) { + if (PXE_URL) { + throw new Error( + `PXE_URL provided but no ETHEREUM_HOST set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`, + ); + } + // Start anvil. // We go via a wrapper script to ensure if the parent dies, anvil dies. const ethereumHostPort = await getPort(); config.rpcUrl = `http://localhost:${ethereumHostPort}`; - const anvil = createAnvil({ anvilBinary: './scripts/anvil_kill_wrapper.sh', port: ethereumHostPort }); + anvil = createAnvil({ anvilBinary: './scripts/anvil_kill_wrapper.sh', port: ethereumHostPort }); await anvil.start(); }