Add more checks for nat integration tests

This commit is contained in:
Arnaud 2026-06-15 22:47:22 +04:00
parent caff5f3136
commit c6bfc88926
No known key found for this signature in database
GPG Key ID: A6C7C781817146FA
5 changed files with 27 additions and 0 deletions

View File

@ -5,6 +5,10 @@
import std/[os, osproc]
import ../utils
const
routerWanIp* = "7.7.7.2" ## public IP AutoNAT observes for a NATed node (masquerade)
bootstrapIp* = "7.7.7.10" ## relay + bootstrap public IP
proc composeCmd(composeFile: string): string =
## Prefer podman (where the Makefile builds the image), fall back to docker.
let base =

View File

@ -45,3 +45,10 @@ asyncchecksuite "NAT not reachable":
check nat{"relayRunning"}.getBool
check nat{"portMapping"}.getStr == "none"
check info.announcesCircuitAddr()
let announced = info{"announceAddresses"}.getElems.mapIt(it.getStr)
# the announced circuit address points at the bootstrap's relay
check announced.anyIt(
("/ip4/" & bootstrapIp & "/tcp/8070" in it) and ("p2p-circuit" in it)
)
# relay addresses go only into the provider record, never the DHT routing record
check info{"dhtAddresses"}.getElems.len == 0

View File

@ -52,3 +52,9 @@ asyncchecksuite "NAT pcp":
check nat{"relayRunning"}.getBool == false
check nat{"portMapping"}.getStr == "pcp"
check info.announcesDirectAddr()
let announced = info{"announceAddresses"}.getElems.mapIt(it.getStr)
# PCP may map a port different from the listen port, so check the IP only
check announced.anyIt(("/ip4/" & routerWanIp & "/tcp/") in it)
# the public mapped address
# a reachable node announces its UDP address to the DHT routing record
check info{"dhtAddresses"}.getElems.len > 0

View File

@ -52,3 +52,8 @@ asyncchecksuite "NAT reachable":
check nat{"reachability"}.getStr == "Reachable"
check nat{"relayRunning"}.getBool == false
check info.announcesDirectAddr()
let announced = info{"announceAddresses"}.getElems.mapIt(it.getStr)
check announced.anyIt(("/ip4/" & routerWanIp & "/tcp/8070") in it)
# public forwarded address
# a reachable node announces its UDP address to the DHT routing record
check info{"dhtAddresses"}.getElems.len > 0

View File

@ -52,3 +52,8 @@ asyncchecksuite "NAT upnp":
check nat{"relayRunning"}.getBool == false
check nat{"portMapping"}.getStr == "upnp"
check info.announcesDirectAddr()
let announced = info{"announceAddresses"}.getElems.mapIt(it.getStr)
check announced.anyIt(("/ip4/" & routerWanIp & "/tcp/8070") in it)
# public mapped address
# a reachable node announces its UDP address to the DHT routing record
check info{"dhtAddresses"}.getElems.len > 0