Skip to content

Commit

Permalink
chore: get network config from foundry.toml (#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
iosh authored Oct 28, 2024
1 parent 6aa79e3 commit a6f3de6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions crates/tools/js/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"mocha": "^10.0.0",
"prettier": "^3.2.5",
"simple-git": "^3.25.0",
"smol-toml": "^1.3.0",
"tsx": "^4.7.1",
"typescript": "~5.5.3"
},
Expand Down
25 changes: 16 additions & 9 deletions crates/tools/js/benchmark/src/solidity-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
Baseline
Source: https://github.com/NomicFoundation/forge-std/tree/js-benchmark-config
Expand Down Expand Up @@ -27,6 +27,7 @@ import {
ArtifactId,
ContractData,
} from "@ignored/edr";
import TOML from "smol-toml";

// This is automatically cached in CI
const RPC_CACHE_PATH = "./edr-cache";
Expand Down Expand Up @@ -94,7 +95,6 @@ export async function runForgeStdTests(forgeStdRepoPath: string) {
);

const config = getConfig(forgeStdRepoPath);

const allResults = [];
const runs = new Map<string, number[]>();
const recordRun = recordTime.bind(null, runs);
Expand Down Expand Up @@ -162,20 +162,27 @@ export async function runForgeStdTests(forgeStdRepoPath: string) {
}

function getConfig(forgeStdRepoPath: string): SolidityTestRunnerConfigArgs {
const foundryTomlPath = path.join(forgeStdRepoPath, "foundry.toml");

if (!fs.existsSync(foundryTomlPath)) {
throw new Error(`Get config failed: could not find ${foundryTomlPath}`);
}
const foundryToml = fs.readFileSync(foundryTomlPath, "utf8");
const foundryTomlConfig = TOML.parse(foundryToml);

const rpcEndpoints = foundryTomlConfig.rpc_endpoints as Record<
string,
string
>;

return {
projectRoot: forgeStdRepoPath,
rpcCachePath: RPC_CACHE_PATH,
fsPermissions: [
{ path: forgeStdRepoPath, access: FsAccessPermission.ReadWrite },
],
testFail: true,
rpcEndpoints: {
// These are hardcoded in the `forge-std` foundry.toml
mainnet:
"https://eth-mainnet.alchemyapi.io/v2/WV407BEiBmjNJfKo9Uo_55u0z0ITyCOX",
optimism_sepolia: "https://sepolia.optimism.io/",
arbitrum_one_sepolia: "https://sepolia-rollup.arbitrum.io/rpc/",
},
rpcEndpoints,
fuzz: {
// Used to ensure deterministic fuzz execution
seed: "0x1234567890123456789012345678901234567890",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a6f3de6

Please sign in to comment.