From 49a8ede734f076197c6ce4940f9b11c9ac2a9638 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 29 May 2023 14:06:24 +0200 Subject: [PATCH] chore: update CI and fix clippy (#2446) --- .github/workflows/ci.yml | 2 +- ethers-contract/src/lib.rs | 8 ++++---- ethers-core/src/abi/mod.rs | 10 +++++----- ethers-middleware/src/signer.rs | 2 +- ethers-providers/src/rpc/provider.rs | 1 - ethers-providers/src/rpc/transports/ws/mod.rs | 2 +- ethers-providers/src/stream/tx_stream.rs | 18 +++++++++--------- ethers-providers/tests/it/main.rs | 2 +- ethers-providers/tests/it/provider.rs | 2 +- ethers-solc/src/artifacts/mod.rs | 5 +---- ethers-solc/src/compile/project.rs | 2 +- 11 files changed, 25 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f215a01d..3b2fa5766 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,7 +99,7 @@ jobs: - uses: taiki-e/install-action@cargo-hack - uses: Swatinem/rust-cache@v2 - name: cargo hack - run: cargo hack check --feature-powerset --depth 1 --no-dev-deps + run: cargo hack check --feature-powerset --depth 1 --all-targets clippy: name: clippy diff --git a/ethers-contract/src/lib.rs b/ethers-contract/src/lib.rs index 1d8b6213a..b23524785 100644 --- a/ethers-contract/src/lib.rs +++ b/ethers-contract/src/lib.rs @@ -27,10 +27,10 @@ pub use log::{decode_logs, EthLogDecode, LogMeta}; pub mod stream; -#[cfg(any(test, feature = "abigen"))] +#[cfg(feature = "abigen")] #[cfg_attr(docsrs, doc(cfg(feature = "abigen")))] mod multicall; -#[cfg(any(test, feature = "abigen"))] +#[cfg(feature = "abigen")] #[cfg_attr(docsrs, doc(cfg(feature = "abigen")))] pub use multicall::{ constants::{MULTICALL_ADDRESS, MULTICALL_SUPPORTED_CHAIN_IDS}, @@ -50,13 +50,13 @@ pub mod builders { }; } -#[cfg(any(test, feature = "abigen"))] +#[cfg(feature = "abigen")] #[cfg_attr(docsrs, doc(cfg(feature = "abigen")))] pub use ethers_contract_abigen::{ Abigen, ContractFilter, ExcludeContracts, InternalStructs, MultiAbigen, SelectContracts, }; -#[cfg(any(test, feature = "abigen"))] +#[cfg(feature = "abigen")] #[cfg_attr(docsrs, doc(cfg(feature = "abigen")))] pub use ethers_contract_derive::{ abigen, Eip712, EthAbiCodec, EthAbiType, EthCall, EthDisplay, EthError, EthEvent, diff --git a/ethers-core/src/abi/mod.rs b/ethers-core/src/abi/mod.rs index dfb6c5128..73a4a1537 100644 --- a/ethers-core/src/abi/mod.rs +++ b/ethers-core/src/abi/mod.rs @@ -3,7 +3,7 @@ //! Adapted from [Gnosis' `ethcontract-rs`](https://github.com/gnosis/ethcontract-rs). use crate::{ - types::{Bytes, Selector, Uint8, H256, H512, I256, U128, U256, U64}, + types::{self, Selector, Uint8, H256, H512, I256, U128, U256, U64}, utils::id, }; pub use ethabi::{self, Contract as Abi, *}; @@ -184,7 +184,7 @@ macro_rules! impl_abi_type { } impl_abi_type!( - Bytes => Bytes, + types::Bytes => Bytes, bytes::Bytes => Bytes, Vec => Array(Box::new(ParamType::Uint(8))), Address => Address, @@ -317,9 +317,9 @@ mod tests { #[test] fn abi_type_works() { - assert_eq!(ParamType::Bytes, Bytes::param_type()); + assert_eq!(ParamType::Bytes, types::Bytes::param_type()); assert_eq!(ParamType::Array(Box::new(ParamType::Uint(8))), Vec::::param_type()); - assert_eq!(ParamType::Array(Box::new(ParamType::Bytes)), Vec::::param_type()); + assert_eq!(ParamType::Array(Box::new(ParamType::Bytes)), Vec::::param_type()); assert_eq!( ParamType::Array(Box::new(ParamType::Array(Box::new(ParamType::Uint(8))))), Vec::>::param_type() @@ -335,7 +335,7 @@ mod tests { assert_eq!( ParamType::Tuple(vec![ParamType::Bytes, ParamType::Address]), - <(Bytes, Address)>::param_type() + <(types::Bytes, Address)>::param_type() ); assert_eq!(ParamType::FixedBytes(32), <[u8; 32]>::param_type()); diff --git a/ethers-middleware/src/signer.rs b/ethers-middleware/src/signer.rs index 648d2039b..71b92d148 100644 --- a/ethers-middleware/src/signer.rs +++ b/ethers-middleware/src/signer.rs @@ -356,7 +356,7 @@ where } } -#[cfg(all(test, not(feature = "celo"), not(target_arch = "wasm32")))] +#[cfg(all(test, not(feature = "celo")))] mod tests { use super::*; use ethers_core::{ diff --git a/ethers-providers/src/rpc/provider.rs b/ethers-providers/src/rpc/provider.rs index f16ec6b90..f4ded5cf8 100644 --- a/ethers-providers/src/rpc/provider.rs +++ b/ethers-providers/src/rpc/provider.rs @@ -1506,7 +1506,6 @@ pub fn is_local_endpoint(endpoint: &str) -> bool { } #[cfg(test)] -#[cfg(not(target_arch = "wasm32"))] mod tests { use super::*; use crate::Http; diff --git a/ethers-providers/src/rpc/transports/ws/mod.rs b/ethers-providers/src/rpc/transports/ws/mod.rs index a3fdadf35..ad27daa7d 100644 --- a/ethers-providers/src/rpc/transports/ws/mod.rs +++ b/ethers-providers/src/rpc/transports/ws/mod.rs @@ -192,9 +192,9 @@ impl crate::Provider { Ok(Self::new(ws)) } - #[cfg(not(target_arch = "wasm32"))] /// Connect to a WS RPC provider with authentication details and a set /// number of reconnection attempts + #[cfg(not(target_arch = "wasm32"))] pub async fn connect_with_auth_and_reconnects( url: impl AsRef, auth: Authorization, diff --git a/ethers-providers/src/stream/tx_stream.rs b/ethers-providers/src/stream/tx_stream.rs index 3444df59f..063fa748a 100644 --- a/ethers-providers/src/stream/tx_stream.rs +++ b/ethers-providers/src/stream/tx_stream.rs @@ -169,25 +169,25 @@ where } #[cfg(test)] -#[cfg(not(target_arch = "wasm32"))] mod tests { use super::*; - use crate::{stream::tx_stream, Http, Ws}; - use ethers_core::{ - types::{Transaction, TransactionReceipt, TransactionRequest}, - utils::Anvil, - }; - use futures_util::{FutureExt, StreamExt}; - use std::{collections::HashSet, time::Duration}; + use crate::{stream::tx_stream, Http}; + use ethers_core::{types::TransactionRequest, utils::Anvil}; + use std::collections::HashSet; #[tokio::test] + #[cfg(feature = "ws")] async fn can_stream_pending_transactions() { + use ethers_core::types::{Transaction, TransactionReceipt}; + use futures_util::{FutureExt, StreamExt}; + use std::time::Duration; + let num_txs = 5; let geth = Anvil::new().block_time(2u64).spawn(); let provider = Provider::::try_from(geth.endpoint()) .unwrap() .interval(Duration::from_millis(1000)); - let ws = Ws::connect(geth.ws_endpoint()).await.unwrap(); + let ws = crate::Ws::connect(geth.ws_endpoint()).await.unwrap(); let ws_provider = Provider::new(ws); let accounts = provider.get_accounts().await.unwrap(); diff --git a/ethers-providers/tests/it/main.rs b/ethers-providers/tests/it/main.rs index 06d192e29..84c7d048a 100644 --- a/ethers-providers/tests/it/main.rs +++ b/ethers-providers/tests/it/main.rs @@ -16,7 +16,7 @@ mod provider; mod txpool; -#[cfg(not(feature = "celo"))] +#[cfg(all(feature = "ws", not(feature = "legacy-ws"), not(feature = "celo")))] mod ws_errors; /// Spawns Anvil and instantiates an Http provider. diff --git a/ethers-providers/tests/it/provider.rs b/ethers-providers/tests/it/provider.rs index ec595281f..68a6c0b28 100644 --- a/ethers-providers/tests/it/provider.rs +++ b/ethers-providers/tests/it/provider.rs @@ -28,7 +28,7 @@ mod eth_tests { // Without TLS this would error with "TLS Support not compiled in" #[tokio::test] - #[cfg(any(feature = "openssl", feature = "rustls"))] + #[cfg(all(feature = "ws", any(feature = "openssl", feature = "rustls")))] async fn ssl_websocket() { let provider = GOERLI.ws().await; assert_ne!(provider.get_block_number().await.unwrap(), 0.into()); diff --git a/ethers-solc/src/artifacts/mod.rs b/ethers-solc/src/artifacts/mod.rs index 8026685d0..e9132e48a 100644 --- a/ethers-solc/src/artifacts/mod.rs +++ b/ethers-solc/src/artifacts/mod.rs @@ -24,10 +24,7 @@ pub mod contract; pub mod output_selection; pub mod serde_helpers; use crate::{ - artifacts::{ - lowfidelity::NodeType, - output_selection::{ContractOutputSelection, OutputSelection}, - }, + artifacts::output_selection::{ContractOutputSelection, OutputSelection}, filter::FilteredSources, }; pub use bytecode::*; diff --git a/ethers-solc/src/compile/project.rs b/ethers-solc/src/compile/project.rs index 1279a57b3..423ae39e3 100644 --- a/ethers-solc/src/compile/project.rs +++ b/ethers-solc/src/compile/project.rs @@ -676,7 +676,7 @@ fn compile_parallel( } #[cfg(test)] -#[cfg(feature = "project-util")] +#[cfg(all(feature = "project-util", feature = "svm-solc"))] mod tests { use super::*; use crate::{project_util::TempProject, MinimalCombinedArtifacts};