mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-05-21 00:39:29 +00:00
add test
This commit is contained in:
parent
984c8ac58b
commit
49e7bdea20
27
private_test.go
Normal file
27
private_test.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package manet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsPublicAddr(t *testing.T) {
|
||||||
|
a, err := ma.NewMultiaddr("/ip4/192.168.1.1/tcp/80")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if IsPublicAddr(a) {
|
||||||
|
t.Fatal("192.168.1.1 is not a public address!")
|
||||||
|
}
|
||||||
|
|
||||||
|
a, err = ma.NewMultiaddr("/ip4/1.1.1.1/tcp/80")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !IsPublicAddr(a) {
|
||||||
|
t.Fatal("1.1.1.1 is a public address!")
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user