From 115f321e211fcc723f6035524075c7caa2d7c8a8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 18 Oct 2018 14:00:36 +0100 Subject: [PATCH] test to make sure we only consider addresses that *start* with IP addresses (would have failed with ValueForProtocol) --- private_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/private_test.go b/private_test.go index ddd6485..a4380a5 100644 --- a/private_test.go +++ b/private_test.go @@ -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*") + } }