From 989148b7c85622f5025a61800ad5527bb0d0cca5 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Mon, 19 Feb 2018 14:49:41 +0100 Subject: [PATCH] whisper: warning removal --- whisper/whisperv6/libp2p_glue.go | 2 ++ whisper/whisperv6/libp2p_glue_test.go | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/whisper/whisperv6/libp2p_glue.go b/whisper/whisperv6/libp2p_glue.go index 2ed9cb1a9e..88959b1ff7 100644 --- a/whisper/whisperv6/libp2p_glue.go +++ b/whisper/whisperv6/libp2p_glue.go @@ -26,6 +26,8 @@ import ( inet "github.com/libp2p/go-libp2p-net" ) +// LibP2PStream is a wrapper used to implement the MsgReadWriter +// interface for libp2p's streams. type LibP2PStream struct { stream inet.Stream } diff --git a/whisper/whisperv6/libp2p_glue_test.go b/whisper/whisperv6/libp2p_glue_test.go index b56f3a4baa..102db8d1ed 100644 --- a/whisper/whisperv6/libp2p_glue_test.go +++ b/whisper/whisperv6/libp2p_glue_test.go @@ -17,18 +17,18 @@ package whisperv6 import ( - "math" - "encoding/binary" - "context" "bytes" - "testing" + "context" + "encoding/binary" + "math" "math/rand" + "testing" "github.com/ethereum/go-ethereum/p2p" host "github.com/libp2p/go-libp2p-host" + inet "github.com/libp2p/go-libp2p-net" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" testutil "github.com/libp2p/go-testutil" - inet "github.com/libp2p/go-libp2p-net" ) const ( @@ -82,10 +82,10 @@ func TestSimpleCode(t *testing.T) { 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() - raw := make([]byte, size + codeLength + payloadSizeLength) + raw := make([]byte, size+codeLength+payloadSizeLength) n, err = s.Read(raw) if len(raw) != n || err != nil { @@ -135,7 +135,7 @@ func TestSimpleDecode(t *testing.T) { ctx := context.Background() hosts := createTestNetwork(ctx, t, 2) - hosts[0].SetStreamHandler(testProtocolID, func (s inet.Stream) { + hosts[0].SetStreamHandler(testProtocolID, func(s inet.Stream) { defer s.Close() lps := LibP2PStream{ @@ -180,7 +180,7 @@ func TestSimpleCodeDecode(t *testing.T) { 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() lps := LibP2PStream{ @@ -245,7 +245,7 @@ func TestMaxWriteSize(t *testing.T) { 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() dummy := []byte{0x0} @@ -258,7 +258,7 @@ func TestMaxWriteSize(t *testing.T) { msg := p2p.Msg{ Code: code, - Size: math.MaxInt32+1, + Size: math.MaxInt32 + 1, Payload: bytes.NewReader(payload), }