From 67c466c2d9d225f7cd8538af9509d52d79fff92e Mon Sep 17 00:00:00 2001 From: Nasr Date: Wed, 24 Jan 2024 12:18:28 -0500 Subject: [PATCH] chore: clippy and fmt --- crates/torii/libp2p/src/client/mod.rs | 6 +++--- crates/torii/libp2p/src/server/mod.rs | 4 +--- crates/torii/libp2p/src/tests.rs | 16 ++++++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/torii/libp2p/src/client/mod.rs b/crates/torii/libp2p/src/client/mod.rs index 2d99ceaf55..79c00577ab 100644 --- a/crates/torii/libp2p/src/client/mod.rs +++ b/crates/torii/libp2p/src/client/mod.rs @@ -1,12 +1,12 @@ +use std::time::Duration; + use futures::channel::mpsc::{Receiver, Sender}; -use futures::StreamExt; -use futures::{select, SinkExt}; +use futures::{select, SinkExt, StreamExt}; use libp2p::gossipsub::{self, IdentTopic, MessageId}; use libp2p::swarm::{NetworkBehaviour, Swarm, SwarmEvent}; use libp2p::{identify, identity, ping, Multiaddr, PeerId}; #[cfg(not(target_arch = "wasm32"))] use libp2p::{noise, tcp, yamux}; -use std::time::Duration; use tracing::info; pub mod events; diff --git a/crates/torii/libp2p/src/server/mod.rs b/crates/torii/libp2p/src/server/mod.rs index 7c75cf738c..b0fb16a861 100644 --- a/crates/torii/libp2p/src/server/mod.rs +++ b/crates/torii/libp2p/src/server/mod.rs @@ -94,9 +94,7 @@ impl Libp2pRelay { .unwrap(), } })? - .with_swarm_config(|cfg| { - cfg.with_idle_connection_timeout(Duration::from_secs(60)) - }) + .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(60))) .build(); // TCP diff --git a/crates/torii/libp2p/src/tests.rs b/crates/torii/libp2p/src/tests.rs index 8cfb284934..d6fe2848a0 100644 --- a/crates/torii/libp2p/src/tests.rs +++ b/crates/torii/libp2p/src/tests.rs @@ -1,11 +1,12 @@ #[cfg(test)] mod test { - use crate::client::Command; - use crate::client::Libp2pClient; - use crate::types::ClientMessage; - use futures::{SinkExt, StreamExt}; use std::error::Error; + use futures::{SinkExt, StreamExt}; + + use crate::client::{Command, Libp2pClient}; + use crate::types::ClientMessage; + #[cfg(target_arch = "wasm32")] wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); #[cfg(target_arch = "wasm32")] @@ -15,11 +16,13 @@ mod test { #[cfg(not(target_arch = "wasm32"))] #[tokio::test] async fn test_client_messaging() -> Result<(), Box> { - use crate::server::Libp2pRelay; use std::time::Duration; + use tokio::time::sleep; use tokio::{self, select}; + use crate::server::Libp2pRelay; + let _ = tracing_subscriber::fmt().with_env_filter("torii_libp2p=debug").try_init(); // Initialize the relay server let mut relay_server: Libp2pRelay = Libp2pRelay::new(9090, 9091, None, None)?; @@ -74,7 +77,8 @@ mod test { // Initialize the first client (listener) // Make sure the cert hash is correct - corresponding to the cert in the relay server let mut client = Libp2pClient::new( - "/ip4/127.0.0.1/udp/9091/webrtc-direct/certhash/uEiBDKAUMioKpVK2CLQjtOL9eLPmaJkTcPPbBMtau7XaPGA" + "/ip4/127.0.0.1/udp/9091/webrtc-direct/certhash/\ + uEiBDKAUMioKpVK2CLQjtOL9eLPmaJkTcPPbBMtau7XaPGA" .to_string(), )?;