From 93a9fd203a100c17438d1a772edadcfd5c23521e Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Sun, 8 Sep 2019 01:59:14 -0600 Subject: [PATCH] fix: multistream tests --- libp2p/muxers/mplex/channel.nim | 8 ++++---- libp2p/switch.nim | 2 +- tests/testmultistream.nim | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libp2p/muxers/mplex/channel.nim b/libp2p/muxers/mplex/channel.nim index 8b37f9267..8659e9755 100644 --- a/libp2p/muxers/mplex/channel.nim +++ b/libp2p/muxers/mplex/channel.nim @@ -8,12 +8,12 @@ ## those terms. import chronos, strformat -import ../../stream/bufferstream, +import types, + coder, + nimcrypto/utils, + ../../stream/bufferstream, ../../stream/lpstream, ../../connection, - nimcrypto/utils, - types, - coder, ../../helpers/debug const DefaultChannelSize* = DefaultBufferSize * 64 # 64kb diff --git a/libp2p/switch.nim b/libp2p/switch.nim index d11911da6..b1fbe1b05 100644 --- a/libp2p/switch.nim +++ b/libp2p/switch.nim @@ -117,8 +117,8 @@ proc handleConn(s: Switch, conn: Connection): Future[Connection] {.async, gcsafe await s.mux(result) # mux it if possible proc cleanupConn(s: Switch, conn: Connection) {.async, gcsafe.} = - let id = if conn.peerInfo.isSome: conn.peerInfo.get().peerId.pretty else: "" if conn.peerInfo.isSome: + let id = conn.peerInfo.get().peerId.pretty if s.muxed.contains(id): await s.muxed[id].close diff --git a/tests/testmultistream.nim b/tests/testmultistream.nim index 08d31a6ca..68c74a2d5 100644 --- a/tests/testmultistream.nim +++ b/tests/testmultistream.nim @@ -43,6 +43,9 @@ method readExactly*(s: TestSelectStream, cstring("\0x3na\n"), "\0x3na\n".len()) +method write*(s: TestSelectStream, msg: seq[byte], msglen = -1) + {.async, gcsafe.} = discard + method write*(s: TestSelectStream, msg: string, msglen = -1) {.async, gcsafe.} = discard