Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: get network config from foundry.toml #715

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading