Update tests

This commit is contained in:
Arnaud 2026-05-14 12:15:14 +04:00
parent 084f3dfa04
commit aa0d9e812b
No known key found for this signature in database
GPG Key ID: A6C7C781817146FA
3 changed files with 16 additions and 8 deletions

View File

@ -14,7 +14,10 @@ const
PollInterval = 1_000
proc checkNatStatus*(
client: StorageClient, reachability: string, relayRunning: bool
client: StorageClient,
reachability: string,
relayRunning: bool,
clientMode: bool,
) {.async.} =
check eventuallySafe(
block:
@ -22,7 +25,7 @@ proc checkNatStatus*(
let nat = info["nat"]
let addrs = info["addrs"].getElems.mapIt(it.getStr)
nat["reachability"].getStr() == reachability and
nat["clientMode"].getBool() == relayRunning and
nat["clientMode"].getBool() == clientMode and
nat["relayRunning"].getBool() == relayRunning and
addrs.anyIt("p2p-circuit" in it) == relayRunning,
timeout = RelayTimeout,
@ -30,7 +33,10 @@ proc checkNatStatus*(
)
proc checkNatStatus*(client: StorageClient, reachability: string) {.async.} =
await client.checkNatStatus(reachability, reachability == "NotReachable")
let notReachable = reachability == "NotReachable"
await client.checkNatStatus(
reachability, relayRunning = notReachable, clientMode = notReachable
)
# Reminder: multinodesuite setup the first node as bootstrap node
multinodesuite "AutoNAT detection":

View File

@ -39,8 +39,9 @@ multinodesuite "AutoNAT UPnP port mapping":
let node2 = clients()[1]
let isRelayRunning = false
await node2.client.checkNatStatus("NotReachable", isRelayRunning)
await node2.client.checkNatStatus(
"NotReachable", relayRunning = false, clientMode = true
)
check eventuallySafe(
block:
@ -52,8 +53,9 @@ multinodesuite "AutoNAT UPnP port mapping":
# Ideally we should find a way to test that the node is Reachable now
let isRelayRunning = false
await node2.client.checkNatStatus("NotReachable", isRelayRunning)
await node2.client.checkNatStatus(
"NotReachable", relayRunning = false, clientMode = true
)
# Extract mapped TCP port from announce addresses and verify it exists on the IGD
let announceAddrs =

View File

@ -95,7 +95,7 @@ asyncchecksuite "NAT - handleNatStatus":
check disc.announceAddrs ==
@[MultiAddress.init("/ip4/1.2.3.4/tcp/9000").expect("valid")]
check not autoRelay.isRunning
check not disc.protocol.clientMode
check disc.protocol.clientMode
test "handleNatStatus starts autoRelay when NotReachable and UPnP failed":
let mapper = MockNatMapper(mappedPorts: none((Port, Port)))