Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix linter warnings in v0.14-dev #748

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions internal/consensus/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion internal/consensus/core_chainlock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/consensus/gossip_peer_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
Expand Down
2 changes: 1 addition & 1 deletion internal/consensus/msg_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/consensus/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"},
{
Expand Down Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion internal/consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/consensus/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion internal/consensus/state_add_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions internal/consensus/state_add_vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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
})
Expand Down Expand Up @@ -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
})
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/consensus/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/statesync/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
4 changes: 2 additions & 2 deletions internal/statesync/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
4 changes: 2 additions & 2 deletions internal/statesync/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions internal/statesync/stateprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading