Browse Source

resolve import cycle in ping test

pull/458/head
vyzo 6 years ago
parent
commit
48e0effd6a
  1. 9
      p2p/protocol/ping/ping_test.go

9
p2p/protocol/ping/ping_test.go

@ -1,4 +1,4 @@
package ping package ping_test
import ( import (
"context" "context"
@ -9,6 +9,7 @@ import (
pstore "github.com/libp2p/go-libp2p-peerstore" pstore "github.com/libp2p/go-libp2p-peerstore"
swarmt "github.com/libp2p/go-libp2p-swarm/testing" swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
ping "github.com/libp2p/go-libp2p/p2p/protocol/ping"
) )
func TestPing(t *testing.T) { func TestPing(t *testing.T) {
@ -26,14 +27,14 @@ func TestPing(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
ps1 := NewPingService(h1) ps1 := ping.NewPingService(h1)
ps2 := NewPingService(h2) ps2 := ping.NewPingService(h2)
testPing(t, ps1, h2.ID()) testPing(t, ps1, h2.ID())
testPing(t, ps2, h1.ID()) testPing(t, ps2, h1.ID())
} }
func testPing(t *testing.T, ps *PingService, p peer.ID) { func testPing(t *testing.T, ps *ping.PingService, p peer.ID) {
pctx, cancel := context.WithCancel(context.Background()) pctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
ts, err := ps.Ping(pctx, p) ts, err := ps.Ping(pctx, p)

Loading…
Cancel
Save