mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-10-22 15:49:39 +08:00
Consolidate abstractions and core types into go-libp2p-core (#601)
This commit is contained in:
@@ -8,19 +8,19 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
testutil "github.com/libp2p/go-testutil"
|
||||
"github.com/libp2p/go-libp2p-core/helpers"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p-core/test"
|
||||
|
||||
host "github.com/libp2p/go-libp2p-host"
|
||||
inet "github.com/libp2p/go-libp2p-net"
|
||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
||||
protocol "github.com/libp2p/go-libp2p-protocol"
|
||||
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
madns "github.com/multiformats/go-multiaddr-dns"
|
||||
)
|
||||
|
||||
func TestHostSimple(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
h1 := New(swarmt.GenSwarm(t, ctx))
|
||||
h2 := New(swarmt.GenSwarm(t, ctx))
|
||||
@@ -33,7 +33,7 @@ func TestHostSimple(t *testing.T) {
|
||||
}
|
||||
|
||||
piper, pipew := io.Pipe()
|
||||
h2.SetStreamHandler(protocol.TestingID, func(s inet.Stream) {
|
||||
h2.SetStreamHandler(protocol.TestingID, func(s network.Stream) {
|
||||
defer s.Close()
|
||||
w := io.MultiWriter(s, pipew)
|
||||
io.Copy(w, s) // mirror everything
|
||||
@@ -125,7 +125,7 @@ func TestHostProtoPreference(t *testing.T) {
|
||||
|
||||
connectedOn := make(chan protocol.ID)
|
||||
|
||||
handler := func(s inet.Stream) {
|
||||
handler := func(s network.Stream) {
|
||||
connectedOn <- s.Protocol()
|
||||
s.Close()
|
||||
}
|
||||
@@ -140,7 +140,7 @@ func TestHostProtoPreference(t *testing.T) {
|
||||
assertWait(t, connectedOn, protoOld)
|
||||
s.Close()
|
||||
|
||||
mfunc, err := host.MultistreamSemverMatcher(protoMinor)
|
||||
mfunc, err := helpers.MultistreamSemverMatcher(protoMinor)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func TestHostProtoMismatch(t *testing.T) {
|
||||
defer h1.Close()
|
||||
defer h2.Close()
|
||||
|
||||
h1.SetStreamHandler("/super", func(s inet.Stream) {
|
||||
h1.SetStreamHandler("/super", func(s network.Stream) {
|
||||
t.Error("shouldnt get here")
|
||||
s.Reset()
|
||||
})
|
||||
@@ -199,7 +199,7 @@ func TestHostProtoPreknowledge(t *testing.T) {
|
||||
h2 := New(swarmt.GenSwarm(t, ctx))
|
||||
|
||||
conn := make(chan protocol.ID)
|
||||
handler := func(s inet.Stream) {
|
||||
handler := func(s network.Stream) {
|
||||
conn <- s.Protocol()
|
||||
s.Close()
|
||||
}
|
||||
@@ -258,7 +258,7 @@ func TestNewDialOld(t *testing.T) {
|
||||
defer h2.Close()
|
||||
|
||||
connectedOn := make(chan protocol.ID)
|
||||
h1.SetStreamHandler("/testing", func(s inet.Stream) {
|
||||
h1.SetStreamHandler("/testing", func(s network.Stream) {
|
||||
connectedOn <- s.Protocol()
|
||||
s.Close()
|
||||
})
|
||||
@@ -286,7 +286,7 @@ func TestProtoDowngrade(t *testing.T) {
|
||||
defer h2.Close()
|
||||
|
||||
connectedOn := make(chan protocol.ID)
|
||||
h1.SetStreamHandler("/testing/1.0.0", func(s inet.Stream) {
|
||||
h1.SetStreamHandler("/testing/1.0.0", func(s network.Stream) {
|
||||
connectedOn <- s.Protocol()
|
||||
s.Close()
|
||||
})
|
||||
@@ -307,7 +307,7 @@ func TestProtoDowngrade(t *testing.T) {
|
||||
|
||||
time.Sleep(time.Millisecond * 50) // allow notifications to propogate
|
||||
h1.RemoveStreamHandler("/testing/1.0.0")
|
||||
h1.SetStreamHandler("/testing", func(s inet.Stream) {
|
||||
h1.SetStreamHandler("/testing", func(s network.Stream) {
|
||||
connectedOn <- s.Protocol()
|
||||
s.Close()
|
||||
})
|
||||
@@ -339,11 +339,11 @@ func TestProtoDowngrade(t *testing.T) {
|
||||
func TestAddrResolution(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
p1, err := testutil.RandPeerID()
|
||||
p1, err := test.RandPeerID()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
p2, err := testutil.RandPeerID()
|
||||
p2, err := test.RandPeerID()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -363,7 +363,7 @@ func TestAddrResolution(t *testing.T) {
|
||||
h := New(swarmt.GenSwarm(t, ctx), resolver)
|
||||
defer h.Close()
|
||||
|
||||
pi, err := pstore.InfoFromP2pAddr(p2paddr1)
|
||||
pi, err := peer.AddrInfoFromP2pAddr(p2paddr1)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user