From af895a81d5fa9ab976afa2d1daefc050877ab95a Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Thu, 16 Nov 2017 20:05:22 -0500 Subject: [PATCH] Fix most "go vet" errors. --- p2p/host/basic/basic_host_test.go | 4 ++-- p2p/net/mock/mock_peernet.go | 2 +- p2p/net/mock/mock_test.go | 4 ++-- p2p/test/backpressure/backpressure_test.go | 6 +++--- p2p/test/reconnects/reconnect_test.go | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/p2p/host/basic/basic_host_test.go b/p2p/host/basic/basic_host_test.go index 4c14934..7cf8136 100644 --- a/p2p/host/basic/basic_host_test.go +++ b/p2p/host/basic/basic_host_test.go @@ -54,7 +54,7 @@ func TestHostSimple(t *testing.T) { t.Fatal(err) } if !bytes.Equal(buf1, buf2) { - t.Fatal("buf1 != buf2 -- %x != %x", buf1, buf2) + t.Fatalf("buf1 != buf2 -- %x != %x", buf1, buf2) } // get it from the pipe (tee) @@ -63,7 +63,7 @@ func TestHostSimple(t *testing.T) { t.Fatal(err) } if !bytes.Equal(buf1, buf3) { - t.Fatal("buf1 != buf3 -- %x != %x", buf1, buf3) + t.Fatalf("buf1 != buf3 -- %x != %x", buf1, buf3) } } diff --git a/p2p/net/mock/mock_peernet.go b/p2p/net/mock/mock_peernet.go index 26d5a3b..42361ac 100644 --- a/p2p/net/mock/mock_peernet.go +++ b/p2p/net/mock/mock_peernet.go @@ -205,7 +205,7 @@ func (pn *peernet) removeConn(c *conn) { cs, found = pn.connsByPeer[c.remote] if !found { - panic(fmt.Sprintf("attempting to remove a conn that doesnt exist %p", c.remote)) + panic(fmt.Sprintf("attempting to remove a conn that doesnt exist %v", c.remote)) } delete(cs, c) } diff --git a/p2p/net/mock/mock_test.go b/p2p/net/mock/mock_test.go index 6f6b20c..5c6c2cb 100644 --- a/p2p/net/mock/mock_test.go +++ b/p2p/net/mock/mock_test.go @@ -166,7 +166,7 @@ func TestNetworkSetup(t *testing.T) { links12 = mn.LinksBetweenPeers(p1, p2) if len(links12) != 0 { - t.Errorf("should be 0 now...", len(links12)) + t.Error("should be 0 now...", len(links12)) } links11 = mn.LinksBetweenPeers(p1, p1) @@ -190,7 +190,7 @@ func TestNetworkSetup(t *testing.T) { // first, no conns if len(n2.Conns()) > 0 || len(n3.Conns()) > 0 { - t.Error("should have 0 conn. Got: (%d, %d)", len(n2.Conns()), len(n3.Conns())) + t.Errorf("should have 0 conn. Got: (%d, %d)", len(n2.Conns()), len(n3.Conns())) } // connect p2->p3 diff --git a/p2p/test/backpressure/backpressure_test.go b/p2p/test/backpressure/backpressure_test.go index 163c705..8e78311 100644 --- a/p2p/test/backpressure/backpressure_test.go +++ b/p2p/test/backpressure/backpressure_test.go @@ -146,7 +146,7 @@ a problem. h2pi := h2.Peerstore().PeerInfo(h2.ID()) log.Debugf("dialing %s", h2pi.Addrs) if err := h1.Connect(ctx, h2pi); err != nil { - t.Fatalf("Failed to connect:", err) + t.Fatal("Failed to connect:", err) } // launch sender! @@ -266,7 +266,7 @@ func TestStBackpressureStreamWrite(t *testing.T) { t.Error("read failed:", err) } if expect != n { - t.Error("read len differs: %d != %d", expect, n) + t.Errorf("read len differs: %d != %d", expect, n) } } @@ -283,7 +283,7 @@ func TestStBackpressureStreamWrite(t *testing.T) { h2pi := h2.Peerstore().PeerInfo(h2.ID()) log.Debugf("dialing %s", h2pi.Addrs) if err := h1.Connect(ctx, h2pi); err != nil { - t.Fatalf("Failed to connect:", err) + t.Fatal("Failed to connect:", err) } // open a stream, from 2->1, this is our reader diff --git a/p2p/test/reconnects/reconnect_test.go b/p2p/test/reconnects/reconnect_test.go index 55b7b1c..e8851ef 100644 --- a/p2p/test/reconnects/reconnect_test.go +++ b/p2p/test/reconnects/reconnect_test.go @@ -174,7 +174,7 @@ func SubtestConnSendDisc(t *testing.T, hosts []host.Host) { h2pi := h2.Peerstore().PeerInfo(h2.ID()) log.Debugf("dialing %s", h2pi.Addrs) if err := h1.Connect(ctx, h2pi); err != nil { - t.Fatalf("Failed to connect:", err) + t.Fatal("Failed to connect:", err) } } } -- GitLab