style: apply cargo fmt across the crate (A20)
The repo never enforced rustfmt, so formatting had drifted broadly. This is a single mechanical `cargo fmt` pass over the whole crate (no behavioral change; lib suite green, 493 passed). Going forward fmt should be enforced (planned CI fmt --check step). Part of the 0.6.1 hygiene pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,7 @@ use iroh::endpoint::presets;
|
||||
use iroh::protocol::Router;
|
||||
use iroh::{Endpoint, RelayMode};
|
||||
|
||||
use peerspeak::files::{ChatAttachment, AttachmentKind};
|
||||
use peerspeak::files::{AttachmentKind, ChatAttachment};
|
||||
use peerspeak::network::NetworkTransport;
|
||||
use peerspeak::network::iroh_impl::{FileRouter, IrohTransport};
|
||||
use peerspeak::protocol::FILES_ALPN;
|
||||
@@ -52,7 +52,12 @@ async fn spawn_node() -> Node {
|
||||
.accept(FILES_ALPN, file_router)
|
||||
.spawn();
|
||||
|
||||
Node { endpoint, transport, _router: router, lookup }
|
||||
Node {
|
||||
endpoint,
|
||||
transport,
|
||||
_router: router,
|
||||
lookup,
|
||||
}
|
||||
}
|
||||
|
||||
/// A pseudo-random-ish multi-megabyte payload spanning many QUIC packets, so a
|
||||
@@ -86,7 +91,9 @@ async fn loopback_attachment_round_trips_intact() {
|
||||
|
||||
let blob = big_blob();
|
||||
let id = [42u8; 32];
|
||||
server.transport.serve_attachment(id, Arc::new(blob.clone()));
|
||||
server
|
||||
.transport
|
||||
.serve_attachment(id, Arc::new(blob.clone()));
|
||||
|
||||
let att = ChatAttachment {
|
||||
name: "exterior-landscape.jpg".to_string(),
|
||||
|
||||
@@ -62,7 +62,7 @@ async fn evicted_within(
|
||||
Ok(Some(UiEvent::PeerConnectionFailed { id })) if id == peer => return true,
|
||||
Ok(Some(_)) => continue, // ignore PeerConnecting / PeerConnected / PeerLeft
|
||||
Ok(None) => return false, // channel closed
|
||||
Err(_) => return false, // timed out — no eviction
|
||||
Err(_) => return false, // timed out — no eviction
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ async fn left_within(
|
||||
Ok(Some(UiEvent::PeerLeft { id })) if id == peer => return true,
|
||||
Ok(Some(_)) => continue, // ignore PeerConnecting / PeerConnected
|
||||
Ok(None) => return false, // channel closed
|
||||
Err(_) => return false, // timed out — no leave
|
||||
Err(_) => return false, // timed out — no leave
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+53
-11
@@ -23,8 +23,8 @@ use iroh::protocol::{AcceptError, ProtocolHandler};
|
||||
use peerspeak::codec::AudioEncoder;
|
||||
use peerspeak::codec::opus_impl::OpusEncoder;
|
||||
use peerspeak::core::jitter::{FRAME_SAMPLES, JitterBuffer};
|
||||
use peerspeak::network::{ConnEvent, NetworkTransport};
|
||||
use peerspeak::network::iroh_impl::{AudioRouter, IrohTransport};
|
||||
use peerspeak::network::{ConnEvent, NetworkTransport};
|
||||
use peerspeak::protocol::AUDIO_ALPN;
|
||||
|
||||
struct Node {
|
||||
@@ -91,7 +91,12 @@ async fn spawn_capture_peer(secret: iroh::SecretKey) -> CapturePeer {
|
||||
.accept(AUDIO_ALPN, CaptureProtocol { conns_tx })
|
||||
.spawn();
|
||||
|
||||
CapturePeer { endpoint, _router: router, lookup, conns_rx }
|
||||
CapturePeer {
|
||||
endpoint,
|
||||
_router: router,
|
||||
lookup,
|
||||
conns_rx,
|
||||
}
|
||||
}
|
||||
|
||||
/// Spawn a node with a specific secret key. Reusing a key gives the respawned
|
||||
@@ -208,7 +213,11 @@ async fn loopback_sequenced_audio_reaches_peer_and_decodes() {
|
||||
received += 1;
|
||||
|
||||
if let Some(frame) = jitter.pop_frame() {
|
||||
assert_eq!(frame.len(), FRAME_SAMPLES, "decoded frame is one 20ms frame");
|
||||
assert_eq!(
|
||||
frame.len(),
|
||||
FRAME_SAMPLES,
|
||||
"decoded frame is one 20ms frame"
|
||||
);
|
||||
decoded_frames += 1;
|
||||
}
|
||||
if received >= N {
|
||||
@@ -290,7 +299,11 @@ async fn dialer_reconnects_after_link_drops() {
|
||||
.expect("timed out awaiting initial connection")
|
||||
.expect("connection channel closed");
|
||||
assert!(
|
||||
await_reconnect(&mut conn_events, tokio::time::Instant::now() + Duration::from_secs(10)).await,
|
||||
await_reconnect(
|
||||
&mut conn_events,
|
||||
tokio::time::Instant::now() + Duration::from_secs(10)
|
||||
)
|
||||
.await,
|
||||
"initial link should report Connecting then Connected"
|
||||
);
|
||||
|
||||
@@ -306,7 +319,11 @@ async fn dialer_reconnects_after_link_drops() {
|
||||
.expect("timed out awaiting reconnect")
|
||||
.expect("connection channel closed");
|
||||
assert!(
|
||||
await_reconnect(&mut conn_events, tokio::time::Instant::now() + Duration::from_secs(15)).await,
|
||||
await_reconnect(
|
||||
&mut conn_events,
|
||||
tokio::time::Instant::now() + Duration::from_secs(15)
|
||||
)
|
||||
.await,
|
||||
"dropped link should report Connecting (down) then Connected (recovered)"
|
||||
);
|
||||
|
||||
@@ -319,7 +336,12 @@ async fn dialer_reconnects_after_link_drops() {
|
||||
tokio::time::sleep(Duration::from_millis(5)).await;
|
||||
}
|
||||
|
||||
let received = count_audio(&conn2, 25, tokio::time::Instant::now() + Duration::from_secs(3)).await;
|
||||
let received = count_audio(
|
||||
&conn2,
|
||||
25,
|
||||
tokio::time::Instant::now() + Duration::from_secs(3),
|
||||
)
|
||||
.await;
|
||||
assert!(
|
||||
received >= 20,
|
||||
"audio should resume after reconnect; got {received} frames"
|
||||
@@ -359,7 +381,11 @@ async fn dialer_reports_left_on_graceful_close() {
|
||||
.expect("timed out awaiting initial connection")
|
||||
.expect("connection channel closed");
|
||||
assert!(
|
||||
await_reconnect(&mut conn_events, tokio::time::Instant::now() + Duration::from_secs(10)).await,
|
||||
await_reconnect(
|
||||
&mut conn_events,
|
||||
tokio::time::Instant::now() + Duration::from_secs(10)
|
||||
)
|
||||
.await,
|
||||
"initial link should report Connecting then Connected"
|
||||
);
|
||||
|
||||
@@ -384,7 +410,10 @@ async fn dialer_reports_left_on_graceful_close() {
|
||||
|
||||
// And no re-dial reaches the peer within a short window.
|
||||
let redial = tokio::time::timeout(Duration::from_secs(2), peer.conns_rx.recv()).await;
|
||||
assert!(redial.is_err(), "supervisor must not re-dial after a graceful leave");
|
||||
assert!(
|
||||
redial.is_err(),
|
||||
"supervisor must not re-dial after a graceful leave"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -429,7 +458,11 @@ async fn dialer_connects_and_reconnects_without_an_address_lookup() {
|
||||
.expect("timed out awaiting initial connection (retained address path)")
|
||||
.expect("connection channel closed");
|
||||
assert!(
|
||||
await_reconnect(&mut conn_events, tokio::time::Instant::now() + Duration::from_secs(10)).await,
|
||||
await_reconnect(
|
||||
&mut conn_events,
|
||||
tokio::time::Instant::now() + Duration::from_secs(10)
|
||||
)
|
||||
.await,
|
||||
"initial link should report Connecting then Connected"
|
||||
);
|
||||
|
||||
@@ -443,7 +476,11 @@ async fn dialer_connects_and_reconnects_without_an_address_lookup() {
|
||||
.expect("timed out awaiting reconnect (retained address path)")
|
||||
.expect("connection channel closed");
|
||||
assert!(
|
||||
await_reconnect(&mut conn_events, tokio::time::Instant::now() + Duration::from_secs(15)).await,
|
||||
await_reconnect(
|
||||
&mut conn_events,
|
||||
tokio::time::Instant::now() + Duration::from_secs(15)
|
||||
)
|
||||
.await,
|
||||
"reconnect should report Connecting then Connected with no lookup at all"
|
||||
);
|
||||
|
||||
@@ -455,7 +492,12 @@ async fn dialer_connects_and_reconnects_without_an_address_lookup() {
|
||||
tokio::time::sleep(Duration::from_millis(5)).await;
|
||||
}
|
||||
|
||||
let received = count_audio(&conn2, 25, tokio::time::Instant::now() + Duration::from_secs(3)).await;
|
||||
let received = count_audio(
|
||||
&conn2,
|
||||
25,
|
||||
tokio::time::Instant::now() + Duration::from_secs(3),
|
||||
)
|
||||
.await;
|
||||
assert!(
|
||||
received >= 20,
|
||||
"audio should resume after reconnecting via the retained address; got {received} frames"
|
||||
|
||||
Reference in New Issue
Block a user