Skip to content

Commit

Permalink
Add comments to identify failing tests, increase timeouts in some fai…
Browse files Browse the repository at this point in the history
…ling tests.
  • Loading branch information
AlejandroCabeza committed Nov 30, 2023
1 parent deb72c8 commit aa0e7c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ tests/pubsub/testgossipsub
examples/*.md
nimble.develop
nimble.paths
go-libp2p-daemon/
33 changes: 23 additions & 10 deletions tests/testdcutr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ suite "Dcutr":

check syncMsg == syncMsgDecoded

# FAILS
asyncTest "DCUtR establishes a new connection":

let behindNATSwitch = newStandardSwitch()
Expand All @@ -63,6 +64,9 @@ suite "Dcutr":
# tcp simultaneous incoming upgrader in the dialer which works only in the simultaneous open case.
await DcutrClient.new().startSync(behindNATSwitch, publicSwitch.peerInfo.peerId, behindNATSwitch.peerInfo.addrs)
.wait(300.millis)
# TODO
# await DcutrClient.new().startSync(behindNATSwitch, publicSwitch.peerInfo.peerId, behindNATSwitch.peerInfo.addrs)
# .wait(1000.millis)

checkExpiring:
# we still expect a new connection to be open by the receiver peer acting as the dcutr server
Expand All @@ -89,25 +93,27 @@ suite "Dcutr":

await allFutures(behindNATSwitch.stop(), publicSwitch.stop())

# FAILS
asyncTest "Client connect timeout":

proc connectTimeoutProc(self: SwitchStub,
proc connectTimeoutProc(self: SwitchStub,
peerId: PeerId,
addrs: seq[MultiAddress],
forceDial = false,
reuseConnection = true,
dir = Direction.Out): Future[void] {.async.} =
await sleepAsync(100.millis)

let behindNATSwitch = SwitchStub.new(newStandardSwitch(), connectTimeoutProc)
let publicSwitch = newStandardSwitch()
ductrClientTest(behindNATSwitch, publicSwitch):
try:
let client = DcutrClient.new(connectTimeout = 5.millis)
await client.startSync(behindNATSwitch, publicSwitch.peerInfo.peerId, behindNATSwitch.peerInfo.addrs)
except DcutrError as err:
check err.parent of AsyncTimeoutError
let behindNATSwitch = SwitchStub.new(newStandardSwitch(), connectTimeoutProc)
let publicSwitch = newStandardSwitch()

ductrClientTest(behindNATSwitch, publicSwitch):
try:
let client = DcutrClient.new(connectTimeout = 5.millis)
await client.startSync(behindNATSwitch, publicSwitch.peerInfo.peerId, behindNATSwitch.peerInfo.addrs)
except DcutrError as err:
check err.parent of AsyncTimeoutError

# FAILS
asyncTest "All client connect attempts fail":

proc connectErrorProc(self: SwitchStub,
Expand Down Expand Up @@ -149,13 +155,17 @@ suite "Dcutr":
# tcp simultaneous incoming upgrader in the dialer which works only in the simultaneous open case.
await DcutrClient.new().startSync(behindNATSwitch, publicSwitch.peerInfo.peerId, behindNATSwitch.peerInfo.addrs)
.wait(300.millis)
# TODO
# await DcutrClient.new().startSync(behindNATSwitch, publicSwitch.peerInfo.peerId, behindNATSwitch.peerInfo.addrs)
# .wait(1000.millis)

checkExpiring:
# we still expect a new connection to be open by the receiver peer acting as the dcutr server
behindNATSwitch.connManager.connCount(publicSwitch.peerInfo.peerId) == 1

await allFutures(behindNATSwitch.stop(), publicSwitch.stop())

# FAILS
asyncTest "DCUtR server timeout when establishing a new connection":

proc connectProc(self: SwitchStub,
Expand All @@ -165,9 +175,12 @@ suite "Dcutr":
reuseConnection = true,
dir = Direction.Out): Future[void] {.async.} =
await sleepAsync(100.millis)
# TODO
# await sleepAsync(1000.millis)

await ductrServerTest(connectProc)

# FAILS
asyncTest "DCUtR server error when establishing a new connection":

proc connectProc(self: SwitchStub,
Expand Down
5 changes: 4 additions & 1 deletion tests/testhpservice.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ suite "Hole Punching":
teardown:
checkTrackers()

# FAILS
asyncTest "Direct connection must work when peer address is public":
let autonatClientStub = AutonatClientStub.new(expectedDials = 1)
autonatClientStub.answer = NotReachable
Expand Down Expand Up @@ -96,6 +97,7 @@ suite "Hole Punching":
await allFuturesThrowing(
privatePeerSwitch.stop(), publicPeerSwitch.stop(), switchRelay.stop(), peerSwitch.stop())

# FAILS
asyncTest "Direct connection must work when peer address is public and dns is used":

let autonatClientStub = AutonatClientStub.new(expectedDials = 1)
Expand Down Expand Up @@ -200,11 +202,12 @@ suite "Hole Punching":
privatePeerSwitch1.stop(), privatePeerSwitch2.stop(), switchRelay.stop(),
switchAux.stop(), switchAux2.stop(), switchAux3.stop(), switchAux4.stop())

# FAILS
asyncTest "Hole punching when peers addresses are private":
await holePunchingTest(nil, nil, NotReachable)

# FAILS
asyncTest "Hole punching when peers addresses are private and there is an error in the initiator side":

proc connectStub(self: SwitchStub,
peerId: PeerId,
addrs: seq[MultiAddress],
Expand Down

0 comments on commit aa0e7c2

Please sign in to comment.