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

(feat): accept ETH_RPC_URL env as fork-url alias #8972

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ pub struct AnvilEvmArgs {
long,
short,
visible_alias = "rpc-url",
env = "ETH_RPC_URL",
value_name = "URL",
help_heading = "Fork config"
)]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct EvmArgs {
/// Fetch state over a remote endpoint instead of starting from an empty state.
///
/// If you want to fetch state from a specific block number, see --fork-block-number.
#[arg(long, short, visible_alias = "rpc-url", value_name = "URL")]
#[arg(long, short, visible_alias = "rpc-url", env = "ETH_RPC_URL", value_name = "URL")]
#[serde(rename = "eth_rpc_url", skip_serializing_if = "Option::is_none")]
pub fork_url: Option<String>,

Expand Down
4 changes: 4 additions & 0 deletions crates/forge/tests/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,17 @@ forgetest!(can_extract_config_values, |prj, cmd| {
_non_exhaustive: (),
};
prj.write_config(input.clone());
cmd.unset_env("ETH_RPC_URL");
let config = cmd.config();
similar_asserts::assert_eq!(input, config);
});

// tests config gets printed to std out
forgetest!(can_show_config, |prj, cmd| {
println!("prj.root {}", prj.root().display());
let expected =
Config::load_with_root(prj.root()).to_string_pretty().unwrap().trim().to_string();
cmd.unset_env("ETH_RPC_URL");
let output = cmd.arg("config").assert_success().get_output().stdout_lossy().trim().to_string();
assert_eq!(expected, output);
});
Expand Down Expand Up @@ -191,6 +194,7 @@ forgetest_init!(can_override_config, |prj, cmd| {
);

let expected = profile.to_string_pretty().unwrap().trim().to_string();
cmd.unset_env("ETH_RPC_URL");
let output = cmd.arg("config").assert_success().get_output().stdout_lossy().trim().to_string();
assert_eq!(expected, output);

Expand Down
5 changes: 5 additions & 0 deletions crates/forge/tests/cli/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ contract Demo {
)
.unwrap();

cmd.unset_env("ETH_RPC_URL");
cmd.arg("script").arg(format!("{}:Demo", script.display())).assert_success().stdout_eq(str![[
r#"
...
Expand Down Expand Up @@ -1286,6 +1287,7 @@ result: uint256 255

forgetest_async!(can_run_script_with_empty_setup, |prj, cmd| {
let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root());
tester.cmd.unset_env("ETH_RPC_URL");

tester.add_sig("BroadcastEmptySetUp", "run()").simulate(ScriptOutcome::OkNoEndpoint);
});
Expand Down Expand Up @@ -1462,6 +1464,7 @@ interface Interface {}
)
.unwrap();

cmd.unset_env("ETH_RPC_URL");
cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#"
[COMPILING_FILES] with [SOLC_VERSION]
[SOLC_VERSION] [ELAPSED]
Expand Down Expand Up @@ -1555,13 +1558,15 @@ contract ScriptC {}

let mut tester = ScriptTester::new(cmd, None, prj.root(), "script/B.sol");
tester.cmd.forge_fuse().args(["script", "script/B.sol"]);
tester.cmd.unset_env("ETH_RPC_URL");
tester.simulate(ScriptOutcome::OkNoEndpoint);
});

forgetest_async!(can_sign_with_script_wallet_single, |prj, cmd| {
foundry_test_utils::util::initialize(prj.root());

let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root());
tester.cmd.unset_env("ETH_RPC_URL");
tester
.add_sig("ScriptSign", "run()")
.load_private_keys(&[0])
Expand Down
Loading