From aa0d9e812b789e055d75aa4a3c7e727f334b15f4 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Thu, 14 May 2026 12:15:14 +0400 Subject: [PATCH] Update tests --- tests/integration/1_minute/testnat.nim | 12 +++++++++--- tests/integration/1_minute/testnatupnp.nim | 10 ++++++---- tests/storage/testnat.nim | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/integration/1_minute/testnat.nim b/tests/integration/1_minute/testnat.nim index 795ed6b6..79efee9e 100644 --- a/tests/integration/1_minute/testnat.nim +++ b/tests/integration/1_minute/testnat.nim @@ -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": diff --git a/tests/integration/1_minute/testnatupnp.nim b/tests/integration/1_minute/testnatupnp.nim index 3c09c9c5..933e6204 100644 --- a/tests/integration/1_minute/testnatupnp.nim +++ b/tests/integration/1_minute/testnatupnp.nim @@ -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 = diff --git a/tests/storage/testnat.nim b/tests/storage/testnat.nim index 888279ee..d4c14f23 100644 --- a/tests/storage/testnat.nim +++ b/tests/storage/testnat.nim @@ -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)))