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
|
if autonatMsg.isNone() or
|
||||||
autonatMsg.get().msgType != DialResponse or
|
autonatMsg.get().msgType != DialResponse or
|
||||||
autonatMsg.get().response.isNone() 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")
|
raise newException(AutonatError, "Unexpected response")
|
||||||
else:
|
else:
|
||||||
autonatMsg.get().response.get()
|
autonatMsg.get().response.get()
|
||||||
|
|
|
@ -34,7 +34,7 @@ suite "Autonat":
|
||||||
teardown:
|
teardown:
|
||||||
checkTrackers()
|
checkTrackers()
|
||||||
|
|
||||||
asyncTest "Simple test":
|
asyncTest "dialMe returns public address":
|
||||||
let
|
let
|
||||||
src = newStandardSwitch()
|
src = newStandardSwitch()
|
||||||
dst = createAutonatSwitch()
|
dst = createAutonatSwitch()
|
||||||
|
@ -43,9 +43,10 @@ suite "Autonat":
|
||||||
|
|
||||||
await src.connect(dst.peerInfo.peerId, dst.peerInfo.addrs)
|
await src.connect(dst.peerInfo.peerId, dst.peerInfo.addrs)
|
||||||
let ma = await Autonat.new(src).dialMe(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())
|
await allFutures(src.stop(), dst.stop())
|
||||||
|
|
||||||
asyncTest "Simple failed test":
|
asyncTest "dialMe handles dial error msg":
|
||||||
let
|
let
|
||||||
src = newStandardSwitch()
|
src = newStandardSwitch()
|
||||||
dst = makeAutonatServicePrivate()
|
dst = makeAutonatServicePrivate()
|
||||||
|
@ -54,6 +55,6 @@ suite "Autonat":
|
||||||
await dst.start()
|
await dst.start()
|
||||||
|
|
||||||
await src.connect(dst.peerInfo.peerId, dst.peerInfo.addrs)
|
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)
|
discard await Autonat.new(src).dialMe(dst.peerInfo.peerId, dst.peerInfo.addrs)
|
||||||
await allFutures(src.stop(), dst.stop())
|
await allFutures(src.stop(), dst.stop())
|
||||||
|
|
Loading…
Reference in New Issue