Skip to content

Commit 12801fd

Browse files
committed
Merge branch 'master' into haiko-webrtc-outbound-multistream-nego-fix
2 parents 4ed539e + 08311db commit 12801fd

File tree

9 files changed

+296
-216
lines changed

9 files changed

+296
-216
lines changed

src/transport/manager/mod.rs

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,67 +1447,70 @@ mod tests {
14471447
(dial_address, connection_id)
14481448
}
14491449

1450+
#[tokio::test]
14501451
#[cfg(feature = "websocket")]
1451-
struct MockTransport {
1452-
rx: tokio::sync::mpsc::Receiver<TransportEvent>,
1453-
}
1454-
1455-
#[cfg(feature = "websocket")]
1456-
impl MockTransport {
1457-
fn new(rx: tokio::sync::mpsc::Receiver<TransportEvent>) -> Self {
1458-
Self { rx }
1452+
#[cfg(feature = "quic")]
1453+
async fn transport_events() {
1454+
struct MockTransport {
1455+
rx: tokio::sync::mpsc::Receiver<TransportEvent>,
14591456
}
1460-
}
14611457

1462-
#[cfg(feature = "websocket")]
1463-
impl Transport for MockTransport {
1464-
fn dial(&mut self, _connection_id: ConnectionId, _address: Multiaddr) -> crate::Result<()> {
1465-
Ok(())
1458+
impl MockTransport {
1459+
fn new(rx: tokio::sync::mpsc::Receiver<TransportEvent>) -> Self {
1460+
Self { rx }
1461+
}
14661462
}
14671463

1468-
fn accept(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1469-
Ok(())
1470-
}
1464+
impl Transport for MockTransport {
1465+
fn dial(
1466+
&mut self,
1467+
_connection_id: ConnectionId,
1468+
_address: Multiaddr,
1469+
) -> crate::Result<()> {
1470+
Ok(())
1471+
}
14711472

1472-
fn accept_pending(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1473-
Ok(())
1474-
}
1473+
fn accept(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1474+
Ok(())
1475+
}
14751476

1476-
fn reject_pending(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1477-
Ok(())
1478-
}
1477+
fn accept_pending(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1478+
Ok(())
1479+
}
14791480

1480-
fn reject(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1481-
Ok(())
1482-
}
1481+
fn reject_pending(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1482+
Ok(())
1483+
}
14831484

1484-
fn open(
1485-
&mut self,
1486-
_connection_id: ConnectionId,
1487-
_addresses: Vec<Multiaddr>,
1488-
) -> crate::Result<()> {
1489-
Ok(())
1490-
}
1485+
fn reject(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1486+
Ok(())
1487+
}
14911488

1492-
fn negotiate(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1493-
Ok(())
1494-
}
1489+
fn open(
1490+
&mut self,
1491+
_connection_id: ConnectionId,
1492+
_addresses: Vec<Multiaddr>,
1493+
) -> crate::Result<()> {
1494+
Ok(())
1495+
}
14951496

1496-
fn cancel(&mut self, _connection_id: ConnectionId) {}
1497-
}
1497+
fn negotiate(&mut self, _connection_id: ConnectionId) -> crate::Result<()> {
1498+
Ok(())
1499+
}
14981500

1499-
#[cfg(feature = "websocket")]
1500-
impl Stream for MockTransport {
1501-
type Item = TransportEvent;
1502-
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
1503-
self.rx.poll_recv(cx)
1501+
fn cancel(&mut self, _connection_id: ConnectionId) {}
1502+
}
1503+
1504+
impl Stream for MockTransport {
1505+
type Item = TransportEvent;
1506+
fn poll_next(
1507+
mut self: Pin<&mut Self>,
1508+
cx: &mut Context<'_>,
1509+
) -> Poll<Option<Self::Item>> {
1510+
self.rx.poll_recv(cx)
1511+
}
15041512
}
1505-
}
15061513

1507-
#[tokio::test]
1508-
#[cfg(feature = "websocket")]
1509-
#[cfg(feature = "quic")]
1510-
async fn transport_events() {
15111514
let mut transports = TransportContext::new();
15121515

15131516
let (tx_tcp, rx) = tokio::sync::mpsc::channel(8);

src/transport/tcp/connection.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ pub struct NegotiatedConnection {
123123
substream_open_timeout: Duration,
124124
}
125125

126+
impl std::fmt::Debug for NegotiatedConnection {
127+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
128+
f.debug_struct("NegotiatedConnection")
129+
.field("peer", &self.peer)
130+
.field("endpoint", &self.endpoint)
131+
.finish()
132+
}
133+
}
134+
126135
impl NegotiatedConnection {
127136
/// Get `ConnectionId` of the negotiated connection.
128137
pub fn connection_id(&self) -> ConnectionId {

0 commit comments

Comments
 (0)