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)
|
||||
|
||||
for s in startFuts:
|
||||
if s.failed:
|
||||
# TODO: replace this exception with a `listenError` callback. See
|
||||
# https://github.com/status-im/nim-libp2p/pull/662 for more info.
|
||||
raise newException(transport.TransportError,
|
||||
"Failed to start one transport", s.error)
|
||||
for fut in startFuts:
|
||||
if fut.failed:
|
||||
await s.stop()
|
||||
raise fut.error
|
||||
|
||||
for t in s.transports: # for each transport
|
||||
if t.addrs.len > 0 or t.running:
|
||||
|
|
|
@ -1035,3 +1035,12 @@ suite "Switch":
|
|||
await conn.close()
|
||||
await src.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…
Reference in New Issue