github.com/ethersphere/bee/v2@v2.2.0/pkg/p2p/p2p_test.go (about) 1 // Copyright 2020 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package p2p_test 6 7 import ( 8 "testing" 9 10 "github.com/ethersphere/bee/v2/pkg/p2p" 11 "github.com/libp2p/go-libp2p/core/network" 12 ) 13 14 func TestNewSwarmStreamName(t *testing.T) { 15 t.Parallel() 16 17 want := "/swarm/hive/1.2.0/peers" 18 got := p2p.NewSwarmStreamName("hive", "1.2.0", "peers") 19 20 if got != want { 21 t.Errorf("got %s, want %s", got, want) 22 } 23 } 24 25 func TestReachabilityStatus_String(t *testing.T) { 26 t.Parallel() 27 28 mapping := map[string]string{ 29 p2p.ReachabilityStatusUnknown.String(): network.ReachabilityUnknown.String(), 30 p2p.ReachabilityStatusPrivate.String(): network.ReachabilityPrivate.String(), 31 p2p.ReachabilityStatusPublic.String(): network.ReachabilityPublic.String(), 32 } 33 for have, want := range mapping { 34 if have != want { 35 t.Fatalf("have reachability status string %q; want %q", have, want) 36 } 37 } 38 }