Skip to content

Commit 115f321

Browse files
committed
test to make sure we only consider addresses that *start* with IP addresses
(would have failed with ValueForProtocol)
1 parent 0425819 commit 115f321

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

private_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,17 @@ func TestIsPublicAddr(t *testing.T) {
3232
if IsPrivateAddr(a) {
3333
t.Fatal("1.1.1.1 is not a private address!")
3434
}
35+
36+
a, err = ma.NewMultiaddr("/tcp/80/ip4/1.1.1.1")
37+
if err != nil {
38+
t.Fatal(err)
39+
}
40+
41+
if IsPublicAddr(a) {
42+
t.Fatal("shouldn't consider an address that starts with /tcp/ as *public*")
43+
}
44+
45+
if IsPrivateAddr(a) {
46+
t.Fatal("shouldn't consider an address that starts with /tcp/ as *private*")
47+
}
3548
}

0 commit comments

Comments
 (0)