make etherscan tests serial

This commit is contained in:
Alexey Shekhirin 2021-11-25 09:57:22 +03:00
parent 1d2746fdde
commit 20948d9fe5
No known key found for this signature in database
GPG Key ID: AF9A26AA133B5B98
8 changed files with 58 additions and 9 deletions

24
Cargo.lock generated
View File

@ -1075,6 +1075,7 @@ dependencies = [
"serde", "serde",
"serde-aux", "serde-aux",
"serde_json", "serde_json",
"serial_test",
"thiserror", "thiserror",
"tokio", "tokio",
] ]
@ -1098,6 +1099,7 @@ dependencies = [
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"serial_test",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing", "tracing",
@ -2794,6 +2796,28 @@ dependencies = [
"serde", "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]] [[package]]
name = "sha-1" name = "sha-1"
version = "0.9.8" version = "0.9.8"

View File

@ -23,6 +23,7 @@ thiserror = "1.0.29"
[dev-dependencies] [dev-dependencies]
tokio = { version = "1.5", features = ["macros", "rt-multi-thread"] } tokio = { version = "1.5", features = ["macros", "rt-multi-thread"] }
serial_test = "0.5.1"
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -254,7 +254,10 @@ mod tests {
use crate::{contract::VerifyContract, Client}; use crate::{contract::VerifyContract, Client};
use ethers_core::types::Chain; use ethers_core::types::Chain;
use serial_test::serial;
#[tokio::test] #[tokio::test]
#[serial]
#[ignore] #[ignore]
async fn can_fetch_contract_abi() { async fn can_fetch_contract_abi() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();
@ -266,6 +269,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[serial]
#[ignore] #[ignore]
async fn can_fetch_contract_source_code() { async fn can_fetch_contract_source_code() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();
@ -277,6 +281,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[serial]
#[ignore] #[ignore]
async fn can_verify_contract() { async fn can_verify_contract() {
// TODO this needs further investigation // TODO this needs further investigation

View File

@ -1,9 +1,10 @@
use std::{collections::HashMap, str::FromStr}; use std::{collections::HashMap, str::FromStr};
use ethers_core::types::U256;
use serde::{de, Deserialize}; use serde::{de, Deserialize};
use serde_aux::prelude::*; use serde_aux::prelude::*;
use ethers_core::types::U256;
use crate::{Client, EtherscanError, Response, Result}; use crate::{Client, EtherscanError, Response, Result};
#[derive(Deserialize)] #[derive(Deserialize)]
@ -69,11 +70,14 @@ impl Client {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use serial_test::serial;
use ethers_core::types::Chain; use ethers_core::types::Chain;
use super::*; use super::*;
#[tokio::test] #[tokio::test]
#[serial]
async fn gas_estimate_success() { async fn gas_estimate_success() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();
@ -83,6 +87,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[serial]
async fn gas_estimate_error() { async fn gas_estimate_error() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();
@ -92,6 +97,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[serial]
async fn gas_oracle_success() { async fn gas_oracle_success() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();

View File

@ -1,16 +1,18 @@
//! Bindings for [etherscan.io web api](https://docs.etherscan.io/) //! 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 contract;
pub mod errors; pub mod errors;
pub mod gas; pub mod gas;
pub mod transaction; 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<T> = std::result::Result<T, EtherscanError>; pub type Result<T> = std::result::Result<T, EtherscanError>;
/// The Etherscan.io API client. /// The Etherscan.io API client.
@ -174,9 +176,10 @@ struct Query<'a, T: Serialize> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{Client, EtherscanError};
use ethers_core::types::Chain; use ethers_core::types::Chain;
use crate::{Client, EtherscanError};
#[test] #[test]
fn chain_not_supported() { fn chain_not_supported() {
let err = Client::new_from_env(Chain::XDai).unwrap_err(); let err = Client::new_from_env(Chain::XDai).unwrap_err();

View File

@ -52,10 +52,14 @@ impl Client {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use serial_test::serial;
use crate::Chain; use crate::Chain;
use super::*;
#[tokio::test] #[tokio::test]
#[serial]
async fn check_contract_execution_status_success() { async fn check_contract_execution_status_success() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();
@ -69,6 +73,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[serial]
async fn check_contract_execution_status_error() { async fn check_contract_execution_status_error() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();
@ -84,6 +89,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[serial]
async fn check_transaction_receipt_status_success() { async fn check_transaction_receipt_status_success() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();
@ -97,6 +103,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[serial]
async fn check_transaction_receipt_status_failed() { async fn check_transaction_receipt_status_failed() {
let client = Client::new_from_env(Chain::Mainnet).unwrap(); let client = Client::new_from_env(Chain::Mainnet).unwrap();

View File

@ -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"] } ethers-providers = { version = "^0.6.0", path = "../ethers-providers", default-features = false, features = ["ws", "rustls"] }
once_cell = "1.8.0" once_cell = "1.8.0"
ethers-solc = { version = "^0.1.0", path = "../ethers-solc", default-features = false } 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] [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
tokio = { version = "1.5", default-features = false, features = ["rt", "macros", "time"] } tokio = { version = "1.5", default-features = false, features = ["rt", "macros", "time"] }

View File

@ -10,6 +10,7 @@ use ethers_middleware::gas_oracle::{
GasOracleMiddleware, GasOracleMiddleware,
}; };
use ethers_providers::{Http, Middleware, Provider}; use ethers_providers::{Http, Middleware, Provider};
use serial_test::serial;
#[derive(Debug)] #[derive(Debug)]
struct FakeGasOracle { struct FakeGasOracle {
@ -60,6 +61,7 @@ async fn eth_gas_station() {
} }
#[tokio::test] #[tokio::test]
#[serial]
async fn etherscan() { async fn etherscan() {
let etherscan_client = ethers_etherscan::Client::new_from_env(Chain::Mainnet).unwrap(); let etherscan_client = ethers_etherscan::Client::new_from_env(Chain::Mainnet).unwrap();