test to make sure we only consider addresses that *start* with IP addresses

(would have failed with ValueForProtocol)
This commit is contained in:
Steven Allen 2018-10-18 14:00:36 +01:00
parent 0425819f0e
commit 115f321e21

View File

@ -32,4 +32,17 @@ func TestIsPublicAddr(t *testing.T) {
if IsPrivateAddr(a) {
t.Fatal("1.1.1.1 is not a private address!")
}
a, err = ma.NewMultiaddr("/tcp/80/ip4/1.1.1.1")
if err != nil {
t.Fatal(err)
}
if IsPublicAddr(a) {
t.Fatal("shouldn't consider an address that starts with /tcp/ as *public*")
}
if IsPrivateAddr(a) {
t.Fatal("shouldn't consider an address that starts with /tcp/ as *private*")
}
}