Skip to content

Commit

Permalink
optionally still provide an external anvil to e2e tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
charlielye committed Mar 30, 2024
1 parent d0e32bf commit 871c44c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion yarn-project/archiver/src/archiver/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function getConfigEnvVars(): ArchiverConfig {
: EthAddress.ZERO,
};
return {
rpcUrl: ETHEREUM_HOST || 'http://127.0.0.1:8545/',
rpcUrl: ETHEREUM_HOST || '',
archiverPollingIntervalMS: ARCHIVER_POLLING_INTERVAL_MS ? +ARCHIVER_POLLING_INTERVAL_MS : 1_000,
viemPollingIntervalMS: ARCHIVER_VIEM_POLLING_INTERVAL_MS ? +ARCHIVER_VIEM_POLLING_INTERVAL_MS : 1_000,
apiKey: API_KEY,
Expand Down
20 changes: 12 additions & 8 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { getCanonicalGasToken, getCanonicalGasTokenAddress } from '@aztec/protoc
import { PXEService, PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe';
import { SequencerClient } from '@aztec/sequencer-client';

import { createAnvil } from '@viem/anvil';
import { type Anvil, createAnvil } from '@viem/anvil';
import * as fs from 'fs/promises';
import getPort from 'get-port';
import * as path from 'path';
Expand Down Expand Up @@ -333,12 +333,16 @@ export async function setup(
): Promise<EndToEndContext> {
const config = { ...getConfigEnvVars(), ...opts };

// 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 });
await anvil.start();
let anvil: Anvil | undefined;

if (!config.rpcUrl) {
// 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 });
await anvil.start();
}

// Enable logging metrics to a local file named after the test suite
if (isMetricsLoggingRequested()) {
Expand Down Expand Up @@ -400,7 +404,7 @@ export async function setup(
await fs.rm(acvmConfig.directoryToCleanup, { recursive: true, force: true });
}

await anvil.stop();
await anvil?.stop();
};

return {
Expand Down

0 comments on commit 871c44c

Please sign in to comment.