mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2025-01-28 01:15:32 +00:00
Fix switch failed start (#770)
This commit is contained in:
parent
a001508490
commit
72abe822c0
@ -312,12 +312,10 @@ proc start*(s: Switch) {.async, gcsafe, public.} =
|
|||||||
|
|
||||||
await allFutures(startFuts)
|
await allFutures(startFuts)
|
||||||
|
|
||||||
for s in startFuts:
|
for fut in startFuts:
|
||||||
if s.failed:
|
if fut.failed:
|
||||||
# TODO: replace this exception with a `listenError` callback. See
|
await s.stop()
|
||||||
# https://github.com/status-im/nim-libp2p/pull/662 for more info.
|
raise fut.error
|
||||||
raise newException(transport.TransportError,
|
|
||||||
"Failed to start one transport", s.error)
|
|
||||||
|
|
||||||
for t in s.transports: # for each transport
|
for t in s.transports: # for each transport
|
||||||
if t.addrs.len > 0 or t.running:
|
if t.addrs.len > 0 or t.running:
|
||||||
|
@ -1035,3 +1035,12 @@ suite "Switch":
|
|||||||
await conn.close()
|
await conn.close()
|
||||||
await src.stop()
|
await src.stop()
|
||||||
await dst.stop()
|
await dst.stop()
|
||||||
|
|
||||||
|
asyncTest "switch failing to start stops properly":
|
||||||
|
let switch = newStandardSwitch(
|
||||||
|
addrs = @[MultiAddress.init("/ip4/0.0.0.0/tcp/0").tryGet(), MultiAddress.init("/ip4/1.1.1.1/tcp/0").tryGet()]
|
||||||
|
)
|
||||||
|
|
||||||
|
expect LPError:
|
||||||
|
await switch.start()
|
||||||
|
# test is that this doesn't leak
|
||||||
|
Loading…
x
Reference in New Issue
Block a user