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 29, 2023
1 parent 5f7a3ab commit 40ec256
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 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/
44 changes: 25 additions & 19 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 @@ -58,7 +59,7 @@ suite "Dcutr":
t.networkReachability = NetworkReachability.NotReachable

await DcutrClient.new().startSync(behindNATSwitch, publicSwitch.peerInfo.peerId, behindNATSwitch.peerInfo.addrs)
.wait(300.millis)
.wait(1000.millis)

checkExpiring:
# we can't hole punch when both peers are in the same machine. This means that the simultaneous dialings will result
Expand Down Expand Up @@ -88,25 +89,28 @@ suite "Dcutr":

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

# FAILS
asyncTest "Client connect timeout":
proc connectTimeoutProc(self: SwitchStub,
peerId: PeerId,
addrs: seq[MultiAddress],
forceDial = false,
reuseConnection = true,
upgradeDir = Direction.Out): Future[void] {.async.} =
await sleepAsync(100.millis)

let behindNATSwitch = SwitchStub.new(newStandardSwitch(), connectTimeoutProc)
let publicSwitch = newStandardSwitch()

ductrClientTest(behindNATSwitch, publicSwitch):

proc connectTimeoutProc(self: SwitchStub,
peerId: PeerId,
addrs: seq[MultiAddress],
forceDial = false,
reuseConnection = true,
upgradeDir = 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
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 @@ -143,7 +147,7 @@ suite "Dcutr":
t.networkReachability = NetworkReachability.NotReachable

await DcutrClient.new().startSync(behindNATSwitch, publicSwitch.peerInfo.peerId, behindNATSwitch.peerInfo.addrs)
.wait(300.millis)
.wait(1000.millis)

checkExpiring:
# we can't hole punch when both peers are in the same machine. This means that the simultaneous dialings will result
Expand All @@ -152,6 +156,7 @@ suite "Dcutr":

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

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

proc connectProc(self: SwitchStub,
Expand All @@ -160,10 +165,11 @@ suite "Dcutr":
forceDial = false,
reuseConnection = true,
upgradeDir = Direction.Out): Future[void] {.async.} =
await sleepAsync(100.millis)
await sleepAsync(1000.millis)

await ductrServerTest(connectProc)

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

proc connectProc(self: SwitchStub,
Expand Down
4 changes: 4 additions & 0 deletions 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 @@ -205,6 +207,7 @@ 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":
proc connectStub(self: SwitchStub,
peerId: PeerId,
Expand All @@ -217,6 +220,7 @@ suite "Hole Punching":
await self.switch.connect(peerId, addrs, forceDial, reuseConnection, upgradeDir)
await holePunchingTest(nil, connectStub, NotReachable)

# FAILS
asyncTest "Hole punching when there is an error during unilateral direct connection":

proc connectStub(self: SwitchStub,
Expand Down

0 comments on commit 40ec256

Please sign in to comment.