Skip to content

Commit

Permalink
test: add alias test (#6585)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 12, 2023
1 parent cdbaf9d commit 7d21fe7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ alloy-json-abi = "0.5.0"
alloy-sol-types = "0.5.0"
syn-solidity = "0.5.0"

alloy-chains = "0.1.4"
alloy-chains = "0.1.5"
alloy-rlp = "0.3.3"
solang-parser = "=0.3.3"

Expand Down
4 changes: 3 additions & 1 deletion crates/config/src/etherscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ impl EtherscanConfig {
Ok(ResolvedEtherscanConfig { api_url, browser_url: None, key, chain: None })
}
(None, None) => {
let msg = alias.map(|a| format!(" for Etherscan config `{a}`")).unwrap_or_default();
let msg = alias
.map(|a| format!(" for Etherscan config with unknown alias `{a}`"))
.unwrap_or_default();
Err(EtherscanConfigError::MissingUrlOrChain(msg))
}
}
Expand Down
27 changes: 27 additions & 0 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3089,6 +3089,33 @@ mod tests {
})
}

#[test]
fn test_resolve_rpc_aliases() {
figment::Jail::expect_with(|jail| {
jail.create_file(
"foundry.toml",
r#"
[profile.default]
[etherscan]
arbitrum_alias = { key = "${TEST_RESOLVE_RPC_ALIAS_ARBISCAN}" }
[rpc_endpoints]
arbitrum_alias = "https://arb-mainnet.g.alchemy.com/v2/${TEST_RESOLVE_RPC_ALIAS_ARB_ONE}"
"#,
)?;

jail.set_env("TEST_RESOLVE_RPC_ALIAS_ARB_ONE", "123455");
jail.set_env("TEST_RESOLVE_RPC_ALIAS_ARBISCAN", "123455");

let config = Config::load();

let config = config.get_etherscan_config_with_chain(Some(NamedChain::Arbitrum.into()));
assert!(config.is_err());
assert_eq!(config.unwrap_err().to_string(), "At least one of `url` or `chain` must be present for Etherscan config with unknown alias `arbitrum_alias`");

Ok(())
});
}

#[test]
fn test_resolve_endpoints() {
figment::Jail::expect_with(|jail| {
Expand Down

0 comments on commit 7d21fe7

Please sign in to comment.