tests: use sepolia (#1989)
* tests: use sepolia * update ci * update sleep duration * deprecate ropsten * use goerli * fmt * keys
This commit is contained in:
parent
228f9607fe
commit
fd4da49121
|
@ -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
|
||||
|
|
|
@ -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::<Vec<_>>())
|
||||
assert_eq!(nonces, (nonce..nonce + num_tx as u64).collect::<Vec<_>>())
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ impl TestWallets {
|
|||
#[allow(unused)]
|
||||
pub async fn fund<T: JsonRpcClient, U: Into<u32>>(&self, provider: &Provider<T>, n: U) {
|
||||
let addrs = (0..n.into()).map(|i| self.get(i).address()).collect::<Vec<_>>();
|
||||
// hardcoded funder address private key, goerli
|
||||
// hardcoded funder address private key, GOERLI
|
||||
let signer = "39aa18eeb5d12c071e5f19d8e9375a872e90cb1f2fa640384ffd8800a2f3e8f1"
|
||||
.parse::<LocalWallet>()
|
||||
.unwrap()
|
||||
|
|
|
@ -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<TestProvider> = Lazy::new(|| TestProvider::new(INFURA_KEYS, "goerli"));
|
||||
pub static MAINNET: Lazy<TestProvider> =
|
||||
Lazy::new(|| TestProvider::new(INFURA_KEYS, "mainnet"));
|
||||
pub static GOERLI: Lazy<TestProvider> = Lazy::new(|| TestProvider::new(INFURA_KEYS, "goerli"));
|
||||
pub static SEPOLIA: Lazy<TestProvider> =
|
||||
Lazy::new(|| TestProvider::new(INFURA_KEYS, "sepolia"));
|
||||
|
||||
#[deprecated = "Ropsten testnet has been deprecated in favor of Goerli or Sepolia."]
|
||||
pub static ROPSTEN: Lazy<TestProvider> =
|
||||
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<String>) -> 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<Http> {
|
||||
|
|
Loading…
Reference in New Issue