Skip to content

Commit 4c0f66c

Browse files
committed
Tidy, fmt
1 parent c18dd85 commit 4c0f66c

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

contribs/gnostats/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
rundep := go run -modfile ../../misc/devdeps/go.mod
2+
golangci_lint := $(rundep) github.com/golangci/golangci-lint/cmd/golangci-lint
3+
14
.PHONY: protoc
25
protoc:
36
# Make sure the following prerequisites are installed before running these commands:
47
# https://grpc.io/docs/languages/go/quickstart/#prerequisites
58
protoc --proto_path=./ --go_out=./ --go-grpc_out=./ ./proto/*.proto
9+
10+
lint:
11+
$(golangci_lint) --config ../../.github/golangci.yml run ./...

contribs/gnostats/agent/agent_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ func (m *mockPushDataClient) SendMsg(msg any) error { panic("sho
7171
func (m *mockPushDataClient) RecvMsg(msg any) error { panic("should never happen") }
7272

7373
// Helpers that generate random string and int
74-
func randomIntInRange(t *testing.T, min, max int) int {
74+
func randomIntInRange(t *testing.T, minVal, maxVal int) int {
7575
t.Helper()
7676

77-
require.Less(t, min, max)
77+
require.Less(t, minVal, maxVal)
7878

79-
diff := int64(max - min + 1)
79+
diff := int64(maxVal - minVal + 1)
8080

8181
require.Greater(t, diff, int64(0))
8282

8383
n, err := rand.Int(rand.Reader, big.NewInt(diff))
8484
require.NoError(t, err)
8585

86-
return int(n.Int64()) + min
86+
return int(n.Int64()) + minVal
8787
}
8888

8989
func randomStringOfLength(t *testing.T, length int) string {
@@ -102,10 +102,10 @@ func randomStringOfLength(t *testing.T, length int) string {
102102
return string(randBytes)
103103
}
104104

105-
func randomStringOfLengthInRange(t *testing.T, min, max int) string {
105+
func randomStringOfLengthInRange(t *testing.T, minVal, maxVal int) string {
106106
t.Helper()
107107

108-
return randomStringOfLength(t, randomIntInRange(t, min, max))
108+
return randomStringOfLength(t, randomIntInRange(t, minVal, maxVal))
109109
}
110110

111111
func randomNodeInfo(t *testing.T) p2pTypes.NodeInfo {

contribs/gnostats/agent/collector_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ func TestCollector_DynamicTimeout(t *testing.T) {
262262
mockBatch.On("BlockResults", (*uint64)(nil)).Return(nil)
263263

264264
// Set up a context and a sendLatency that will trigger a timeout
265-
ctx, _ := context.WithTimeout(context.Background(), time.Millisecond)
265+
ctx, cancelFn := context.WithTimeout(context.Background(), time.Millisecond)
266+
defer cancelFn()
267+
266268
mockBatch.sendLatency = time.Second
267269
mockBatch.On("Send", ctx).Return([]any{})
268270

@@ -340,7 +342,9 @@ func TestCollector_StaticTimeout(t *testing.T) {
340342
mockBatch.On("Status").Return(nil)
341343

342344
// Set up a context and a sendLatency that will trigger a timeout
343-
ctx, _ := context.WithTimeout(context.Background(), time.Millisecond)
345+
ctx, cancelFn := context.WithTimeout(context.Background(), time.Millisecond)
346+
defer cancelFn()
347+
344348
mockBatch.sendLatency = time.Second
345349
mockBatch.On("Send", ctx).Return([]any{})
346350

contribs/gnostats/proto/stats.pb.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contribs/gnostats/proto/stats_grpc.pb.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)