diff --git a/ethers-middleware/tests/gas_escalator.rs b/ethers-middleware/tests/gas_escalator.rs index c2bfbad6..66d7d4ff 100644 --- a/ethers-middleware/tests/gas_escalator.rs +++ b/ethers-middleware/tests/gas_escalator.rs @@ -13,6 +13,7 @@ use std::time::Duration; #[ignore] async fn gas_escalator_live() { // connect to ropsten for getting bad block times + #[allow(deprecated)] let provider = ethers_providers::ROPSTEN.ws().await; let provider = provider.interval(Duration::from_millis(2000u64)); let wallet = "fdb33e2105f08abe41a8ee3b758726a31abdd57b7a443f470f23efce853af169" @@ -34,7 +35,7 @@ async fn gas_escalator_live() { provider.send_transaction(tx.clone().nonce(nonce + 2), None).await.unwrap(); // Wait a bunch of seconds and refresh etherscan to see the transactions get bumped - tokio::time::sleep(std::time::Duration::from_secs(100)).await; + tokio::time::sleep(Duration::from_secs(100)).await; // TODO: Figure out how to test this behavior properly in a local network. If the gas price was // bumped then the tx hash will be different diff --git a/ethers-middleware/tests/nonce_manager.rs b/ethers-middleware/tests/nonce_manager.rs index a1c74915..1be27fec 100644 --- a/ethers-middleware/tests/nonce_manager.rs +++ b/ethers-middleware/tests/nonce_manager.rs @@ -8,7 +8,7 @@ use std::time::Duration; #[tokio::test] async fn nonce_manager() { - let provider = ethers_providers::GOERLI.provider().interval(Duration::from_millis(2000u64)); + let provider = ethers_providers::GOERLI.provider().interval(Duration::from_millis(2000)); let chain_id = provider.get_chainid().await.unwrap().as_u64(); let wallet = std::env::var("GOERLI_PRIVATE_KEY") @@ -44,12 +44,12 @@ async fn nonce_manager() { } // sleep a bit to ensure there's no flakiness in the test - std::thread::sleep(std::time::Duration::new(5, 0)); + tokio::time::sleep(Duration::from_secs(10)).await; let mut nonces = Vec::with_capacity(num_tx); for tx_hash in tx_hashes { nonces.push(provider.get_transaction(tx_hash).await.unwrap().unwrap().nonce.as_u64()); } - assert_eq!(nonces, (nonce..nonce + (num_tx as u64)).collect::>()) + assert_eq!(nonces, (nonce..nonce + num_tx as u64).collect::>()) } diff --git a/ethers-middleware/tests/signer.rs b/ethers-middleware/tests/signer.rs index 9c2176ed..eecd1e65 100644 --- a/ethers-middleware/tests/signer.rs +++ b/ethers-middleware/tests/signer.rs @@ -294,7 +294,7 @@ impl TestWallets { #[allow(unused)] pub async fn fund>(&self, provider: &Provider, n: U) { let addrs = (0..n.into()).map(|i| self.get(i).address()).collect::>(); - // hardcoded funder address private key, goerli + // hardcoded funder address private key, GOERLI let signer = "39aa18eeb5d12c071e5f19d8e9375a872e90cb1f2fa640384ffd8800a2f3e8f1" .parse::() .unwrap() diff --git a/ethers-providers/src/lib.rs b/ethers-providers/src/lib.rs index b7825682..31ef49fe 100644 --- a/ethers-providers/src/lib.rs +++ b/ethers-providers/src/lib.rs @@ -723,7 +723,8 @@ pub trait CeloMiddleware: Middleware { } } -pub use test_provider::{GOERLI, MAINNET, ROPSTEN}; +#[allow(deprecated)] +pub use test_provider::{GOERLI, MAINNET, ROPSTEN, SEPOLIA}; /// Pre-instantiated Infura HTTP clients which rotate through multiple API keys /// to prevent rate limits @@ -743,9 +744,13 @@ pub mod test_provider { "5c812e02193c4ba793f8c214317582bd", ]; - pub static GOERLI: Lazy = Lazy::new(|| TestProvider::new(INFURA_KEYS, "goerli")); pub static MAINNET: Lazy = Lazy::new(|| TestProvider::new(INFURA_KEYS, "mainnet")); + pub static GOERLI: Lazy = Lazy::new(|| TestProvider::new(INFURA_KEYS, "goerli")); + pub static SEPOLIA: Lazy = + Lazy::new(|| TestProvider::new(INFURA_KEYS, "sepolia")); + + #[deprecated = "Ropsten testnet has been deprecated in favor of Goerli or Sepolia."] pub static ROPSTEN: Lazy = Lazy::new(|| TestProvider::new(INFURA_KEYS, "ropsten")); @@ -756,16 +761,14 @@ pub mod test_provider { } impl TestProvider { - pub fn new(keys: &'static [&'static str], network: &str) -> Self { - Self { keys: Mutex::new(keys.iter().cycle()), network: network.to_owned() } + pub fn new(keys: &'static [&'static str], network: impl Into) -> Self { + Self { keys: keys.iter().cycle().into(), network: network.into() } } pub fn url(&self) -> String { - format!( - "https://{}.infura.io/v3/{}", - self.network, - self.keys.lock().unwrap().next().unwrap() - ) + let Self { network, keys } = self; + let key = keys.lock().unwrap().next().unwrap(); + format!("https://{network}.infura.io/v3/{key}") } pub fn provider(&self) -> Provider {