package swarm_test import ( "context" "testing" "github.com/libp2p/go-libp2p-core/peerstore" "github.com/libp2p/go-libp2p-core/test" ma "github.com/multiformats/go-multiaddr" ) func TestDialBadAddrs(t *testing.T) { m := func(s string) ma.Multiaddr { maddr, err := ma.NewMultiaddr(s) if err != nil { t.Fatal(err) } return maddr } ctx := context.Background() s := makeSwarms(ctx, t, 1)[0] test := func(a ma.Multiaddr) { p := test.RandPeerIDFatal(t) s.Peerstore().AddAddr(p, a, peerstore.PermanentAddrTTL) if _, err := s.DialPeer(ctx, p); err == nil { t.Errorf("swarm should not dial: %s", p) } } test(m("/ip6/fe80::1")) // link local test(m("/ip6/fe80::100")) // link local test(m("/ip4/127.0.0.1/udp/1234/utp")) // utp }