Skip to content

Commit

Permalink
Adding test for invalid and inexistent DNS domains
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer committed Sep 19, 2023
1 parent d89c1d4 commit 2b225c6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_wakunode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,40 @@ suite "WakuNode":
not ipStr.contains("0.0.0.0")
not ipStr.contains("127.0.0.1")

asyncTest "Node creation fails when invalid dns4 address is provided":
let
nodeKey = generateSecp256k1Key()
bindIp = ValidIpAddress.init("0.0.0.0")
bindPort = Port(61010)

inexistentDomain = "thisdomain.doesnot.exist"
invalidDomain = ""

var inexistentDomainErr, invalidDomainErr: bool = false

# Create node with inexistent domain
try:
let node = newTestWakuNode(
nodeKey,
bindIp, bindPort,
dns4DomainName = some(inexistentDomain))
except CatchableError:
inexistentDomainErr = true

# Create node with invalid domain
try:
let node = newTestWakuNode(
nodeKey,
bindIp, bindPort,
dns4DomainName = some(invalidDomain))
except CatchableError:
invalidDomainErr = true

# Check that exceptions were raised in both cases
check:
inexistentDomainErr == true
invalidDomainErr == true

asyncTest "Agent string is set and advertised correctly":
let
# custom agent string
Expand Down

0 comments on commit 2b225c6

Please sign in to comment.