Browse Source

Address `go vet` and `saticcheck` issues

Run `go mod tidy`

Resolve staticcheck issues:
- SA2002 `t.Fatal`  must be called in the same goroutine as the test
- U1000 unused struct
- ST1005 error string should not be capitalized

The `go vet` issues were the same as the ones reported by `saticcheck`.

Relates to:
- https://github.com/orgs/ipfs/projects/12#card-58209321
merge-testsuite-transports
Masih H. Derkani 3 years ago
parent
commit
6ebf948a1a
  1. 4
      p2p/transport/testsuite/stream_suite.go
  2. 10
      p2p/transport/testsuite/transport_suite.go

4
p2p/transport/testsuite/stream_suite.go

@ -158,7 +158,7 @@ func goServe(t *testing.T, l transport.Listener) (done func()) {
func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, peerA peer.ID, opt Options) {
msgsize := 1 << 11
errs := make(chan error, 0) // dont block anything.
errs := make(chan error) // dont block anything.
rateLimitN := 5000 // max of 5k funcs, because -race has 8k max.
rateLimitChan := make(chan struct{}, rateLimitN)
@ -211,7 +211,7 @@ func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
s, err := c.OpenStream(context.Background())
if err != nil {
errs <- fmt.Errorf("Failed to create NewStream: %s", err)
errs <- fmt.Errorf("failed to create NewStream: %s", err)
return
}

10
p2p/transport/testsuite/transport_suite.go

@ -8,7 +8,6 @@ import (
"sync"
"testing"
"github.com/libp2p/go-libp2p-core/mux"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport"
@ -17,11 +16,6 @@ import (
var testData = []byte("this is some test data")
type streamAndConn struct {
stream mux.MuxedStream
conn transport.CapableConn
}
func SubtestProtocols(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, peerA peer.ID) {
rawIPAddr, _ := ma.NewMultiaddr("/ip4/1.2.3.4")
if ta.CanDial(rawIPAddr) || tb.CanDial(rawIPAddr) {
@ -271,7 +265,7 @@ func SubtestPingPong(t *testing.T, ta, tb transport.Transport, maddr ma.Multiadd
return
}
if err = s.CloseWrite(); err != nil {
t.Fatal(err)
t.Error(err)
return
}
@ -286,7 +280,7 @@ func SubtestPingPong(t *testing.T, ta, tb transport.Transport, maddr ma.Multiadd
}
if err = s.Close(); err != nil {
t.Fatal(err)
t.Error(err)
return
}
}(i)

Loading…
Cancel
Save