Skip to content

Commit d9fd4a1

Browse files
committed
chore: fix golangci-lint errors
1 parent b8c7641 commit d9fd4a1

File tree

9 files changed

+11
-15
lines changed

9 files changed

+11
-15
lines changed

core/record/envelope_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func TestEnvelopeHappyPath(t *testing.T) {
9191

9292
func TestConsumeTypedEnvelope(t *testing.T) {
9393
var (
94-
rec = simpleRecord{message: "hello world!"}
95-
priv, _, err = test.RandTestKeyPair(crypto.Ed25519, 256)
94+
rec = simpleRecord{message: "hello world!"}
95+
priv, _, _ = test.RandTestKeyPair(crypto.Ed25519, 256)
9696
)
9797

9898
envelope, err := Seal(&rec, priv)

p2p/discovery/backoff/backoff_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ func TestFixedBackoff(t *testing.T) {
2121
delay := startDelay
2222

2323
bkf := NewFixedBackoff(delay)
24-
delay *= 2
2524
b1 := bkf()
26-
delay *= 2
2725
b2 := bkf()
2826

2927
if b1.Delay() != startDelay || b2.Delay() != startDelay {

p2p/host/autonat/autonat.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ func (as *AmbientAutoNAT) scheduleProbe(forceProbe bool) time.Duration {
270270
// retry very quicky if forceProbe is true *and* we don't know our reachability
271271
// limit all peers fetch from peerstore to 1 per second.
272272
nextProbeAfter = 2 * time.Second
273-
nextProbeAfter = 2 * time.Second
274273
case currentStatus == network.ReachabilityUnknown,
275274
as.confidence < maxConfidence,
276275
currentStatus != network.ReachabilityPublic && receivedInbound:

p2p/http/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func ExampleHost_overLibp2pStreams() {
181181
// Make an HTTP request using the Go standard library, but over libp2p
182182
// streams. If the server were listening on an HTTP transport, this could
183183
// also make the request over the HTTP transport.
184-
httpClient, err := client.NamespacedClient("/echo/1.0.0", peer.AddrInfo{ID: server.PeerID(), Addrs: server.Addrs()})
184+
httpClient, _ := client.NamespacedClient("/echo/1.0.0", peer.AddrInfo{ID: server.PeerID(), Addrs: server.Addrs()})
185185

186186
// Only need to Post to "/" because this client is namespaced to the "/echo/1.0.0" protocol.
187187
resp, err := httpClient.Post("/", "application/octet-stream", strings.NewReader("Hello HTTP"))

p2p/net/connmgr/connmgr_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ func TestPeerProtectionSingleTag(t *testing.T) {
531531
}
532532

533533
// protect the first 5 peers.
534-
var protected []network.Conn
534+
protected := make([]network.Conn, 0, 5)
535535
for _, c := range conns[0:5] {
536536
cm.Protect(c.RemotePeer(), "global")
537537
protected = append(protected, c)
@@ -610,7 +610,7 @@ func TestPeerProtectionMultipleTags(t *testing.T) {
610610
}
611611

612612
// protect the first 5 peers under two tags.
613-
var protected []network.Conn
613+
protected := make([]network.Conn, 0, 5)
614614
for _, c := range conns[0:5] {
615615
cm.Protect(c.RemotePeer(), "tag1")
616616
cm.Protect(c.RemotePeer(), "tag2")

p2p/net/nat/internal/nat/nat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (e ErrNoNATFound) Unwrap() []error {
2929
}
3030

3131
func (e ErrNoNATFound) Error() string {
32-
var errStrs []string
32+
errStrs := make([]string, 0, len(e.Errs))
3333
for _, err := range e.Errs {
3434
errStrs = append(errStrs, err.Error())
3535
}

p2p/net/swarm/black_hole_detector_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import (
1111
func TestBlackHoleSuccessCounterReset(t *testing.T) {
1212
n := 10
1313
bhf := &BlackHoleSuccessCounter{N: n, MinSuccesses: 2, Name: "test"}
14-
var i = 0
1514
// calls up to n should be probing
16-
for i = 1; i <= n; i++ {
15+
for i := 1; i <= n; i++ {
1716
if bhf.HandleRequest() != blackHoleStateProbing {
1817
t.Fatalf("expected calls up to n to be probes")
1918
}
@@ -24,7 +23,7 @@ func TestBlackHoleSuccessCounterReset(t *testing.T) {
2423
}
2524

2625
// after threshold calls every nth call should be a probe
27-
for i = n + 1; i < 42; i++ {
26+
for i := n + 1; i < 42; i++ {
2827
result := bhf.HandleRequest()
2928
if (i%n == 0 && result != blackHoleStateProbing) || (i%n != 0 && result != blackHoleStateBlocked) {
3029
t.Fatalf("expected every nth dial to be a probe")
@@ -36,7 +35,7 @@ func TestBlackHoleSuccessCounterReset(t *testing.T) {
3635

3736
bhf.RecordResult(true)
3837
// check if calls up to n are probes again
39-
for i = 0; i < n; i++ {
38+
for i := 0; i < n; i++ {
4039
if bhf.HandleRequest() != blackHoleStateProbing {
4140
t.Fatalf("expected black hole detector state to reset after success")
4241
}

p2p/protocol/circuitv2/relay/relay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ func makeReservationMsg(
591591
return rsvp
592592
}
593593

594-
var addrBytes [][]byte
594+
addrBytes := make([][]byte, 0, len(selfAddrs))
595595
for _, addr := range selfAddrs {
596596
if !manet.IsPublicAddr(addr) {
597597
continue

p2p/protocol/circuitv2/relay/relay_priv_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestMakeReservationWithP2PAddrs(t *testing.T) {
4242
"/ip4/1.2.3.4/tcp/1235/p2p/" + selfID.String(),
4343
}
4444

45-
var addrsFromRsvp []string
45+
addrsFromRsvp := make([]string, 0, len(rsvp.GetAddrs()))
4646
for _, addr := range rsvp.GetAddrs() {
4747
a, err := ma.NewMultiaddrBytes(addr)
4848
require.NoError(t, err)

0 commit comments

Comments
 (0)