mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
whisper: warning removal in libp2p Stream
This commit is contained in:
parent
729de332dc
commit
38fd361b95
1 changed files with 5 additions and 7 deletions
|
|
@ -24,19 +24,17 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
// libp2p "github.com/libp2p/go-libp2p"
|
|
||||||
host "github.com/libp2p/go-libp2p-host"
|
host "github.com/libp2p/go-libp2p-host"
|
||||||
// crypto "github.com/libp2p/go-libp2p-crypto"
|
|
||||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||||
testutil "github.com/libp2p/go-testutil"
|
testutil "github.com/libp2p/go-testutil"
|
||||||
inet "github.com/libp2p/go-libp2p-net"
|
inet "github.com/libp2p/go-libp2p-net"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
testProtocolId = "/whispertesting/6.1"
|
testProtocolID = "/whispertesting/6.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createTestNetwork(t *testing.T, ctx context.Context, n int) []host.Host {
|
func createTestNetwork(ctx context.Context, t *testing.T, n int) []host.Host {
|
||||||
net := make([]host.Host, n)
|
net := make([]host.Host, n)
|
||||||
mn := mocknet.New(ctx)
|
mn := mocknet.New(ctx)
|
||||||
|
|
||||||
|
|
@ -71,7 +69,7 @@ func createTestNetwork(t *testing.T, ctx context.Context, n int) []host.Host {
|
||||||
|
|
||||||
func TestSimpleCode(t *testing.T) {
|
func TestSimpleCode(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
hosts := createTestNetwork(t, ctx, 2)
|
hosts := createTestNetwork(ctx, t, 2)
|
||||||
|
|
||||||
code := rand.Uint64()
|
code := rand.Uint64()
|
||||||
size := rand.Uint32() % 512
|
size := rand.Uint32() % 512
|
||||||
|
|
@ -81,7 +79,7 @@ func TestSimpleCode(t *testing.T) {
|
||||||
t.Fatalf("Read %d random bytes instead of the expected %d, err: %v", n, size, err)
|
t.Fatalf("Read %d random bytes instead of the expected %d, err: %v", n, size, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hosts[0].SetStreamHandler(testProtocolId, func (s inet.Stream) {
|
hosts[0].SetStreamHandler(testProtocolID, func (s inet.Stream) {
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
raw := make([]byte, size + codeLength + payloadSizeLength)
|
raw := make([]byte, size + codeLength + payloadSizeLength)
|
||||||
|
|
@ -104,7 +102,7 @@ func TestSimpleCode(t *testing.T) {
|
||||||
t.Fatalf("Encoded payload differ from source")
|
t.Fatalf("Encoded payload differ from source")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
stream, err := hosts[1].NewStream(ctx, hosts[0].ID(), testProtocolId)
|
stream, err := hosts[1].NewStream(ctx, hosts[0].ID(), testProtocolID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue