diff --git a/Cargo.lock b/Cargo.lock index 372deb14..f8fa2751 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1075,6 +1075,7 @@ dependencies = [ "serde", "serde-aux", "serde_json", + "serial_test", "thiserror", "tokio", ] @@ -1098,6 +1099,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "serial_test", "thiserror", "tokio", "tracing", @@ -2794,6 +2796,28 @@ dependencies = [ "serde", ] +[[package]] +name = "serial_test" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d" +dependencies = [ + "lazy_static", + "parking_lot", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sha-1" version = "0.9.8" diff --git a/ethers-etherscan/Cargo.toml b/ethers-etherscan/Cargo.toml index 9139dfe6..ed9dd2a9 100644 --- a/ethers-etherscan/Cargo.toml +++ b/ethers-etherscan/Cargo.toml @@ -23,6 +23,7 @@ thiserror = "1.0.29" [dev-dependencies] tokio = { version = "1.5", features = ["macros", "rt-multi-thread"] } +serial_test = "0.5.1" [package.metadata.docs.rs] all-features = true diff --git a/ethers-etherscan/src/contract.rs b/ethers-etherscan/src/contract.rs index faf50661..d9e18bd3 100644 --- a/ethers-etherscan/src/contract.rs +++ b/ethers-etherscan/src/contract.rs @@ -254,7 +254,10 @@ mod tests { use crate::{contract::VerifyContract, Client}; use ethers_core::types::Chain; + use serial_test::serial; + #[tokio::test] + #[serial] #[ignore] async fn can_fetch_contract_abi() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); @@ -266,6 +269,7 @@ mod tests { } #[tokio::test] + #[serial] #[ignore] async fn can_fetch_contract_source_code() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); @@ -277,6 +281,7 @@ mod tests { } #[tokio::test] + #[serial] #[ignore] async fn can_verify_contract() { // TODO this needs further investigation diff --git a/ethers-etherscan/src/gas.rs b/ethers-etherscan/src/gas.rs index 0137ac0f..4d3c66dd 100644 --- a/ethers-etherscan/src/gas.rs +++ b/ethers-etherscan/src/gas.rs @@ -1,9 +1,10 @@ use std::{collections::HashMap, str::FromStr}; -use ethers_core::types::U256; use serde::{de, Deserialize}; use serde_aux::prelude::*; +use ethers_core::types::U256; + use crate::{Client, EtherscanError, Response, Result}; #[derive(Deserialize)] @@ -69,11 +70,14 @@ impl Client { #[cfg(test)] mod tests { + use serial_test::serial; + use ethers_core::types::Chain; use super::*; #[tokio::test] + #[serial] async fn gas_estimate_success() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); @@ -83,6 +87,7 @@ mod tests { } #[tokio::test] + #[serial] async fn gas_estimate_error() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); @@ -92,6 +97,7 @@ mod tests { } #[tokio::test] + #[serial] async fn gas_oracle_success() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); diff --git a/ethers-etherscan/src/lib.rs b/ethers-etherscan/src/lib.rs index 4c8d8e13..689e8358 100644 --- a/ethers-etherscan/src/lib.rs +++ b/ethers-etherscan/src/lib.rs @@ -1,16 +1,18 @@ //! Bindings for [etherscan.io web api](https://docs.etherscan.io/) +use std::borrow::Cow; + +use reqwest::{header, Url}; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; + +use errors::EtherscanError; +use ethers_core::{abi::Address, types::Chain}; + pub mod contract; pub mod errors; pub mod gas; pub mod transaction; -use errors::EtherscanError; -use ethers_core::{abi::Address, types::Chain}; -use reqwest::{header, Url}; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use std::borrow::Cow; - pub type Result = std::result::Result; /// The Etherscan.io API client. @@ -174,9 +176,10 @@ struct Query<'a, T: Serialize> { #[cfg(test)] mod tests { - use crate::{Client, EtherscanError}; use ethers_core::types::Chain; + use crate::{Client, EtherscanError}; + #[test] fn chain_not_supported() { let err = Client::new_from_env(Chain::XDai).unwrap_err(); diff --git a/ethers-etherscan/src/transaction.rs b/ethers-etherscan/src/transaction.rs index 260f70f3..69b1564b 100644 --- a/ethers-etherscan/src/transaction.rs +++ b/ethers-etherscan/src/transaction.rs @@ -52,10 +52,14 @@ impl Client { #[cfg(test)] mod tests { - use super::*; + use serial_test::serial; + use crate::Chain; + use super::*; + #[tokio::test] + #[serial] async fn check_contract_execution_status_success() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); @@ -69,6 +73,7 @@ mod tests { } #[tokio::test] + #[serial] async fn check_contract_execution_status_error() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); @@ -84,6 +89,7 @@ mod tests { } #[tokio::test] + #[serial] async fn check_transaction_receipt_status_success() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); @@ -97,6 +103,7 @@ mod tests { } #[tokio::test] + #[serial] async fn check_transaction_receipt_status_failed() { let client = Client::new_from_env(Chain::Mainnet).unwrap(); diff --git a/ethers-middleware/Cargo.toml b/ethers-middleware/Cargo.toml index 714a7a28..64e20d3e 100644 --- a/ethers-middleware/Cargo.toml +++ b/ethers-middleware/Cargo.toml @@ -43,6 +43,7 @@ rand = { version = "0.8.4", default-features = false } ethers-providers = { version = "^0.6.0", path = "../ethers-providers", default-features = false, features = ["ws", "rustls"] } once_cell = "1.8.0" ethers-solc = { version = "^0.1.0", path = "../ethers-solc", default-features = false } +serial_test = "0.5.1" [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tokio = { version = "1.5", default-features = false, features = ["rt", "macros", "time"] } diff --git a/ethers-middleware/tests/gas_oracle.rs b/ethers-middleware/tests/gas_oracle.rs index 916ca036..49560319 100644 --- a/ethers-middleware/tests/gas_oracle.rs +++ b/ethers-middleware/tests/gas_oracle.rs @@ -10,6 +10,7 @@ use ethers_middleware::gas_oracle::{ GasOracleMiddleware, }; use ethers_providers::{Http, Middleware, Provider}; +use serial_test::serial; #[derive(Debug)] struct FakeGasOracle { @@ -60,6 +61,7 @@ async fn eth_gas_station() { } #[tokio::test] +#[serial] async fn etherscan() { let etherscan_client = ethers_etherscan::Client::new_from_env(Chain::Mainnet).unwrap();