Skip to content

Commit

Permalink
Tidy, fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed Feb 7, 2025
1 parent c18dd85 commit 4c0f66c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
6 changes: 6 additions & 0 deletions contribs/gnostats/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
rundep := go run -modfile ../../misc/devdeps/go.mod
golangci_lint := $(rundep) github.com/golangci/golangci-lint/cmd/golangci-lint

.PHONY: protoc
protoc:
# Make sure the following prerequisites are installed before running these commands:
# https://grpc.io/docs/languages/go/quickstart/#prerequisites
protoc --proto_path=./ --go_out=./ --go-grpc_out=./ ./proto/*.proto

lint:
$(golangci_lint) --config ../../.github/golangci.yml run ./...
12 changes: 6 additions & 6 deletions contribs/gnostats/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ func (m *mockPushDataClient) SendMsg(msg any) error { panic("sho
func (m *mockPushDataClient) RecvMsg(msg any) error { panic("should never happen") }

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

require.Less(t, min, max)
require.Less(t, minVal, maxVal)

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

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

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

return int(n.Int64()) + min
return int(n.Int64()) + minVal
}

func randomStringOfLength(t *testing.T, length int) string {
Expand All @@ -102,10 +102,10 @@ func randomStringOfLength(t *testing.T, length int) string {
return string(randBytes)
}

func randomStringOfLengthInRange(t *testing.T, min, max int) string {
func randomStringOfLengthInRange(t *testing.T, minVal, maxVal int) string {
t.Helper()

return randomStringOfLength(t, randomIntInRange(t, min, max))
return randomStringOfLength(t, randomIntInRange(t, minVal, maxVal))
}

func randomNodeInfo(t *testing.T) p2pTypes.NodeInfo {
Expand Down
8 changes: 6 additions & 2 deletions contribs/gnostats/agent/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ func TestCollector_DynamicTimeout(t *testing.T) {
mockBatch.On("BlockResults", (*uint64)(nil)).Return(nil)

// Set up a context and a sendLatency that will trigger a timeout
ctx, _ := context.WithTimeout(context.Background(), time.Millisecond)
ctx, cancelFn := context.WithTimeout(context.Background(), time.Millisecond)
defer cancelFn()

mockBatch.sendLatency = time.Second
mockBatch.On("Send", ctx).Return([]any{})

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

// Set up a context and a sendLatency that will trigger a timeout
ctx, _ := context.WithTimeout(context.Background(), time.Millisecond)
ctx, cancelFn := context.WithTimeout(context.Background(), time.Millisecond)
defer cancelFn()

mockBatch.sendLatency = time.Second
mockBatch.On("Send", ctx).Return([]any{})

Expand Down
5 changes: 3 additions & 2 deletions contribs/gnostats/proto/stats.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnostats/proto/stats_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4c0f66c

Please sign in to comment.