fix(netxlite): consolidate IPv4/IPv6 checking code (#726)

Originally 966e7f7cdd

See https://github.com/ooni/probe/issues/2096
This commit is contained in:
Simone Basso 2022-05-13 18:49:18 +02:00 committed by GitHub
commit 192dfd49b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 12 deletions

View file

@ -57,7 +57,9 @@ func TestQuirkSortIPAddrs(t *testing.T) {
addrs := []string{
"::1",
"192.168.1.2",
"x.org", // ensure we skip non IP addrs
"2a00:1450:4002:404::2004",
"example.com", // ensure we skip non IP addrs
"142.250.184.36",
"2604:8800:5000:82:466:38ff:fecb:d46e",
"198.145.29.83",
@ -83,4 +85,14 @@ func TestQuirkSortIPAddrs(t *testing.T) {
t.Fatal("expected nil output")
}
})
t.Run("with non-IP addrs", func(t *testing.T) {
addrs := []string{
"example.com",
"x.org",
}
if quirkSortIPAddrs(addrs) != nil {
t.Fatal("expected nil output")
}
})
}