Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov committed Dec 20, 2024
1 parent d9bcc42 commit 28c69a9
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 36 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/golangci_lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Golangci-lint
name: Lint MultiNode

on: [push]

Expand All @@ -19,14 +19,8 @@ jobs:
go-version: '1.19'

- name: Lint multinode
working-directory: ./multinode
uses: smartcontractkit/.github/actions/ci-lint-go@2ac9d97a83a5edded09af7fcf4ea5bce7a4473a4
with:
golangci-lint-version: v1.62.2

- name: Lint evm-chain-bindings
working-directory: ./tools/evm-chain-bindings
uses: smartcontractkit/.github/actions/ci-lint-go@2ac9d97a83a5edded09af7fcf4ea5bce7a4473a4
with:
golangci-lint-version: v1.62.2

run: |
cd ./multinode
golangci-lint run
env:
GOLANGCI_LINT_VERSION: v1.62.2
16 changes: 7 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,27 @@ linters:
enable:
- containedctx
- depguard
- errname
- errorlint
#- errorlint
- exhaustive
- exportloopref
#- exportloopref
- fatcontext
- ginkgolinter
- gocritic
#- gocritic
- goimports
- gosec
#- gosec
- loggercheck
- mirror
- misspell
- noctx
- nolintlint
- perfsprint
- prealloc
#- prealloc
- revive
- rowserrcheck
- spancheck
- sqlclosecheck
- testifylint
#- testifylint
- unconvert
- whitespace
#- whitespace
linters-settings:
exhaustive:
default-signifies-exhaustive: true
Expand Down
2 changes: 1 addition & 1 deletion multinode/node_fsm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (fm *fnMock) AssertNotCalled(t *testing.T) {
}

func (fm *fnMock) AssertCalled(t *testing.T) {
assert.Greater(t, fm.calls, 0)
assert.Positive(t, fm.calls)
}

