From 0be2cd2325fef22b9443adb56297dd3517dbde36 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Mon, 10 Jun 2024 12:38:12 +0300 Subject: [PATCH] fix lint --- simapp/sim_test.go | 1 - store/rootmulti/store.go | 1 - x/bank/app_test.go | 9 +++++++-- x/bank/keeper/send.go | 4 ++-- x/distribution/keeper/grpc_query.go | 1 - x/gov/keeper/tally.go | 1 - x/group/simulation/operations.go | 2 -- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 21aee560f5d4..e8b4762b0f95 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -170,7 +170,6 @@ func TestAppImportExport(t *testing.T) { ctxA := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()}) ctxB := newApp.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()}) _, err = newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState) - if err != nil { if strings.Contains(err.Error(), "validator set is empty after InitGenesis") { logger.Info("Skipping simulation as all validators have been unbonded") diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 94336bc5faa8..5e408f4c3fd5 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -898,7 +898,6 @@ func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error { return nil }() - if err != nil { return err } diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 67746b96f19b..338f2838b9fa 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -7,7 +7,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -36,6 +35,7 @@ import ( govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) type ( @@ -476,7 +476,7 @@ var ( func (h *MockBankHooksReceiver) TrackBeforeSend(ctx context.Context, from, to sdk.AccAddress, amount sdk.Coins) { for _, coin := range amount { if coin.Amount.Equal(sdkmath.NewInt(50)) { - countTrackBeforeSend += 1 + countTrackBeforeSend++ } } } @@ -527,6 +527,7 @@ func TestHooks(t *testing.T) { err = s.BankKeeper.SendCoinsFromAccountToModule(ctx, addr1, stakingtypes.BondedPoolName, invalidBlockSendAmount) require.Error(t, err) err = s.BankKeeper.SendCoinsFromAccountToModule(ctx, addr1, stakingtypes.BondedPoolName, triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -536,6 +537,7 @@ func TestHooks(t *testing.T) { err = s.BankKeeper.SendCoinsFromModuleToAccount(ctx, stakingtypes.BondedPoolName, addr1, invalidBlockSendAmount) require.Error(t, err) err = s.BankKeeper.SendCoinsFromModuleToAccount(ctx, stakingtypes.BondedPoolName, addr1, triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -546,6 +548,7 @@ func TestHooks(t *testing.T) { // there should be no error since module to module does not call block before send hooks require.NoError(t, err) err = s.BankKeeper.SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, stakingtypes.NotBondedPoolName, triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -555,6 +558,7 @@ func TestHooks(t *testing.T) { err = s.BankKeeper.DelegateCoins(ctx, addr1, s.AccountKeeper.GetModuleAddress(stakingtypes.BondedPoolName), invalidBlockSendAmount) require.Error(t, err) err = s.BankKeeper.DelegateCoins(ctx, addr1, s.AccountKeeper.GetModuleAddress(stakingtypes.BondedPoolName), triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -565,6 +569,7 @@ func TestHooks(t *testing.T) { require.Error(t, err) err = s.BankKeeper.UndelegateCoins(ctx, s.AccountKeeper.GetModuleAddress(stakingtypes.BondedPoolName), addr1, triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ } diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 50778b9f3ca4..b0de6cc69e1a 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -216,13 +216,13 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input, } // SendCoinsWithoutBlockHook calls sendCoins without calling the `BlockBeforeSend` hook. -func (k BaseSendKeeper) SendCoinsWithoutBlockHook(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error { +func (k BaseSendKeeper) SendCoinsWithoutBlockHook(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error { return k.sendCoins(ctx, fromAddr, toAddr, amt) } // SendCoins transfers amt coins from a sending account to a receiving account. // An error is returned upon failure. -func (k BaseSendKeeper) SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error { +func (k BaseSendKeeper) SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error { // BlockBeforeSend hook should always be called before the TrackBeforeSend hook. err := k.BlockBeforeSend(ctx, fromAddr, toAddr, amt) if err != nil { diff --git a/x/distribution/keeper/grpc_query.go b/x/distribution/keeper/grpc_query.go index b80ca323f8fc..beb53e58920a 100644 --- a/x/distribution/keeper/grpc_query.go +++ b/x/distribution/keeper/grpc_query.go @@ -331,7 +331,6 @@ func (k Querier) DelegatorValidators(ctx context.Context, req *types.QueryDelega return false }, ) - if err != nil { return nil, err } diff --git a/x/gov/keeper/tally.go b/x/gov/keeper/tally.go index fa69ca381f91..972911d5cadb 100644 --- a/x/gov/keeper/tally.go +++ b/x/gov/keeper/tally.go @@ -91,7 +91,6 @@ func (keeper Keeper) Tally(ctx context.Context, proposal v1.Proposal) (passes, b return false, keeper.Votes.Remove(ctx, collections.Join(vote.ProposalId, sdk.AccAddress(voter))) }) - if err != nil { return false, false, tallyResults, err } diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index fe7d04833c4a..e86f4ec5b7aa 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -958,7 +958,6 @@ func SimulateMsgWithdrawProposal( } _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) - if err != nil { if strings.Contains(err.Error(), "group was modified") || strings.Contains(err.Error(), "group policy was modified") { return simtypes.NoOpMsg(group.ModuleName, sdk.MsgTypeURL(msg), "no-op:group/group-policy was modified"), nil, nil @@ -1066,7 +1065,6 @@ func SimulateMsgVote( } _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) - if err != nil { if strings.Contains(err.Error(), "group was modified") || strings.Contains(err.Error(), "group policy was modified") { return simtypes.NoOpMsg(group.ModuleName, sdk.MsgTypeURL(msg), "no-op:group/group-policy was modified"), nil, nil