diff --git a/src/lib.rs b/src/lib.rs index 8542195f..feac164e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -248,6 +248,7 @@ where KeepAlive::Yes } + #[allow(clippy::type_complexity)] fn poll( &mut self, cx: &mut Context<'_>, @@ -475,6 +476,7 @@ where } #[cfg(test)] +#[allow(clippy::blacklisted_name)] mod tests { use super::*; use crate::swarm_harness::await_events_or_timeout; diff --git a/src/swarm_harness.rs b/src/swarm_harness.rs index 15bab452..789335ba 100644 --- a/src/swarm_harness.rs +++ b/src/swarm_harness.rs @@ -1,8 +1,7 @@ use libp2p::futures::future; +use libp2p::futures::future::FutureExt; use libp2p::{ - core::{ - muxing::StreamMuxerBox, transport::memory::MemoryTransport, upgrade::Version, - }, + core::{muxing::StreamMuxerBox, transport::memory::MemoryTransport, upgrade::Version}, identity, noise::{self, NoiseConfig, X25519Spec}, swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent}, @@ -10,9 +9,8 @@ use libp2p::{ Multiaddr, PeerId, Swarm, Transport, }; use std::{fmt::Debug, future::Future, time::Duration}; -use tokio::time; use tokio::runtime::Handle; -use libp2p::futures::future::FutureExt; +use tokio::time; #[allow(missing_debug_implementations)] pub struct Actor { @@ -25,7 +23,8 @@ pub async fn new_connected_swarm_pair(behaviour_fn: F, handle: Handle) -> where B: NetworkBehaviour, F: Fn(PeerId, identity::Keypair) -> B + Clone, -::OutEvent: Debug{ + ::OutEvent: Debug, +{ let (swarm, addr, peer_id) = new_swarm(behaviour_fn.clone(), handle.clone()); let mut alice = Actor { swarm, @@ -45,7 +44,10 @@ where (alice, bob) } -pub fn new_swarm B>(behaviour_fn: F, handle: Handle) -> (Swarm, Multiaddr, PeerId) { +pub fn new_swarm B>( + behaviour_fn: F, + handle: Handle, +) -> (Swarm, Multiaddr, PeerId) { let id_keys = identity::Keypair::generate_ed25519(); let peer_id = PeerId::from(id_keys.public()); @@ -61,15 +63,11 @@ pub fn new_swarm B>(beh .map(|(peer, muxer), _| (peer, StreamMuxerBox::new(muxer))) .boxed(); - let mut swarm: Swarm = SwarmBuilder::new( - transport, - behaviour_fn(peer_id.clone(), id_keys), - peer_id.clone(), - ) - .executor(Box::new(move |f| { - handle.spawn(f); - })) - .build(); + let mut swarm: Swarm = SwarmBuilder::new(transport, behaviour_fn(peer_id, id_keys), peer_id) + .executor(Box::new(move |f| { + handle.spawn(f); + })) + .build(); let address_port = rand::random::(); let addr = format!("/memory/{}", address_port) @@ -104,9 +102,10 @@ pub async fn await_events_or_timeout( /// connection phase. Any event emitted is considered a bug from this functions /// PoV because they would be lost. pub async fn connect(alice: &mut Swarm, bob: &mut Swarm) - where - B: NetworkBehaviour, -::OutEvent: Debug{ +where + B: NetworkBehaviour, + ::OutEvent: Debug, +{ let mut alice_connected = false; let mut bob_connected = false;