mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-06-30 14:29:29 +00:00
Refactoring
This commit is contained in:
parent
bdbd9ed543
commit
df40f4c6e3
@ -19,10 +19,6 @@ import ../../../checktest
|
||||
import ../../storageclient
|
||||
import ../composehelper
|
||||
|
||||
const
|
||||
detectTimeout = 300_000 # ms
|
||||
pollInterval = 5_000 # ms
|
||||
|
||||
proc announcesNothing(info: JsonNode): bool =
|
||||
## An unreachable node with no relay has no dialable address to announce.
|
||||
info{"announceAddresses"}.getElems.len == 0
|
||||
@ -53,19 +49,9 @@ asyncchecksuite "NAT not downloadable":
|
||||
|
||||
test testName:
|
||||
# Make sure nodeClient is not reachable
|
||||
check eventuallySafe(
|
||||
block:
|
||||
var settled = false
|
||||
try:
|
||||
let info = await nodeClient.info()
|
||||
settled =
|
||||
info.isOk and info.get{"nat"}{"reachability"}.getStr == "NotReachable" and
|
||||
info.get.announcesNothing()
|
||||
except HttpError:
|
||||
discard
|
||||
settled,
|
||||
timeout = detectTimeout,
|
||||
pollInterval = pollInterval,
|
||||
check eventuallyInfo(
|
||||
nodeClient,
|
||||
info{"nat"}{"reachability"}.getStr == "NotReachable" and info.announcesNothing(),
|
||||
)
|
||||
|
||||
let info = (await nodeClient.info()).get
|
||||
@ -74,19 +60,7 @@ asyncchecksuite "NAT not downloadable":
|
||||
check info.announcesNothing()
|
||||
|
||||
# C is reachable
|
||||
check eventuallySafe(
|
||||
block:
|
||||
var reachable = false
|
||||
try:
|
||||
let cInfo = await clientC.info()
|
||||
reachable =
|
||||
cInfo.isOk and cInfo.get{"nat"}{"reachability"}.getStr == "Reachable"
|
||||
except HttpError:
|
||||
discard
|
||||
reachable,
|
||||
timeout = detectTimeout,
|
||||
pollInterval = pollInterval,
|
||||
)
|
||||
check eventuallyInfo(clientC, info{"nat"}{"reachability"}.getStr == "Reachable")
|
||||
|
||||
# B uploads a file
|
||||
let cid = (await nodeClient.upload("hello from behind the NAT")).get
|
||||
|
||||
@ -13,10 +13,6 @@ import ../../../checktest
|
||||
import ../../storageclient
|
||||
import ../composehelper
|
||||
|
||||
const
|
||||
detectTimeout = 300_000 # ms
|
||||
pollInterval = 5_000 # ms
|
||||
|
||||
proc announcesCircuitAddr(info: JsonNode): bool =
|
||||
info{"announceAddresses"}.getElems.anyIt("p2p-circuit" in it.getStr)
|
||||
|
||||
@ -41,19 +37,7 @@ asyncchecksuite "NAT not reachable":
|
||||
|
||||
test testName:
|
||||
# Wait for the announcements, after the relay reservation is created.
|
||||
check eventuallySafe(
|
||||
block:
|
||||
var settled = false
|
||||
try:
|
||||
let info = await client.info()
|
||||
settled = info.isOk and info.get.announcesCircuitAddr()
|
||||
except HttpError:
|
||||
# B's API is not up yet, keep polling
|
||||
discard
|
||||
settled,
|
||||
timeout = detectTimeout,
|
||||
pollInterval = pollInterval,
|
||||
)
|
||||
check eventuallyInfo(client, info.announcesCircuitAddr())
|
||||
|
||||
let info = (await client.info()).get
|
||||
let nat = info{"nat"}
|
||||
|
||||
@ -18,10 +18,6 @@ import ../../../checktest
|
||||
import ../../storageclient
|
||||
import ../composehelper
|
||||
|
||||
const
|
||||
detectTimeout = 300_000 # ms
|
||||
pollInterval = 5_000 # ms
|
||||
|
||||
proc announcesDirectAddr(info: JsonNode): bool =
|
||||
## A reachable node announces at least one direct (non-circuit) address.
|
||||
info{"announceAddresses"}.getElems.anyIt("p2p-circuit" notin it.getStr)
|
||||
@ -48,19 +44,7 @@ asyncchecksuite "NAT pcp":
|
||||
test testName:
|
||||
# Reachable is the settling signal: wait for it, then assert each expected
|
||||
# property separately so a failure points at the exact condition.
|
||||
check eventuallySafe(
|
||||
block:
|
||||
var reachable = false
|
||||
try:
|
||||
let info = await client.info()
|
||||
reachable =
|
||||
info.isOk and info.get{"nat"}{"reachability"}.getStr == "Reachable"
|
||||
except HttpError:
|
||||
discard # B's API is not up yet, keep polling
|
||||
reachable,
|
||||
timeout = detectTimeout,
|
||||
pollInterval = pollInterval,
|
||||
)
|
||||
check eventuallyInfo(client, info{"nat"}{"reachability"}.getStr == "Reachable")
|
||||
|
||||
let info = (await client.info()).get
|
||||
let nat = info{"nat"}
|
||||
|
||||
@ -19,10 +19,6 @@ import ../../../checktest
|
||||
import ../../storageclient
|
||||
import ../composehelper
|
||||
|
||||
const
|
||||
detectTimeout = 120_000 # ms
|
||||
pollInterval = 5_000 # ms
|
||||
|
||||
proc announcesDirectAddr(info: JsonNode): bool =
|
||||
## A reachable node announces at least one direct (non-circuit) address.
|
||||
info{"announceAddresses"}.getElems.anyIt("p2p-circuit" notin it.getStr)
|
||||
@ -49,19 +45,7 @@ asyncchecksuite "NAT reachable":
|
||||
test testName:
|
||||
# Reachable is the settling signal: wait for it, then assert each expected
|
||||
# property separately so a failure points at the exact condition.
|
||||
check eventuallySafe(
|
||||
block:
|
||||
var reachable = false
|
||||
try:
|
||||
let info = await client.info()
|
||||
reachable =
|
||||
info.isOk and info.get{"nat"}{"reachability"}.getStr == "Reachable"
|
||||
except HttpError:
|
||||
discard # B's API is not up yet, keep polling
|
||||
reachable,
|
||||
timeout = detectTimeout,
|
||||
pollInterval = pollInterval,
|
||||
)
|
||||
check eventuallyInfo(client, info{"nat"}{"reachability"}.getStr == "Reachable")
|
||||
|
||||
let info = (await client.info()).get
|
||||
let nat = info{"nat"}
|
||||
|
||||
@ -18,10 +18,6 @@ import ../../../checktest
|
||||
import ../../storageclient
|
||||
import ../composehelper
|
||||
|
||||
const
|
||||
detectTimeout = 300_000 # ms
|
||||
pollInterval = 5_000 # ms
|
||||
|
||||
proc announcesDirectAddr(info: JsonNode): bool =
|
||||
## A reachable node announces at least one direct (non-circuit) address.
|
||||
info{"announceAddresses"}.getElems.anyIt("p2p-circuit" notin it.getStr)
|
||||
@ -48,19 +44,7 @@ asyncchecksuite "NAT upnp":
|
||||
test testName:
|
||||
# Reachable is the settling signal: wait for it, then assert each expected
|
||||
# property separately so a failure points at the exact condition.
|
||||
check eventuallySafe(
|
||||
block:
|
||||
var reachable = false
|
||||
try:
|
||||
let info = await client.info()
|
||||
reachable =
|
||||
info.isOk and info.get{"nat"}{"reachability"}.getStr == "Reachable"
|
||||
except HttpError:
|
||||
discard # B's API is not up yet, keep polling
|
||||
reachable,
|
||||
timeout = detectTimeout,
|
||||
pollInterval = pollInterval,
|
||||
)
|
||||
check eventuallyInfo(client, info{"nat"}{"reachability"}.getStr == "Reachable")
|
||||
|
||||
let info = (await client.info()).get
|
||||
let nat = info{"nat"}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user