chore: make clippy happy (#6666)

This commit is contained in:
Dan Cline
2024-02-19 01:31:47 -05:00
committed by GitHub
parent 79f1fa3c10
commit 79452eadaf
86 changed files with 106 additions and 241 deletions

View File

@ -176,7 +176,7 @@ mod tests {
use super::*;
use tokio::{
io::{duplex, AsyncReadExt, AsyncWriteExt, DuplexStream},
net::{TcpListener, TcpStream},
net::TcpListener,
};
async fn duplex_stream_ping_pong(

View File

@ -2193,7 +2193,7 @@ mod tests {
use alloy_rlp::{Decodable, Encodable};
use rand::{thread_rng, Rng};
use reth_primitives::{hex, mainnet_nodes, ForkHash};
use std::{future::poll_fn, net::Ipv4Addr};
use std::future::poll_fn;
#[tokio::test]
async fn test_configured_enr_forkid_entry() {

View File

@ -314,7 +314,7 @@ pub fn rng_message(rng: &mut impl RngCore) -> Message {
mod tests {
use super::*;
use crate::Discv4Event;
use std::net::{IpAddr, Ipv4Addr};
use std::net::Ipv4Addr;
/// This test creates two local UDP sockets. The mocked discovery service responds to specific
/// messages and we check the actual service receives answers

View File

@ -415,7 +415,6 @@ mod tests {
use reth_primitives::{Hardfork, MAINNET};
use secp256k1::rand::thread_rng;
use std::{future::poll_fn, net::Ipv4Addr};
use tokio_stream::StreamExt;
#[tokio::test]
async fn test_start_root_sync() {

View File

@ -364,7 +364,6 @@ fn ensure_strip_key(input: &mut &str, key: &str, err: &'static str) -> ParseEntr
#[cfg(test)]
mod tests {
use super::*;
use secp256k1::SecretKey;
#[test]
fn parse_root_entry() {

View File

@ -596,12 +596,11 @@ mod tests {
test_utils::{generate_bodies, TestBodiesClient},
};
use assert_matches::assert_matches;
use futures_util::stream::StreamExt;
use reth_db::test_utils::create_test_rw_db;
use reth_interfaces::test_utils::{generators, generators::random_block_range, TestConsensus};
use reth_primitives::{BlockBody, B256, MAINNET};
use reth_provider::ProviderFactory;
use std::{collections::HashMap, sync::Arc};
use std::collections::HashMap;
// Check that the blocks are emitted in order of block number, not in order of
// first-downloaded

View File

@ -252,12 +252,7 @@ mod tests {
bodies::test_utils::zip_blocks,
test_utils::{generate_bodies, TestBodiesClient},
};
use reth_interfaces::{
p2p::bodies::response::BlockResponse,
test_utils::{generators, generators::random_header_range, TestConsensus},
};
use reth_primitives::B256;
use std::sync::Arc;
use reth_interfaces::test_utils::{generators, generators::random_header_range, TestConsensus};
/// Check if future returns empty bodies without dispathing any requests.
#[tokio::test]

View File

@ -10,7 +10,7 @@ use reth_interfaces::p2p::{
use reth_primitives::{
BlockBody, BlockHash, BlockHashOrNumber, BlockNumber, Header, HeadersDirection, PeerId, B256,
};
use std::{self, collections::HashMap, path::Path};
use std::{collections::HashMap, path::Path};
use thiserror::Error;
use tokio::{fs::File, io::AsyncReadExt};
use tokio_stream::StreamExt;

View File

@ -1225,7 +1225,6 @@ mod tests {
use crate::headers::test_utils::child_header;
use assert_matches::assert_matches;
use reth_interfaces::test_utils::{TestConsensus, TestHeadersClient};
use reth_primitives::SealedHeader;
/// Tests that `replace_number` works the same way as Option::replace
#[test]

View File

@ -23,7 +23,6 @@ use secp256k1::{
};
use sha2::Sha256;
use sha3::Keccak256;
use std::convert::TryFrom;
const PROTOCOL_VERSION: usize = 4;

View File

@ -149,7 +149,7 @@ where
mod tests {
use super::*;
use crate::util::pk2id;
use secp256k1::{rand, SECP256K1};
use secp256k1::SECP256K1;
use tokio::net::{TcpListener, TcpStream};
#[tokio::test]

View File

@ -643,7 +643,7 @@ mod tests {
connect_passthrough, eth_handshake, eth_hello,
proto::{test_hello, TestProtoMessage},
},
UnauthedEthStream, UnauthedP2PStream,
UnauthedP2PStream,
};
use tokio::{net::TcpListener, sync::oneshot};
use tokio_util::codec::Decoder;

View File

@ -809,9 +809,7 @@ impl Decodable for ProtocolVersion {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
capability::SharedCapability, test_utils::eth_hello, DisconnectReason, EthVersion,
};
use crate::{capability::SharedCapability, test_utils::eth_hello, EthVersion};
use tokio::net::{TcpListener, TcpStream};
use tokio_util::codec::Decoder;

View File

@ -12,10 +12,7 @@ use reth_primitives::{Block, Bytes, TransactionSigned, TxHash, B256, U128};
use std::{collections::HashMap, mem, sync::Arc};
#[cfg(feature = "arbitrary")]
use proptest::prelude::*;
#[cfg(feature = "arbitrary")]
use proptest::{arbitrary::Arbitrary, collection::vec};
use proptest::{collection::vec, prelude::*};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
@ -664,7 +661,6 @@ impl FromIterator<(TxHash, Option<(u8, usize)>)> for RequestTxHashes {
#[cfg(test)]
mod tests {
use super::*;
use alloy_rlp::{Decodable, Encodable};
use bytes::BytesMut;
use reth_primitives::hex;
use std::str::FromStr;

View File

@ -131,7 +131,6 @@ impl From<EthVersion> for &'static str {
#[cfg(test)]
mod tests {
use super::{EthVersion, ParseVersionError};
use std::{convert::TryFrom, string::ToString};
#[test]
fn test_eth_version_try_from_str() {

View File

@ -2,7 +2,7 @@ use core::hash::BuildHasher;
use derive_more::{Deref, DerefMut};
use itertools::Itertools;
use linked_hash_set::LinkedHashSet;
use schnellru::{self, ByLength, Limiter, RandomState, Unlimited};
use schnellru::{ByLength, Limiter, RandomState, Unlimited};
use std::{borrow::Borrow, fmt, hash::Hash, num::NonZeroUsize};
/// A minimal LRU cache based on a `LinkedHashSet` with limited capacity.

View File

@ -429,7 +429,7 @@ pub(crate) enum BlockResponseOutcome {
mod tests {
use super::*;
use crate::{peers::PeersManager, PeersConfig};
use reth_primitives::{SealedHeader, B256, B512};
use reth_primitives::{SealedHeader, B512};
use std::future::poll_fn;
#[tokio::test(flavor = "multi_thread")]

View File

@ -761,8 +761,7 @@ fn calculate_new_timeout(current_timeout: Duration, estimated_rtt: Duration) ->
mod tests {
use super::*;
use crate::session::{
config::{INITIAL_REQUEST_TIMEOUT, PROTOCOL_BREACH_REQUEST_TIMEOUT},
handle::PendingSessionEvent,
config::PROTOCOL_BREACH_REQUEST_TIMEOUT, handle::PendingSessionEvent,
start_pending_incoming_session,
};
use reth_ecies::{stream::ECIESStream, util::pk2id};
@ -773,7 +772,6 @@ mod tests {
use reth_net_common::bandwidth_meter::{BandwidthMeter, MeteredStream};
use reth_primitives::{ForkFilter, Hardfork, MAINNET};
use secp256k1::{SecretKey, SECP256K1};
use std::time::Duration;
use tokio::{
net::{TcpListener, TcpStream},
sync::mpsc,

View File

@ -223,9 +223,9 @@ impl FilterAnnouncement for EthAnnouncementFilter {
let NewPooledTransactionHashes68 { mut hashes, mut types, mut sizes } = msg;
debug_assert!(
hashes.len() == types.len() && hashes.len() == sizes.len(), "`%hashes`, `%types` and `%sizes` should all be the same length, decoding of `NewPooledTransactionHashes68` should handle this,
`%hashes`: {hashes:?},
`%types`: {types:?},
hashes.len() == types.len() && hashes.len() == sizes.len(), "`%hashes`, `%types` and `%sizes` should all be the same length, decoding of `NewPooledTransactionHashes68` should handle this,
`%hashes`: {hashes:?},
`%types`: {types:?},
`%sizes: {sizes:?}`"
);
@ -332,7 +332,6 @@ impl FilterAnnouncement for EthAnnouncementFilter {
#[cfg(test)]
mod test {
use super::*;
use reth_eth_wire::MAX_MESSAGE_SIZE;
use reth_primitives::B256;
use std::str::FromStr;

View File

@ -82,15 +82,15 @@ async fn test_4844_tx_gossip_penalization() {
let network_handle = peer0.network();
let peer0_reputation_before =
peer1.peer_handle().peer_by_id(peer0.peer_id().clone()).await.unwrap().reputation();
peer1.peer_handle().peer_by_id(*peer0.peer_id()).await.unwrap().reputation();
// sends txs directly to peer1
network_handle.send_transactions(peer1.peer_id().clone(), signed_txs);
network_handle.send_transactions(*peer1.peer_id(), signed_txs);
let received = peer1_tx_listener.recv().await.unwrap();
let peer0_reputation_after =
peer1.peer_handle().peer_by_id(peer0.peer_id().clone()).await.unwrap().reputation();
peer1.peer_handle().peer_by_id(*peer0.peer_id()).await.unwrap().reputation();
assert_ne!(peer0_reputation_before, peer0_reputation_after);
assert_eq!(received, txs[1].transaction().hash);
@ -130,24 +130,23 @@ async fn test_sending_invalid_transactions() {
input: Default::default(),
};
let tx = TransactionSigned::from_transaction_and_signature(tx.into(), Default::default());
peer0.network().send_transactions(peer1.peer_id().clone(), vec![Arc::new(tx)]);
peer0.network().send_transactions(*peer1.peer_id(), vec![Arc::new(tx)]);
}
// await disconnect for bad tx spam
while let Some(ev) = peer1_events.next().await {
if let Some(ev) = peer1_events.next().await {
match ev {
NetworkEvent::SessionClosed { peer_id, .. } => {
assert_eq!(peer_id, *peer0.peer_id());
break
}
NetworkEvent::SessionEstablished { .. } => {
panic!("unexpected event")
panic!("unexpected SessionEstablished event")
}
NetworkEvent::PeerAdded(_) => {
panic!("unexpected event")
panic!("unexpected PeerAdded event")
}
NetworkEvent::PeerRemoved(_) => {
panic!("unexpected event")
panic!("unexpected PeerRemoved event")
}
}
}