Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EasterTheBunny committed Dec 24, 2024
1 parent 30b67db commit 5f187da
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ run:
linters:
enable:
- exhaustive
- exportloopref
- copyloopvar
- revive
- goimports
- gosec
Expand Down
9 changes: 5 additions & 4 deletions pkg/solana/config_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ func (c *ConfigTracker) LatestConfigDetails(ctx context.Context) (changedInBlock
func ConfigFromState(ctx context.Context, state State) (types.ContractConfig, error) {
pubKeys := []types.OnchainPublicKey{}
accounts := []types.Account{}

oracles, err := state.Oracles.Data()
if err != nil {
return types.ContractConfig{}, err
}
for _, o := range oracles {
o := o // https://github.com/golang/go/wiki/CommonMistakes#using-reference-to-loop-iterator-variable
pubKeys = append(pubKeys, o.Signer.Key[:])
accounts = append(accounts, types.Account(o.Transmitter.String()))

for idx := range oracles {
pubKeys = append(pubKeys, oracles[idx].Signer.Key[:])
accounts = append(accounts, types.Account(oracles[idx].Transmitter.String()))
}

onchainConfigStruct := median.OnchainConfig{
Expand Down
4 changes: 1 addition & 3 deletions pkg/solana/logpoller/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ func (v *pgDSLParser) Timestamp(prim primitives.Timestamp) {
return
}

var tm int64
tm := int64(prim.Timestamp) //nolint:gosec // disable G115
if prim.Timestamp > math.MaxInt64 {
tm = 0
} else {
tm = int64(prim.Timestamp)
}

v.expression = fmt.Sprintf(
Expand Down
13 changes: 6 additions & 7 deletions pkg/solana/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,11 @@ func TestMedianFromReport(t *testing.T) {
tt = append(tt, test)
}

for _, tc := range tt {
tc := tc
t.Run(tc.name, func(t *testing.T) {
for idx := range tt {
t.Run(tt[idx].name, func(t *testing.T) {
ctx := tests.Context(t)
var pos []median.ParsedAttributedObservation
for i, obs := range tc.obs {
for i, obs := range tt[idx].obs {
pos = append(pos, median.ParsedAttributedObservation{
Value: obs,
JuelsPerFeeCoin: obs,
Expand All @@ -156,15 +155,15 @@ func TestMedianFromReport(t *testing.T) {
}
report, err := cdc.BuildReport(ctx, pos)
require.NoError(t, err)
max, err := cdc.MaxReportLength(ctx, len(tc.obs))
max, err := cdc.MaxReportLength(ctx, len(tt[idx].obs))
require.NoError(t, err)
assert.Equal(t, len(report), max)
med, err := cdc.MedianFromReport(ctx, report)
require.NoError(t, err)
assert.Equal(t, tc.expectedMedian.String(), med.String())
assert.Equal(t, tt[idx].expectedMedian.String(), med.String())
count, err := cdc.ObserversCountFromReport(report)
require.NoError(t, err)
assert.Equal(t, len(tc.obs), int(count))
assert.Equal(t, len(tt[idx].obs), int(count))
})
}
}
Expand Down
11 changes: 5 additions & 6 deletions pkg/solana/txm/pendingtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,17 +1303,16 @@ func TestPendingTxContext_ListAllExpiredBroadcastedTxs(t *testing.T) {
},
}

for _, tt := range tests {
tt := tt // capture range variable
t.Run(tt.name, func(t *testing.T) {
for idx := range tests {
t.Run(tests[idx].name, func(t *testing.T) {
// Initialize a new PendingTxContext
ctx := newPendingTxContext()

// Setup the test case
tt.setup(t, ctx)
tests[idx].setup(t, ctx)

// Execute the function under test
result := ctx.ListAllExpiredBroadcastedTxs(tt.currBlockHeight)
result := ctx.ListAllExpiredBroadcastedTxs(tests[idx].currBlockHeight)

// Extract the IDs from the result
var resultIDs []string
Expand All @@ -1322,7 +1321,7 @@ func TestPendingTxContext_ListAllExpiredBroadcastedTxs(t *testing.T) {
}

// Assert that the expected IDs match the result IDs (order does not matter)
assert.ElementsMatch(t, tt.expectedTxIDs, resultIDs)
assert.ElementsMatch(t, tests[idx].expectedTxIDs, resultIDs)
})
}
}

0 comments on commit 5f187da

Please sign in to comment.