func TestUnit_Node_StateTransitions(t *testing.T) {
Expand Down
14 changes: 7 additions & 7 deletions multinode/node_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ func TestUnit_NodeLifecycle_start(t *testing.T) {

rpc.On("Dial", mock.Anything).Return(errors.New("failed to dial"))
err := node.Start(tests.Context(t))
assert.NoError(t, err)
require.NoError(t, err)
tests.AssertLogEventually(t, observedLogs, "Dial failed: Node is unreachable")
tests.AssertEventually(t, func() bool {
return node.State() == nodeStateUnreachable
Expand All @@ -1470,7 +1470,7 @@ func TestUnit_NodeLifecycle_start(t *testing.T) {
assert.Equal(t, nodeStateDialed, node.State())
}).Return(nodeChainID, errors.New("failed to get chain id"))
err := node.Start(tests.Context(t))
assert.NoError(t, err)
require.NoError(t, err)
tests.AssertLogEventually(t, observedLogs, "Failed to verify chain ID for node")
tests.AssertEventually(t, func() bool {
return node.State() == nodeStateUnreachable
Expand All @@ -1491,7 +1491,7 @@ func TestUnit_NodeLifecycle_start(t *testing.T) {

rpc.On("ChainID", mock.Anything).Return(rpcChainID, nil)
err := node.Start(tests.Context(t))
assert.NoError(t, err)
require.NoError(t, err)
tests.AssertEventually(t, func() bool {
return node.State() == nodeStateInvalidChainID
})
Expand Down Expand Up @@ -1539,7 +1539,7 @@ func TestUnit_NodeLifecycle_start(t *testing.T) {
rpc.On("ChainID", mock.Anything).Return(nodeChainID, nil)
rpc.On("IsSyncing", mock.Anything).Return(true, nil)
err := node.Start(tests.Context(t))
assert.NoError(t, err)
require.NoError(t, err)
tests.AssertEventually(t, func() bool {
return node.State() == nodeStateSyncing
})
Expand All @@ -1560,7 +1560,7 @@ func TestUnit_NodeLifecycle_start(t *testing.T) {
setupRPCForAliveLoop(t, rpc)

err := node.Start(tests.Context(t))
assert.NoError(t, err)
require.NoError(t, err)
tests.AssertEventually(t, func() bool {
return node.State() == nodeStateAlive
})
Expand Down Expand Up @@ -1591,15 +1591,15 @@ func TestUnit_NodeLifecycle_outOfSyncWithPool(t *testing.T) {
t.Run("skip if nLiveNodes is not configured", func(t *testing.T) {
node := newTestNode(t, testNodeOpts{})
outOfSync, liveNodes := node.isOutOfSyncWithPool()
assert.Equal(t, false, outOfSync)
assert.False(t, outOfSync)
assert.Equal(t, 0, liveNodes)
})
t.Run("skip if syncThreshold is not configured", func(t *testing.T) {
node := newTestNode(t, testNodeOpts{})
poolInfo := newMockPoolChainInfoProvider(t)
node.SetPoolChainInfoProvider(poolInfo)
outOfSync, liveNodes := node.isOutOfSyncWithPool()
assert.Equal(t, false, outOfSync)
assert.False(t, outOfSync)
assert.Equal(t, 0, liveNodes)
})
t.Run("panics on invalid selection mode", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion multinode/node_selector_highest_head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestHighestHeadNodeSelectorName(t *testing.T) {
selector := newNodeSelector[ID, RPCClient[ID, Head]](NodeSelectionModeHighestHead, nil)
assert.Equal(t, selector.Name(), NodeSelectionModeHighestHead)
assert.Equal(t, NodeSelectionModeHighestHead, selector.Name())
}

func TestHighestHeadNodeSelector(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion multinode/node_selector_priority_level_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestPriorityLevelNodeSelectorName(t *testing.T) {
selector := newNodeSelector[ID, RPCClient[ID, Head]](NodeSelectionModePriorityLevel, nil)
assert.Equal(t, selector.Name(), NodeSelectionModePriorityLevel)
assert.Equal(t, NodeSelectionModePriorityLevel, selector.Name())
}

func TestPriorityLevelNodeSelector(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion multinode/node_selector_round_robin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestRoundRobinNodeSelectorName(t *testing.T) {
selector := newNodeSelector[ID, RPCClient[ID, Head]](NodeSelectionModeRoundRobin, nil)
assert.Equal(t, selector.Name(), NodeSelectionModeRoundRobin)
assert.Equal(t, NodeSelectionModeRoundRobin, selector.Name())
}

func TestRoundRobinNodeSelector(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion multinode/node_selector_total_difficulty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestTotalDifficultyNodeSelectorName(t *testing.T) {
selector := newNodeSelector[ID, RPCClient[ID, Head]](NodeSelectionModeTotalDifficulty, nil)
assert.Equal(t, selector.Name(), NodeSelectionModeTotalDifficulty)
assert.Equal(t, NodeSelectionModeTotalDifficulty, selector.Name())
}

func TestTotalDifficultyNodeSelector(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion multinode/poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,6 @@ func Test_Poller_Unsubscribe(t *testing.T) {
require.NoError(t, err)

poller.Unsubscribe()
require.Equal(t, <-channel, nil)
require.Nil(t, <-channel)
})
}
2 changes: 1 addition & 1 deletion multinode/send_only_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestStartSendOnlyNode(t *testing.T) {

defer func() { assert.NoError(t, s.Close()) }()
err := s.Start(tests.Context(t))
assert.NoError(t, err)
require.NoError(t, err)
tests.AssertEventually(t, func() bool {
return s.State() == nodeStateAlive
})
Expand Down
1 change: 0 additions & 1 deletion multinode/transaction_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ func TestTransactionSender_SendTransaction(t *testing.T) {
_, txSender = newTestTransactionSender(t, chainID, logger.Test(t),
[]Node[ID, TestSendTxRPCClient]{fastNode, slowNode},
[]SendOnlyNode[ID, TestSendTxRPCClient]{slowSendOnly})

})
t.Run("Returns error if there is no healthy primary nodes", func(t *testing.T) {
chainID := RandomID()
Expand Down

0 comments on commit 28c69a9

Please sign in to comment.