Skip to content

Commit

Permalink
chore: more fixes for --all-features tests (foundry-rs#8946)
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy authored and rplusq committed Sep 25, 2024
1 parent 6ec15a8 commit c53b02b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
6 changes: 5 additions & 1 deletion crates/anvil/tests/it/anvil_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ async fn can_remove_pool_transactions() {

#[tokio::test(flavor = "multi_thread")]
async fn test_reorg() {
let (api, handle) = spawn(NodeConfig::test()).await;
let (api, mut handle) = spawn(NodeConfig::test()).await;
let provider = handle.ws_provider();

let accounts = handle.dev_wallets().collect::<Vec<_>>();
Expand Down Expand Up @@ -792,4 +792,8 @@ async fn test_reorg() {
})
.await;
assert!(res.is_err());

if let Some(signal) = handle.shutdown_signal_mut().take() {
signal.fire().unwrap();
}
}
6 changes: 5 additions & 1 deletion crates/anvil/tests/it/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async fn test_tip_above_fee_cap() {
#[tokio::test(flavor = "multi_thread")]
async fn test_can_use_fee_history() {
let base_fee = 50u128;
let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await;
let (_api, mut handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await;
let provider = handle.http_provider();

for _ in 0..10 {
Expand All @@ -200,4 +200,8 @@ async fn test_can_use_fee_history() {
assert_eq!(latest_block.header.base_fee_per_gas.unwrap(), *latest_fee_history_fee);
assert_eq!(latest_fee_history_fee, next_base_fee);
}

if let Some(signal) = handle.shutdown_signal_mut().take() {
signal.fire().unwrap();
}
}
6 changes: 5 additions & 1 deletion crates/anvil/tests/it/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,16 @@ async fn test_storage_proof() {

#[tokio::test(flavor = "multi_thread")]
async fn can_get_random_account_proofs() {
let (api, _handle) = spawn(NodeConfig::test()).await;
let (api, mut handle) = spawn(NodeConfig::test()).await;

for acc in std::iter::repeat_with(Address::random).take(10) {
let _ = api
.get_proof(acc, Vec::new(), None)
.await
.unwrap_or_else(|_| panic!("Failed to get proof for {acc:?}"));
}

if let Some(signal) = handle.shutdown_signal_mut().take() {
signal.fire().unwrap();
}
}
6 changes: 5 additions & 1 deletion crates/anvil/tests/it/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ async fn test_trace_address_fork2() {

#[tokio::test(flavor = "multi_thread")]
async fn test_trace_filter() {
let (api, handle) = spawn(NodeConfig::test()).await;
let (api, mut handle) = spawn(NodeConfig::test()).await;
let provider = handle.ws_provider();

let accounts = handle.dev_wallets().collect::<Vec<_>>();
Expand Down Expand Up @@ -859,4 +859,8 @@ async fn test_trace_filter() {

let traces = api.trace_filter(tracer).await.unwrap();
assert_eq!(traces.len(), 5);

if let Some(signal) = handle.shutdown_signal_mut().take() {
signal.fire().unwrap();
}
}
1 change: 1 addition & 0 deletions crates/cast/tests/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ casttest!(storage, |_prj, cmd| {
"#]]);

let rpc = next_http_rpc_endpoint();
cmd.cast_fuse()
.args(["storage", usdt, total_supply_slot, "--rpc-url", &rpc, "--block", block_after])
.assert_success()
Expand Down
3 changes: 3 additions & 0 deletions crates/forge/tests/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ forgetest_init!(can_override_config, |prj, cmd| {
);

// env vars work
std::env::remove_var("DAPP_REMAPPINGS");
std::env::set_var("DAPP_REMAPPINGS", "ds-test/=lib/forge-std/lib/ds-test/from-env/");
let config = forge_utils::load_config_with_root(Some(prj.root()));
assert_eq!(
Expand Down Expand Up @@ -517,13 +518,15 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| {
);

// create a new lib directly in the `lib` folder with a remapping
std::env::remove_var("DAPP_REMAPPINGS");
let mut config = config;
config.remappings = vec![Remapping::from_str("nested/=lib/nested").unwrap().into()];
let nested = prj.paths().libraries[0].join("nested-lib");
pretty_err(&nested, fs::create_dir_all(&nested));
let toml_file = nested.join("foundry.toml");
pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap()));

std::env::remove_var("DAPP_REMAPPINGS");
let config = cmd.config();
let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::<Vec<_>>();
similar_asserts::assert_eq!(
Expand Down
1 change: 1 addition & 0 deletions crates/forge/tests/cli/verify_bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn test_verify_bytecode(
prj.add_source(contract_name, &source_code).unwrap();
prj.write_config(config);

let etherscan_key = next_mainnet_etherscan_api_key();
let mut args = vec![
"verify-bytecode",
addr,
Expand Down

0 comments on commit c53b02b

Please sign in to comment.