diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index 7766b3a17f..5b555c54d5 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -246,7 +246,7 @@ func startConsensusState(ctx context.Context, cs *State, maxSteps int) { steps++ } }() - go cs.receiveRoutine(ctx, func(state *State) bool { + go cs.receiveRoutine(ctx, func(_state *State) bool { return maxSteps > 0 && steps >= maxSteps }) } @@ -919,9 +919,7 @@ func genFilePV(dir string) (types.PrivValidator, error) { return nil, err } privVal := privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name()) - if err != nil { - return nil, err - } + return privVal, nil } diff --git a/internal/consensus/core_chainlock_test.go b/internal/consensus/core_chainlock_test.go index 227d40bf56..b64d9edc0b 100644 --- a/internal/consensus/core_chainlock_test.go +++ b/internal/consensus/core_chainlock_test.go @@ -97,7 +97,7 @@ func TestReactorInvalidBlockChainLock(t *testing.T) { } func newCounterWithCoreChainLocks(initCoreChainHeight uint32, step int32) func(logger log.Logger, _ string) abci.Application { - return func(logger log.Logger, _ string) abci.Application { + return func(_logger log.Logger, _ string) abci.Application { counterApp := counter.NewApplication(true) counterApp.InitCoreChainLock(initCoreChainHeight, step) return counterApp diff --git a/internal/consensus/gossip_peer_worker_test.go b/internal/consensus/gossip_peer_worker_test.go index 23edd6b80c..dc9a16031a 100644 --- a/internal/consensus/gossip_peer_worker_test.go +++ b/internal/consensus/gossip_peer_worker_test.go @@ -26,10 +26,10 @@ func TestPeerGossipWorker(t *testing.T) { clock: fakeClock, logger: logger, handlers: []gossipHandler{ - newGossipHandler(func(ctx context.Context, appState StateData) { + newGossipHandler(func(_ctx context.Context, _appState StateData) { handlerCalledCh <- struct{}{} }, 1*time.Second), - newGossipHandler(func(ctx context.Context, appState StateData) { + newGossipHandler(func(_ctx context.Context, _appState StateData) { handlerCalledCh <- struct{}{} }, 1*time.Second), }, diff --git a/internal/consensus/msg_handlers.go b/internal/consensus/msg_handlers.go index 8477e812b1..282becf5ef 100644 --- a/internal/consensus/msg_handlers.go +++ b/internal/consensus/msg_handlers.go @@ -73,7 +73,7 @@ func newMsgInfoDispatcher( } func proposalMessageHandler(propSetter cstypes.ProposalSetter) msgHandlerFunc { - return func(ctx context.Context, stateData *StateData, envelope msgEnvelope) error { + return func(_ctx context.Context, stateData *StateData, envelope msgEnvelope) error { msg := envelope.Msg.(*ProposalMessage) return propSetter.Set(msg.Proposal, envelope.ReceiveTime, &stateData.RoundState) } diff --git a/internal/consensus/msgs_test.go b/internal/consensus/msgs_test.go index 85211b2af0..419102e828 100644 --- a/internal/consensus/msgs_test.go +++ b/internal/consensus/msgs_test.go @@ -502,7 +502,7 @@ func TestVoteSetBitsMessageValidateBasic(t *testing.T) { malleateFn func(*VoteSetBitsMessage) expErr string }{ - {func(msg *VoteSetBitsMessage) {}, ""}, + {func(_msg *VoteSetBitsMessage) {}, ""}, {func(msg *VoteSetBitsMessage) { msg.Height = -1 }, "negative Height"}, {func(msg *VoteSetBitsMessage) { msg.Type = 0x03 }, "invalid Type"}, {func(msg *VoteSetBitsMessage) { @@ -616,7 +616,7 @@ func TestNewValidBlockMessageValidateBasic(t *testing.T) { malleateFn func(*NewValidBlockMessage) expErr string }{ - {func(msg *NewValidBlockMessage) {}, ""}, + {func(_msg *NewValidBlockMessage) {}, ""}, {func(msg *NewValidBlockMessage) { msg.Height = -1 }, "negative Height"}, {func(msg *NewValidBlockMessage) { msg.Round = -1 }, "negative Round"}, { @@ -662,7 +662,7 @@ func TestProposalPOLMessageValidateBasic(t *testing.T) { malleateFn func(*ProposalPOLMessage) expErr string }{ - {func(msg *ProposalPOLMessage) {}, ""}, + {func(_msg *ProposalPOLMessage) {}, ""}, {func(msg *ProposalPOLMessage) { msg.Height = -1 }, "negative Height"}, {func(msg *ProposalPOLMessage) { msg.ProposalPOLRound = -1 }, "negative ProposalPOLRound"}, {func(msg *ProposalPOLMessage) { msg.ProposalPOL = bits.NewBitArray(0) }, "empty ProposalPOL bit array"}, diff --git a/internal/consensus/reactor_test.go b/internal/consensus/reactor_test.go index fde234c87a..8d51c51e2f 100644 --- a/internal/consensus/reactor_test.go +++ b/internal/consensus/reactor_test.go @@ -97,7 +97,7 @@ func setup( t.Cleanup(cancel) chCreator := func(nodeID types.NodeID) p2p.ChannelCreator { - return func(ctx context.Context, desc *p2p.ChannelDescriptor) (p2p.Channel, error) { + return func(_ctx context.Context, desc *p2p.ChannelDescriptor) (p2p.Channel, error) { switch desc.ID { case StateChannel: return rts.stateChannels[nodeID], nil diff --git a/internal/consensus/replay_test.go b/internal/consensus/replay_test.go index 517592e04c..ff6efde35f 100644 --- a/internal/consensus/replay_test.go +++ b/internal/consensus/replay_test.go @@ -129,10 +129,10 @@ func TestWALCrash(t *testing.T) { heightToStop int64 }{ {"empty block", - func(stateDB dbm.DB, cs *State, ctx context.Context) {}, + func(_stateDB dbm.DB, _cs *State, _ctx context.Context) {}, 1}, {"many non-empty blocks", - func(stateDB dbm.DB, cs *State, ctx context.Context) { + func(_stateDB dbm.DB, cs *State, ctx context.Context) { go sendTxs(ctx, t, cs) }, 3}, diff --git a/internal/consensus/state_add_vote.go b/internal/consensus/state_add_vote.go index 0644beb518..26fc4c87f1 100644 --- a/internal/consensus/state_add_vote.go +++ b/internal/consensus/state_add_vote.go @@ -86,7 +86,7 @@ func (c *AddVoteAction) Execute(ctx context.Context, stateEvent StateEvent) erro // addVoteToVoteSetFunc adds a vote to the vote-set func addVoteToVoteSetFunc(metrics *Metrics, ep *EventPublisher) AddVoteFunc { - return func(ctx context.Context, stateData *StateData, vote *types.Vote) (bool, error) { + return func(_ctx context.Context, stateData *StateData, vote *types.Vote) (bool, error) { added, err := stateData.Votes.AddVote(vote) if !added || err != nil { return added, err diff --git a/internal/consensus/state_add_vote_test.go b/internal/consensus/state_add_vote_test.go index c1caff2734..2667f1eeba 100644 --- a/internal/consensus/state_add_vote_test.go +++ b/internal/consensus/state_add_vote_test.go @@ -60,11 +60,11 @@ func (suite *AddVoteTestSuite) TestAddVoteAction() { prevoteCalled := false precommitCalled := false cmd := AddVoteAction{ - prevote: func(ctx context.Context, stateData *StateData, vote *types.Vote) (bool, error) { + prevote: func(_ctx context.Context, _stateData *StateData, _vote *types.Vote) (bool, error) { prevoteCalled = true return true, nil }, - precommit: func(ctx context.Context, stateData *StateData, vote *types.Vote) (bool, error) { + precommit: func(_ctx context.Context, _stateData *StateData, _vote *types.Vote) (bool, error) { precommitCalled = true return true, nil }, @@ -105,7 +105,7 @@ func (suite *AddVoteTestSuite) TestAddVoteToVoteSet() { defer cancel() const H100 = int64(100) eventFired := false - suite.emitter.AddListener(types.EventVoteValue, func(data eventemitter.EventData) error { + suite.emitter.AddListener(types.EventVoteValue, func(_data eventemitter.EventData) error { eventFired = true return nil }) @@ -171,7 +171,7 @@ func (suite *AddVoteTestSuite) TestAddVoteUpdateValidBlockMw() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() eventFired := false - suite.emitter.AddListener(types.EventValidBlockValue, func(data eventemitter.EventData) error { + suite.emitter.AddListener(types.EventValidBlockValue, func(_data eventemitter.EventData) error { eventFired = true return nil }) @@ -197,7 +197,7 @@ func (suite *AddVoteTestSuite) TestAddVoteUpdateValidBlockMw() { suite.NoError(err) returnAdded := true var returnError error - mockFn := func(ctx context.Context, stateData *StateData, vote *types.Vote) (bool, error) { + mockFn := func(_ctx context.Context, _stateData *StateData, _vote *types.Vote) (bool, error) { return returnAdded, returnError } fn := addVoteUpdateValidBlockMw(suite.publisher)(mockFn) diff --git a/internal/consensus/state_test.go b/internal/consensus/state_test.go index 8a5e5a5e9d..e6420a1b30 100644 --- a/internal/consensus/state_test.go +++ b/internal/consensus/state_test.go @@ -303,7 +303,7 @@ func TestStateProposalTime(t *testing.T) { expectNewBlock: false, }, { // TEST 1: BLOCK TIME IS IN FUTURE - blockTimeFunc: func(s *State) time.Time { return tmtime.Now().Add(delay + precision + 24*time.Hour) }, + blockTimeFunc: func(_s *State) time.Time { return tmtime.Now().Add(delay + precision + 24*time.Hour) }, expectNewBlock: true, }, { // TEST 2: BLOCK TIME IS OLDER THAN PREVIOUS BLOCK TIME diff --git a/internal/statesync/peer.go b/internal/statesync/peer.go index bc53201de1..589acecacc 100644 --- a/internal/statesync/peer.go +++ b/internal/statesync/peer.go @@ -136,7 +136,7 @@ func (p *PeerManager) Start(ctx context.Context) { } return nil }) - p.peerSubs.On(p2p.PeerStatusDown, func(ctx context.Context, update p2p.PeerUpdate) error { + p.peerSubs.On(p2p.PeerStatusDown, func(_ctx context.Context, update p2p.PeerUpdate) error { p.peerStore.Delete(update.NodeID) return nil }) diff --git a/internal/statesync/peer_test.go b/internal/statesync/peer_test.go index 7b32e9f728..61547e1d63 100644 --- a/internal/statesync/peer_test.go +++ b/internal/statesync/peer_test.go @@ -26,11 +26,11 @@ func TestPeerSubscriberBasic(_t *testing.T) { } peerSub := NewPeerSubscriber(log.NewNopLogger(), p2pSub) outCh := make(chan struct{}) - peerSub.On(p2p.PeerStatusUp, func(ctx context.Context, update p2p.PeerUpdate) error { + peerSub.On(p2p.PeerStatusUp, func(_ctx context.Context, _update p2p.PeerUpdate) error { outCh <- struct{}{} return nil }) - peerSub.On(p2p.PeerStatusDown, func(ctx context.Context, update p2p.PeerUpdate) error { + peerSub.On(p2p.PeerStatusDown, func(_ctx context.Context, _update p2p.PeerUpdate) error { outCh <- struct{}{} return nil }) diff --git a/internal/statesync/reactor_test.go b/internal/statesync/reactor_test.go index ecfa88fa27..dfe523af66 100644 --- a/internal/statesync/reactor_test.go +++ b/internal/statesync/reactor_test.go @@ -154,7 +154,7 @@ func setup( rts.privVal = types.NewMockPV() rts.dashcoreClient = dashcore.NewMockClient(chainID, llmqType, rts.privVal, false) - chCreator := func(ctx context.Context, desc *p2p.ChannelDescriptor) (p2p.Channel, error) { + chCreator := func(_ctx context.Context, desc *p2p.ChannelDescriptor) (p2p.Channel, error) { switch desc.ID { case SnapshotChannel: return rts.snapshotChannel, nil @@ -716,7 +716,7 @@ func TestReactor_Backfill(t *testing.T) { mock.AnythingOfType("int64"), mock.AnythingOfType("*types.ValidatorSet")). Maybe(). - Return(func(lh, uh int64, vals *types.ValidatorSet) error { + Return(func(lh, uh int64, _vals *types.ValidatorSet) error { require.Equal(t, trackingHeight, lh) require.Equal(t, lh, uh) require.GreaterOrEqual(t, lh, stopHeight) diff --git a/internal/statesync/stateprovider.go b/internal/statesync/stateprovider.go index 2d98e82c51..f30688c735 100644 --- a/internal/statesync/stateprovider.go +++ b/internal/statesync/stateprovider.go @@ -246,9 +246,6 @@ func (s *stateProviderP2P) AppHash(ctx context.Context, height uint64) (tmbytes. if err != nil { return nil, err } - if err != nil { - return nil, err - } return header.AppHash, nil } diff --git a/test/e2e/tests/validator_test.go b/test/e2e/tests/validator_test.go index 23c4c2c3da..332f3e5a31 100644 --- a/test/e2e/tests/validator_test.go +++ b/test/e2e/tests/validator_test.go @@ -88,7 +88,7 @@ func TestValidator_Propose(t *testing.T) { defer cancel() blocks := fetchBlockChain(ctx, t) - testNode(t, func(ctx context.Context, t *testing.T, node e2e.Node) { + testNode(t, func(_ctx context.Context, t *testing.T, node e2e.Node) { if node.Mode != e2e.ModeValidator { return }