mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-07-20 08:10:24 +00:00
Update tests
This commit is contained in:
parent
084f3dfa04
commit
aa0d9e812b
@ -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":
|
||||
|
||||
@ -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 =
|
||||
|
||||
@ -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)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user