Skip to content

Commit 6337fa1

Browse files
committed
Tests nits
1 parent 622aed4 commit 6337fa1

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

crates/test-utils/src/rpc.rs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ static DRPC_KEYS: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
4141
])
4242
});
4343

44-
// List of etherscan keys for mainnet
45-
static ETHERSCAN_MAINNET_KEYS: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
44+
// List of etherscan keys.
45+
static ETHERSCAN_KEYS: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
4646
shuffled(vec![
4747
"MCAUM7WPE9XP5UQMZPCKIBUJHPM1C24FP6",
4848
"JW6RWCG2C5QF8TANH4KC7AYIF1CX7RB5D1",
@@ -54,8 +54,6 @@ static ETHERSCAN_MAINNET_KEYS: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
5454
"A15KZUMZXXCK1P25Y1VP1WGIVBBHIZDS74",
5555
"3IA6ASNQXN8WKN7PNFX7T72S9YG56X9FPG",
5656
"ZUB97R31KSYX7NYVW6224Q6EYY6U56H591",
57-
// Optimism
58-
// "JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46",
5957
])
6058
});
6159

@@ -139,7 +137,7 @@ fn archive_urls(is_ws: bool) -> &'static [String] {
139137

140138
/// Returns the next etherscan api key.
141139
pub fn next_etherscan_api_key() -> String {
142-
let key = next(&ETHERSCAN_MAINNET_KEYS).to_string();
140+
let key = next(&ETHERSCAN_KEYS).to_string();
143141
eprintln!("--- next_etherscan_api_key() = {key} ---");
144142
key
145143
}
@@ -188,6 +186,7 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String {
188186
mod tests {
189187
use super::*;
190188
use alloy_primitives::address;
189+
use foundry_block_explorers::EtherscanApiVersion;
191190
use foundry_config::Chain;
192191

193192
#[tokio::test]
@@ -196,7 +195,7 @@ mod tests {
196195
let address = address!("0xdAC17F958D2ee523a2206206994597C13D831ec7");
197196
let mut first_abi = None;
198197
let mut failed = Vec::new();
199-
for (i, &key) in ETHERSCAN_MAINNET_KEYS.iter().enumerate() {
198+
for (i, &key) in ETHERSCAN_KEYS.iter().enumerate() {
200199
println!("trying key {i} ({key})");
201200

202201
let client = foundry_block_explorers::Client::builder()
@@ -231,4 +230,32 @@ mod tests {
231230
panic!("failed keys: {failed:#?}");
232231
}
233232
}
233+
234+
#[tokio::test]
235+
#[ignore = "run manually"]
236+
async fn test_etherscan_keys_compatibility() {
237+
let address = address!("0x111111125421cA6dc452d289314280a0f8842A65");
238+
let ehterscan_key = "JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46";
239+
let client = foundry_block_explorers::Client::builder()
240+
.with_api_key(ehterscan_key)
241+
.chain(Chain::optimism_mainnet())
242+
.unwrap()
243+
.build()
244+
.unwrap();
245+
if client.contract_abi(address).await.is_ok() {
246+
panic!("v1 Optimisim key should not work with v2 version")
247+
}
248+
249+
let client = foundry_block_explorers::Client::builder()
250+
.with_api_key(ehterscan_key)
251+
.with_api_version(EtherscanApiVersion::V1)
252+
.chain(Chain::optimism_mainnet())
253+
.unwrap()
254+
.build()
255+
.unwrap();
256+
match client.contract_abi(address).await {
257+
Ok(_) => {}
258+
Err(_) => panic!("v1 Optimisim key should work with v1 version"),
259+
};
260+
}
234261
}

0 commit comments

Comments
 (0)