Handle dial error correctly (#830)
This commit is contained in:
parent
63e1872516
commit
d521c57b82
|
@ -211,7 +211,8 @@ method dialMe*(a: Autonat, pid: PeerId, addrs: seq[MultiAddress] = newSeq[MultiA
|
|||
if autonatMsg.isNone() or
|
||||
autonatMsg.get().msgType != DialResponse or
|
||||
autonatMsg.get().response.isNone() or
|
||||
autonatMsg.get().response.get().ma.isNone():
|
||||
(autonatMsg.get().response.get().status == Ok and
|
||||
autonatMsg.get().response.get().ma.isNone()):
|
||||
raise newException(AutonatError, "Unexpected response")
|
||||
else:
|
||||
autonatMsg.get().response.get()
|
||||
|
|
|
@ -34,7 +34,7 @@ suite "Autonat":
|
|||
teardown:
|
||||
checkTrackers()
|
||||
|
||||
asyncTest "Simple test":
|
||||
asyncTest "dialMe returns public address":
|
||||
let
|
||||
src = newStandardSwitch()
|
||||
dst = createAutonatSwitch()
|
||||
|
@ -43,9 +43,10 @@ suite "Autonat":
|
|||
|
||||
await src.connect(dst.peerInfo.peerId, dst.peerInfo.addrs)
|
||||
let ma = await Autonat.new(src).dialMe(dst.peerInfo.peerId, dst.peerInfo.addrs)
|
||||
check ma in src.peerInfo.addrs
|
||||
await allFutures(src.stop(), dst.stop())
|
||||
|
||||
asyncTest "Simple failed test":
|
||||
asyncTest "dialMe handles dial error msg":
|
||||
let
|
||||
src = newStandardSwitch()
|
||||
dst = makeAutonatServicePrivate()
|
||||
|
@ -54,6 +55,6 @@ suite "Autonat":
|
|||
await dst.start()
|
||||
|
||||
await src.connect(dst.peerInfo.peerId, dst.peerInfo.addrs)
|
||||
expect AutonatError:
|
||||
expect AutonatUnreachableError:
|
||||
discard await Autonat.new(src).dialMe(dst.peerInfo.peerId, dst.peerInfo.addrs)
|
||||
await allFutures(src.stop(), dst.stop())
|
||||
|
|
Loading…
Reference in New Issue