From 27e4516796278f506044da58d4d58318dee55f37 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 13 Sep 2019 14:04:46 -0600 Subject: [PATCH] fix breaking test --- libp2p/switch.nim | 6 +++++- tests/testswitch.nim | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libp2p/switch.nim b/libp2p/switch.nim index 7dcfb94..d43ee8e 100644 --- a/libp2p/switch.nim +++ b/libp2p/switch.nim @@ -93,6 +93,9 @@ proc mux(s: Switch, conn: Connection): Future[void] {.async, gcsafe.} = debug "muxing connection" ## mux incoming connection let muxers = toSeq(s.muxers.keys) + if muxers.len == 0: + return + let muxerName = await s.ms.select(conn, muxers) if muxerName.len == 0 or muxerName == "na": return @@ -252,7 +255,7 @@ proc newSwitch*(peerInfo: PeerInfo, transports: seq[Transport], identity: Identify, muxers: Table[string, MuxerProvider], - secureManagers: Table[string, Secure], + secureManagers: Table[string, Secure] = initTable[string, Secure](), pubSub: Option[PubSub] = none(PubSub)): Switch = new result result.peerInfo = peerInfo @@ -283,6 +286,7 @@ proc newSwitch*(peerInfo: PeerInfo, if result.secureManagers.len == 0: # use plain text if no secure managers are provided + debug "no secure managers, falling back to palin text", codec = PlainTextCodec result.secureManagers[PlainTextCodec] = Secure(newPlainText()) if pubSub.isSome: diff --git a/tests/testswitch.nim b/tests/testswitch.nim index 116c69a..f94f40e 100644 --- a/tests/testswitch.nim +++ b/tests/testswitch.nim @@ -12,7 +12,9 @@ import ../libp2p/switch, ../libp2p/protocols/protocol, ../libp2p/muxers/muxer, ../libp2p/muxers/mplex/mplex, - ../libp2p/muxers/mplex/types + ../libp2p/muxers/mplex/types, + ../libp2p/protocols/secure/secio, + ../libp2p/protocols/secure/secure const TestCodec = "/test/proto/1.0.0" @@ -44,6 +46,7 @@ suite "Switch": let mplexProvider = newMuxerProvider(createMplex, MplexCodec) let transports = @[Transport(newTransport(TcpTransport))] let muxers = [(MplexCodec, mplexProvider)].toTable() + # let secureManagers = [(SecioCodec, Secure(newSecio(seckey)))].toTable() let switch = newSwitch(peerInfo, transports, identify, muxers) result = (switch, peerInfo)