Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
umgefahren committed Apr 30, 2024
1 parent 480337e commit a84c998
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
31 changes: 19 additions & 12 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,9 @@ where
}

self.behaviour
.on_swarm_event(FromSwarm::NewListener(behaviour::NewListener { listener_id }));
.on_swarm_event(FromSwarm::NewListener(behaviour::NewListener {
listener_id,
}));

Ok(())
}
Expand All @@ -608,7 +610,9 @@ where
/// The address is broadcast to all [`NetworkBehaviour`]s via [`FromSwarm::ExternalAddrConfirmed`].
pub fn add_external_address(&mut self, a: Multiaddr) {
self.behaviour
.on_swarm_event(FromSwarm::ExternalAddrConfirmed(ExternalAddrConfirmed { addr: &a }));
.on_swarm_event(FromSwarm::ExternalAddrConfirmed(ExternalAddrConfirmed {
addr: &a,
}));
self.confirmed_external_addr.insert(a);
}

Expand Down Expand Up @@ -1055,9 +1059,9 @@ where
);
let addrs = self.listened_addrs.remove(&listener_id).unwrap_or_default();
for addr in addrs.iter() {
self.behaviour.on_swarm_event(
FromSwarm::ExpiredListenAddr(ExpiredListenAddr { listener_id, addr })
);
self.behaviour.on_swarm_event(FromSwarm::ExpiredListenAddr(
ExpiredListenAddr { listener_id, addr },
));
}
self.behaviour
.on_swarm_event(FromSwarm::ListenerClosed(ListenerClosed {
Expand Down Expand Up @@ -2151,9 +2155,9 @@ mod tests {
{}

match swarm2.poll_next_unpin(cx) {
Poll::Ready(Some(SwarmEvent::OutgoingConnectionError { peer_id, error, .. })) => {
Poll::Ready((peer_id, error))
}
Poll::Ready(Some(SwarmEvent::OutgoingConnectionError {
peer_id, error, ..
})) => Poll::Ready((peer_id, error)),
Poll::Ready(x) => panic!("unexpected {x:?}"),
Poll::Pending => Poll::Pending,
}
Expand Down Expand Up @@ -2219,7 +2223,9 @@ mod tests {
return Poll::Ready(Ok(()));
}
}
Poll::Ready(Some(SwarmEvent::IncomingConnectionError { local_addr, .. })) => {
Poll::Ready(Some(SwarmEvent::IncomingConnectionError {
local_addr, ..
})) => {
assert!(!got_inc_err);
assert_eq!(local_addr, local_address);
got_inc_err = true;
Expand Down Expand Up @@ -2340,9 +2346,10 @@ mod tests {
// This constitutes a fairly typical error for chained transports.
let error = DialError::Transport(vec![(
"/ip4/127.0.0.1/tcp/80".parse().unwrap(),
TransportError::Other(
io::Error::new(io::ErrorKind::Other, MemoryTransportError::Unreachable)
),
TransportError::Other(io::Error::new(
io::ErrorKind::Other,
MemoryTransportError::Unreachable,
)),
)]);

let string = format!("{error}");
Expand Down
22 changes: 11 additions & 11 deletions transports/tcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,9 @@ mod tests {
.unwrap()
),
Ok(SocketAddr::new(
IpAddr::V6(Ipv6Addr::new(65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,)),
IpAddr::V6(Ipv6Addr::new(
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
)),
8080,
))
);
Expand Down Expand Up @@ -1275,11 +1277,10 @@ mod tests {

#[cfg(feature = "tokio")]
{
let rt =
::tokio::runtime::Builder::new_current_thread()
.enable_io()
.build()
.unwrap();
let rt = ::tokio::runtime::Builder::new_current_thread()
.enable_io()
.build()
.unwrap();
assert!(rt.block_on(cycle_listeners::<tokio::Tcp>()));
}
}
Expand Down Expand Up @@ -1312,11 +1313,10 @@ mod tests {
}
#[cfg(feature = "tokio")]
{
let rt =
::tokio::runtime::Builder::new_current_thread()
.enable_io()
.build()
.unwrap();
let rt = ::tokio::runtime::Builder::new_current_thread()
.enable_io()
.build()
.unwrap();
rt.block_on(async {
test::<tokio::Tcp>();
});
Expand Down

0 comments on commit a84c998

Please sign in to comment.