From 9be83fa5323655fc14dc1be6a14cc2da23c2f1ed Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Sat, 16 Sep 2023 00:33:11 +0800 Subject: [PATCH] finish linting (#568) --- .golangci.yml | 19 ++++++---- app/upgrades/upgrades.go | 26 +++++++------- app/upgrades_test.go | 10 ++++-- cmd/quicksilverd/bulk_airdrop.go | 10 ++++-- test/simulation/config.go | 2 +- test/simulation/sim_test.go | 2 +- wasmbinding/query_plugin_test.go | 4 +-- wasmbinding/test/store_run_test.go | 3 +- x/airdrop/types/msgs.go | 2 -- x/interchainstaking/client/cli/cli_test.go | 12 +++---- x/interchainstaking/keeper/callbacks_test.go | 20 ++++++++--- .../keeper/ibc_packet_handlers.go | 2 +- .../keeper/ibc_packet_handlers_test.go | 36 +++++++++++++------ x/interchainstaking/keeper/redemptions.go | 7 ++-- x/interchainstaking/keeper/validator_test.go | 3 +- .../keeper/withdrawal_record.go | 2 +- x/interchainstaking/keeper/zones_test.go | 4 +-- x/interchainstaking/types/accounts_test.go | 4 +-- x/mint/simulation/genesis.go | 2 +- x/participationrewards/keeper/keeper_test.go | 3 +- .../keeper/protocol_data.go | 4 +-- .../keeper/rewards_holdings_test.go | 3 +- .../keeper/rewards_validatorSelection_test.go | 4 +-- x/tokenfactory/keeper/admins_test.go | 1 + 24 files changed, 116 insertions(+), 69 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9ba160b5e..ec672f2d8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,6 +2,8 @@ run: tests: true # # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 5m + skip-dirs: + - third-party-chains linters: disable-all: true @@ -26,8 +28,7 @@ linters: - typecheck - tenv - unconvert - # Prefer unparam over revive's unused param. It is more thorough in its checking. - - unparam + - unparam # Prefer unparam over revive's unused param. It is more thorough in its checking. - unused - misspell @@ -91,6 +92,8 @@ linters-settings: disabled: true - name: empty-lines disabled: true + - name: unused-receiver # remove later + disabled: true - name: banned-characters disabled: true - name: deep-exit @@ -107,12 +110,16 @@ linters-settings: disabled: true - name: defer disabled: true - # Disabled in favour of unparam. - - name: unused-parameter + - name: unused-parameter # Disabled in favour of unparam. + disabled: true + - name: unhandled-error # enable later, currently covered by errcheck disabled: true - - name: unhandled-error - disabled: false arguments: + - 'b.WriteString' + - 'respJSON.Write' - 'fmt.Printf' - 'fmt.Print' - 'fmt.Println' + - 'fmt.Fprintf' + + diff --git a/app/upgrades/upgrades.go b/app/upgrades/upgrades.go index 2336bc6e9..45bdba5b2 100644 --- a/app/upgrades/upgrades.go +++ b/app/upgrades/upgrades.go @@ -363,21 +363,21 @@ func V010404beta7UpgradeHandler( ) appKeepers.InterchainstakingKeeper.IterateRedelegationRecords(ctx, func(idx int64, key []byte, redelegation icstypes.RedelegationRecord) (stop bool) { - var UnbondingPeriod int64 + var unbondingPeriod int64 switch redelegation.ChainId { case "theta-testnet-001": - UnbondingPeriod = thetaUnbondingPeriod + unbondingPeriod = thetaUnbondingPeriod case "uni-6": - UnbondingPeriod = uniUnbondingPeriod + unbondingPeriod = uniUnbondingPeriod case "osmo-test-5": - UnbondingPeriod = osmoUnbondingPeriod + unbondingPeriod = osmoUnbondingPeriod case "regen-redwood-1": - UnbondingPeriod = regenUnbondingPeriod + unbondingPeriod = regenUnbondingPeriod } epochInfo := appKeepers.EpochsKeeper.GetEpochInfo(ctx, epochtypes.EpochIdentifierEpoch) - if UnbondingPeriod < (epochInfo.CurrentEpoch-redelegation.EpochNumber)*epochDurations { + if unbondingPeriod < (epochInfo.CurrentEpoch-redelegation.EpochNumber)*epochDurations { appKeepers.InterchainstakingKeeper.Logger(ctx).Info("garbage collecting completed redelegations", "key", key, "completion", redelegation.CompletionTime) appKeepers.InterchainstakingKeeper.DeleteRedelegationRecordByKey(ctx, append(icstypes.KeyPrefixRedelegationRecord, key...)) } @@ -404,21 +404,21 @@ func V010404rc0UpgradeHandler( ) appKeepers.InterchainstakingKeeper.IterateRedelegationRecords(ctx, func(idx int64, key []byte, redelegation icstypes.RedelegationRecord) (stop bool) { - var UnbondingPeriod int64 + var unbondingPeriod int64 switch redelegation.ChainId { case "theta-testnet-001": - UnbondingPeriod = thetaUnbondingPeriod + unbondingPeriod = thetaUnbondingPeriod case "uni-6": - UnbondingPeriod = uniUnbondingPeriod + unbondingPeriod = uniUnbondingPeriod case "osmo-test-5": - UnbondingPeriod = osmoUnbondingPeriod + unbondingPeriod = osmoUnbondingPeriod case "regen-redwood-1": - UnbondingPeriod = regenUnbondingPeriod + unbondingPeriod = regenUnbondingPeriod } epochInfo := appKeepers.EpochsKeeper.GetEpochInfo(ctx, epochtypes.EpochIdentifierEpoch) - if UnbondingPeriod < (epochInfo.CurrentEpoch-redelegation.EpochNumber)*epochDurations { + if unbondingPeriod < (epochInfo.CurrentEpoch-redelegation.EpochNumber)*epochDurations { appKeepers.InterchainstakingKeeper.Logger(ctx).Info("garbage collecting completed redelegations", "key", key, "completion", redelegation.CompletionTime) appKeepers.InterchainstakingKeeper.DeleteRedelegationRecordByKey(ctx, append(icstypes.KeyPrefixRedelegationRecord, key...)) } @@ -685,7 +685,7 @@ func V010404beta10UpgradeHandler( // } // return mm.RunMigrations(ctx, configurator, fromVM) // } -//} +// } // // func V010400rc6UpgradeHandler( // mm *module.Manager, diff --git a/app/upgrades_test.go b/app/upgrades_test.go index b176254a7..5a2df2f6b 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -314,13 +314,17 @@ func (s *AppTestSuite) TestV010402rc3UpgradeHandler() { app.ParticipationRewardsKeeper.SetProtocolData(ctx, prtypes.GetProtocolDataKey(prtypes.ProtocolDataType(pdType), []byte("rege-redwood-1")), &prData) val0 := icstypes.Validator{ValoperAddress: "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - app.InterchainstakingKeeper.SetValidator(ctx, upgrades.OsmosisTestnetChainID, val0) + err := app.InterchainstakingKeeper.SetValidator(ctx, upgrades.OsmosisTestnetChainID, val0) + s.Require().NoError(err) + val1 := icstypes.Validator{ValoperAddress: "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - app.InterchainstakingKeeper.SetValidator(ctx, upgrades.OsmosisTestnetChainID, val1) + err = app.InterchainstakingKeeper.SetValidator(ctx, upgrades.OsmosisTestnetChainID, val1) + s.Require().NoError(err) + vals := app.InterchainstakingKeeper.GetValidators(ctx, upgrades.OsmosisTestnetChainID) s.Require().Equal(2, len(vals)) - _, err := handler(ctx, types.Plan{}, app.mm.GetVersionMap()) + _, err = handler(ctx, types.Plan{}, app.mm.GetVersionMap()) s.Require().NoError(err) _, found := app.InterchainstakingKeeper.GetZone(ctx, upgrades.OsmosisTestnetChainID) diff --git a/cmd/quicksilverd/bulk_airdrop.go b/cmd/quicksilverd/bulk_airdrop.go index 7359d26ef..2b9cc8794 100644 --- a/cmd/quicksilverd/bulk_airdrop.go +++ b/cmd/quicksilverd/bulk_airdrop.go @@ -185,14 +185,18 @@ func BulkGenesisAirdropCmd(defaultNodeHome string) *cobra.Command { var zoneDrop *types.ZoneDrop // assert zonedrop exists + if len(claimRecords) == 0 { + return fmt.Errorf("claimRecords is empty") + } + for _, zd := range airdropGenState.ZoneDrops { - if zd.ChainId == claimRecords[0].ChainId { + if zd.ChainId == claimRecords[0].ChainId { //nolint:gosec zoneDrop = zd } } if zoneDrop == nil { - return fmt.Errorf("zoneDrop doesn't exist for chain ID: %s", claimRecords[0].ChainId) + return fmt.Errorf("zoneDrop doesn't exist for chain ID: %s", claimRecords[0].ChainId) //nolint:gosec // TODO: remove } authGenState := authtypes.GetGenesisStateFromAppState(clientCtx.Codec, appState) @@ -207,7 +211,7 @@ func BulkGenesisAirdropCmd(defaultNodeHome string) *cobra.Command { existing := airdropGenState.ClaimRecords for _, i := range existing { - if i.ChainId == claimRecords[0].ChainId { + if i.ChainId == claimRecords[0].ChainId { //nolint:gosec // TODO: remove zoneclaims[i.Address] = true } } diff --git a/test/simulation/config.go b/test/simulation/config.go index 6128aa1b6..739716289 100644 --- a/test/simulation/config.go +++ b/test/simulation/config.go @@ -31,7 +31,7 @@ var ( ) // GetSimulatorFlags gets the values of all the available simulation flags. -func GetSimulatorFlags() { +func SimulatorFlags() { // config fields flag.StringVar(&FlagGenesisFileValue, "Genesis", "", "custom simulation genesis file; cannot be used with params file") flag.StringVar(&FlagParamsFileValue, "Params", "", "custom simulation params file which overrides any random params; cannot be used with genesis") diff --git a/test/simulation/sim_test.go b/test/simulation/sim_test.go index b11fba5a1..e3f994ad3 100644 --- a/test/simulation/sim_test.go +++ b/test/simulation/sim_test.go @@ -22,7 +22,7 @@ import ( ) func init() { - simulation.GetSimulatorFlags() + simulation.SimulatorFlags() } // interBlockCacheOpt returns a BaseApp option function that sets the persistent diff --git a/wasmbinding/query_plugin_test.go b/wasmbinding/query_plugin_test.go index 6c15409be..d70c6275e 100644 --- a/wasmbinding/query_plugin_test.go +++ b/wasmbinding/query_plugin_test.go @@ -227,7 +227,7 @@ func (s *StargateTestSuite) TestDeterministicJsonMarshal() { responseProtoStruct interface{} expectedProto func() proto.Message }{ - /** + /* * Origin Response * balances: pagination: * New Version Response @@ -274,7 +274,7 @@ func (s *StargateTestSuite) TestDeterministicJsonMarshal() { } }, }, - /** + /* // Origin proto message QueryAccountResponse { // account defines the account of the corresponding address. diff --git a/wasmbinding/test/store_run_test.go b/wasmbinding/test/store_run_test.go index 57bd47071..1106e50c0 100644 --- a/wasmbinding/test/store_run_test.go +++ b/wasmbinding/test/store_run_test.go @@ -90,7 +90,8 @@ func TestInstantiateContract(t *testing.T) { quicksilverApp, ctx := CreateTestInput(t) funder := RandomAccountAddress() benefit, arb := RandomAccountAddress(), RandomAccountAddress() - FundAccount(quicksilverApp.BankKeeper, ctx, funder, sdk.NewCoins(coin)) + err := FundAccount(quicksilverApp.BankKeeper, ctx, funder, sdk.NewCoins(coin)) + require.NoError(t, err) storeCodeViaProposal(t, ctx, quicksilverApp, funder) contractKeeper := keeper.NewDefaultPermissionKeeper(quicksilverApp.WasmKeeper) diff --git a/x/airdrop/types/msgs.go b/x/airdrop/types/msgs.go index 404692960..795057229 100644 --- a/x/airdrop/types/msgs.go +++ b/x/airdrop/types/msgs.go @@ -89,8 +89,6 @@ func (msg MsgClaim) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{address} } -////////////////////////////////////////////////////////////////////////////////////////////////////// - // NewMsgIncentivePoolSpend constructs a msg to claim from a zone airdrop. func NewMsgIncentivePoolSpend(authority, toAddress sdk.Address, amt sdk.Coins) *MsgIncentivePoolSpend { return &MsgIncentivePoolSpend{ diff --git a/x/interchainstaking/client/cli/cli_test.go b/x/interchainstaking/client/cli/cli_test.go index 26267e49f..230f4391a 100644 --- a/x/interchainstaking/client/cli/cli_test.go +++ b/x/interchainstaking/client/cli/cli_test.go @@ -201,13 +201,13 @@ func (s *IntegrationTestSuite) TestGetDelegatorIntentCmd() { &types.QueryDelegatorIntentResponse{}, &types.QueryDelegatorIntentResponse{}, }, - /*{ + /* { "valid", []string{s.cfg.ChainID, ""}, false, &types.QueryDelegatorIntentResponse{}, &types.QueryDelegatorIntentResponse{}, - },*/ + }, */ } for _, tt := range tests { tt := tt @@ -266,13 +266,13 @@ func (s *IntegrationTestSuite) TestGetDepositAccountCmd() { &types.QueryDepositAccountForChainResponse{}, &types.QueryDepositAccountForChainResponse{}, }, - /*{ + /* { "valid", []string{s.cfg.ChainID}, false, &types.QueryDepositAccountForChainResponse{}, &types.QueryDepositAccountForChainResponse{}, - },*/ + }, */ } for _, tt := range tests { tt := tt @@ -378,7 +378,7 @@ func (s *IntegrationTestSuite) TestGetSignalIntentTxCmd() { 0, &sdk.TxResponse{}, }, - /*{ + /* { "valid", []string{ s.network.Config.ChainID, @@ -388,7 +388,7 @@ func (s *IntegrationTestSuite) TestGetSignalIntentTxCmd() { false, 0, &sdk.TxResponse{}, - },*/ + }, */ } for _, tt := range tests { tt := tt diff --git a/x/interchainstaking/keeper/callbacks_test.go b/x/interchainstaking/keeper/callbacks_test.go index 6c04cfd8d..b8c15fe1a 100644 --- a/x/interchainstaking/keeper/callbacks_test.go +++ b/x/interchainstaking/keeper/callbacks_test.go @@ -348,11 +348,20 @@ func (suite *KeeperTestSuite) TestHandleValidatorCallbackNilValue() { func (suite *KeeperTestSuite) TestHandleValidatorCallback() { newVal := addressutils.GenerateAddressForTestWithPrefix("cosmosvaloper") zone := icstypes.Zone{ConnectionId: "connection-0", ChainId: "cosmoshub-4", AccountPrefix: "cosmos", LocalDenom: "uqatom", BaseDenom: "uatom", Is_118: true} - suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1a3yjj7d3qnx4spgvjcwjq9cw9snrrrhu5h6jll", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) - suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1z8zjv3lntpwxua0rtpvgrcwl0nm0tltgpgs6l7", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + err := suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) + + err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) + + err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) + + err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1a3yjj7d3qnx4spgvjcwjq9cw9snrrrhu5h6jll", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) + + err = suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zone.ChainId, icstypes.Validator{ValoperAddress: "cosmosvaloper1z8zjv3lntpwxua0rtpvgrcwl0nm0tltgpgs6l7", CommissionRate: sdk.MustNewDecFromStr("0.2"), VotingPower: sdk.NewInt(2000), DelegatorShares: sdk.NewDec(2000)}) + suite.NoError(err) tests := []struct { name string @@ -383,6 +392,7 @@ func (suite *KeeperTestSuite) TestHandleValidatorCallback() { for _, test := range tests { suite.Run(test.name, func() { + test := test suite.SetupTest() suite.setupTestZones() diff --git a/x/interchainstaking/keeper/ibc_packet_handlers.go b/x/interchainstaking/keeper/ibc_packet_handlers.go index 9334db68c..106facb68 100644 --- a/x/interchainstaking/keeper/ibc_packet_handlers.go +++ b/x/interchainstaking/keeper/ibc_packet_handlers.go @@ -297,7 +297,7 @@ func (*Keeper) HandleTimeout(_ sdk.Context, _ channeltypes.Packet) error { return nil } -//---------------------------------------------------------------- +// ---------------------------------------------------------------- func (k *Keeper) HandleMsgTransfer(ctx sdk.Context, msg sdk.Msg) error { k.Logger(ctx).Info("Received MsgTransfer acknowledgement") diff --git a/x/interchainstaking/keeper/ibc_packet_handlers_test.go b/x/interchainstaking/keeper/ibc_packet_handlers_test.go index 0de5f126c..b5d8962e7 100644 --- a/x/interchainstaking/keeper/ibc_packet_handlers_test.go +++ b/x/interchainstaking/keeper/ibc_packet_handlers_test.go @@ -597,6 +597,7 @@ func (suite *KeeperTestSuite) TestHandleWithdrawForUser() { for _, test := range tests { suite.Run(test.name, func() { + test := test suite.SetupTest() suite.setupTestZones() @@ -1222,13 +1223,20 @@ func (suite *KeeperTestSuite) TestRebalanceDueToIntentChange() { } val0 := icstypes.Validator{ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val0) + err := quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val0) + suite.NoError(err) + val1 := icstypes.Validator{ValoperAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val1) + err = quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val1) + suite.NoError(err) + val2 := icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val2) + err = quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val2) + suite.NoError(err) + val3 := icstypes.Validator{ValoperAddress: "cosmosvaloper1z8zjv3lntpwxua0rtpvgrcwl0nm0tltgpgs6l7", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val3) + err = quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val3) + suite.NoError(err) vals = quicksilver.InterchainstakingKeeper.GetValidators(ctx, zone.ChainId) @@ -1270,7 +1278,7 @@ func (suite *KeeperTestSuite) TestRebalanceDueToIntentChange() { quicksilver.InterchainstakingKeeper.SetZone(ctx, &zone) // trigger rebalance - err := quicksilver.InterchainstakingKeeper.Rebalance(ctx, &zone, 1) + err = quicksilver.InterchainstakingKeeper.Rebalance(ctx, &zone, 1) suite.NoError(err) // change intents to trigger redelegations from val[3] @@ -1352,13 +1360,21 @@ func (suite *KeeperTestSuite) TestRebalanceDueToDelegationChange() { } val0 := icstypes.Validator{ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val0) + err := quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val0) + suite.NoError(err) + val1 := icstypes.Validator{ValoperAddress: "cosmosvaloper156gqf9837u7d4c4678yt3rl4ls9c5vuursrrzf", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val1) + err = quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val1) + suite.NoError(err) + val2 := icstypes.Validator{ValoperAddress: "cosmosvaloper14lultfckehtszvzw4ehu0apvsr77afvyju5zzy", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val2) + err = quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val2) + suite.NoError(err) + val3 := icstypes.Validator{ValoperAddress: "cosmosvaloper1z8zjv3lntpwxua0rtpvgrcwl0nm0tltgpgs6l7", CommissionRate: sdk.MustNewDecFromStr("1"), VotingPower: sdk.NewInt(2000), Status: stakingtypes.BondStatusBonded} - quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val3) + err = quicksilver.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val3) + suite.NoError(err) + delegations := []icstypes.Delegation{ { DelegationAddress: zone.DelegationAddress.Address, @@ -1399,7 +1415,7 @@ func (suite *KeeperTestSuite) TestRebalanceDueToDelegationChange() { } // trigger rebalance - err := quicksilver.InterchainstakingKeeper.Rebalance(ctx, &zone, 1) + err = quicksilver.InterchainstakingKeeper.Rebalance(ctx, &zone, 1) suite.NoError(err) quicksilver.InterchainstakingKeeper.IterateAllDelegations(ctx, &zone, func(delegation icstypes.Delegation) bool { diff --git a/x/interchainstaking/keeper/redemptions.go b/x/interchainstaking/keeper/redemptions.go index 4f8778033..be2b2b9b6 100644 --- a/x/interchainstaking/keeper/redemptions.go +++ b/x/interchainstaking/keeper/redemptions.go @@ -60,8 +60,11 @@ func (k *Keeper) processRedemptionForLsm(ctx sdk.Context, zone *types.Zone, send TokenizedShareOwner: destination, }) } - // add unallocated dust. - msgs[0].Amount = msgs[0].Amount.AddAmount(outstanding) + // Ensure there are messages to process + if len(msgs) > 0 { + // add unallocated dust. + msgs[0].Amount = msgs[0].Amount.AddAmount(outstanding) //nolint:gosec + } sdkMsgs := make([]sdk.Msg, 0) for _, msg := range msgs { sdkMsgs = append(sdkMsgs, sdk.Msg(msg)) diff --git a/x/interchainstaking/keeper/validator_test.go b/x/interchainstaking/keeper/validator_test.go index ed6d45a0f..84f444346 100644 --- a/x/interchainstaking/keeper/validator_test.go +++ b/x/interchainstaking/keeper/validator_test.go @@ -36,7 +36,8 @@ func (suite *KeeperTestSuite) TestStoreGetDeleteValidator() { Status: stakingtypes.BondStatusBonded, Score: sdk.NewDec(0), } - app.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, newValidator) + err = app.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, newValidator) + suite.NoError(err) count2 := len(app.InterchainstakingKeeper.GetValidators(ctx, zone.ChainId)) diff --git a/x/interchainstaking/keeper/withdrawal_record.go b/x/interchainstaking/keeper/withdrawal_record.go index 4cd57b57a..bf1900a4a 100644 --- a/x/interchainstaking/keeper/withdrawal_record.go +++ b/x/interchainstaking/keeper/withdrawal_record.go @@ -32,7 +32,7 @@ func (k *Keeper) AddWithdrawalRecord(ctx sdk.Context, chainID, delegator string, k.SetWithdrawalRecord(ctx, record) } -///---------------------------------------------------------------- +// ---------------------------------------------------------------- // GetWithdrawalRecord returns withdrawal record info by zone and delegator. func (k *Keeper) GetWithdrawalRecord(ctx sdk.Context, chainID, txhash string, status int32) (types.WithdrawalRecord, bool) { diff --git a/x/interchainstaking/keeper/zones_test.go b/x/interchainstaking/keeper/zones_test.go index edb90b325..e7422fa86 100644 --- a/x/interchainstaking/keeper/zones_test.go +++ b/x/interchainstaking/keeper/zones_test.go @@ -185,7 +185,7 @@ func TestKeeperWithZonesRoundTrip(t *testing.T) { // TODO: convert to keeper tests -/*func TestZone_GetBondedValidatorAddressesAsSlice(t *testing.T) { +/* func TestZone_GetBondedValidatorAddressesAsSlice(t *testing.T) { zone := types.Zone{ConnectionId: "connection-0", ChainId: "cosmoshub-4", AccountPrefix: "cosmos", LocalDenom: "uqatom", BaseDenom: "uatom"} zone.Validators = append(zone.Validators, &types.Validator{ ValoperAddress: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0", @@ -299,4 +299,4 @@ func TestZone_GetAggregateIntentOrDefault(t *testing.T) { } actual := zone.GetAggregateIntentOrDefault() require.Equal(t, expected, actual) -}*/ +} */ diff --git a/x/interchainstaking/types/accounts_test.go b/x/interchainstaking/types/accounts_test.go index 86c3e0325..013aef50d 100644 --- a/x/interchainstaking/types/accounts_test.go +++ b/x/interchainstaking/types/accounts_test.go @@ -39,13 +39,13 @@ func TestAccountSetBalanceGood(t *testing.T) { // tests that the balance panics when set to an invalid denomination. func TestAccountSetBalanceBadDenom(t *testing.T) { ica := NewICA() - require.PanicsWithError(t, "invalid denom: _fail", func() { ica.SetBalance(sdk.NewCoins(sdk.NewCoin("_fail", sdk.NewInt(300)))) }) + require.PanicsWithError(t, "invalid denom: _fail", func() { ica.SetBalance(sdk.NewCoins(sdk.NewCoin("_fail", sdk.NewInt(300)))) }) //nolint:errcheck // we're checking for a panic with error here } // tests that the balance panics when set to a negative number. func TestAccountSetBalanceNegativeAmount(t *testing.T) { ica := NewICA() - require.PanicsWithError(t, "negative coin amount: -300", func() { ica.SetBalance(sdk.NewCoins(sdk.NewCoin("uqck", sdk.NewInt(-300)))) }) + require.PanicsWithError(t, "negative coin amount: -300", func() { ica.SetBalance(sdk.NewCoins(sdk.NewCoin("uqck", sdk.NewInt(-300)))) }) //nolint:errcheck // we're checking for a panic with error here } // tests that the balance panics when set to a negative number. diff --git a/x/mint/simulation/genesis.go b/x/mint/simulation/genesis.go index 65665beb6..10adb047c 100644 --- a/x/mint/simulation/genesis.go +++ b/x/mint/simulation/genesis.go @@ -15,7 +15,7 @@ import ( // Simulation parameter constants. const ( - epochProvisionsKey = "genesis_epoch_provisions" + epochProvisionsKey = "genesis_epoch_provisions" //nolint:gosec // these are not hard coded credentials reductionFactorKey = "reduction_factor" reductionPeriodInEpochsKey = "reduction_period_in_epochs" distributionProportionsKey = "distribution_proportions" diff --git a/x/participationrewards/keeper/keeper_test.go b/x/participationrewards/keeper/keeper_test.go index 5eead3267..eb085cc4a 100644 --- a/x/participationrewards/keeper/keeper_test.go +++ b/x/participationrewards/keeper/keeper_test.go @@ -316,7 +316,8 @@ func (suite *KeeperTestSuite) setupTestZones() { }, } for _, cosmosVal := range cosmosVals { - quicksilver.InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zoneCosmos.ChainId, cosmosVal) + err = quicksilver.InterchainstakingKeeper.SetValidator(suite.chainA.GetContext(), zoneCosmos.ChainId, cosmosVal) + suite.NoError(err) } withdrawalAddress := addressutils.GenerateAddressForTestWithPrefix("osmo") diff --git a/x/participationrewards/keeper/protocol_data.go b/x/participationrewards/keeper/protocol_data.go index e11dae0a4..7df055428 100644 --- a/x/participationrewards/keeper/protocol_data.go +++ b/x/participationrewards/keeper/protocol_data.go @@ -90,6 +90,6 @@ func (k *Keeper) AllKeyedProtocolDatas(ctx sdk.Context) []*types.KeyedProtocolDa return out } -/*func GetProtocolDataKey(protocol string, key string) string { +/* func GetProtocolDataKey(protocol string, key string) string { return fmt.Sprintf("%s/%s", protocol, key) -}*/ +} */ diff --git a/x/participationrewards/keeper/rewards_holdings_test.go b/x/participationrewards/keeper/rewards_holdings_test.go index 11fb7adab..cf67dc416 100644 --- a/x/participationrewards/keeper/rewards_holdings_test.go +++ b/x/participationrewards/keeper/rewards_holdings_test.go @@ -307,7 +307,8 @@ func (suite *KeeperTestSuite) TestCalcUserHoldingsAllocations() { suite.True(tt.remainder.Equal(remainder)) // distribute assets to users; check remainder (to be distributed next time!) - appA.ParticipationRewardsKeeper.DistributeToUsersFromAddress(ctx, icsRewardsAllocations, zone.WithdrawalAddress.Address) + err := appA.ParticipationRewardsKeeper.DistributeToUsersFromAddress(ctx, icsRewardsAllocations, zone.WithdrawalAddress.Address) + suite.NoError(err) icsAddress, _ := addressutils.AddressFromBech32(zone.WithdrawalAddress.Address, "") icsBalance := appA.BankKeeper.GetAllBalances(ctx, icsAddress) suite.ElementsMatch(tt.icsRemainder, icsBalance) diff --git a/x/participationrewards/keeper/rewards_validatorSelection_test.go b/x/participationrewards/keeper/rewards_validatorSelection_test.go index 17eb37aa6..56f8bf78e 100644 --- a/x/participationrewards/keeper/rewards_validatorSelection_test.go +++ b/x/participationrewards/keeper/rewards_validatorSelection_test.go @@ -294,7 +294,7 @@ func (suite *KeeperTestSuite) TestCalcDistributionScores() { validators := appA.InterchainstakingKeeper.GetValidators(ctx, zone.ChainId) for i := range validators { validators[i].VotingPower = sdk.NewInt(0) - appA.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, validators[i]) + appA.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, validators[i]) //nolint:errcheck // ignore error } appA.InterchainstakingKeeper.SetZone(ctx, &zone) @@ -329,7 +329,7 @@ func (suite *KeeperTestSuite) TestCalcDistributionScores() { for i, val := range appA.InterchainstakingKeeper.GetValidators(ctx, zone.ChainId) { val.VotingPower = sdk.NewInt(int64(10 + i*10)) - appA.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val) + appA.InterchainstakingKeeper.SetValidator(ctx, zone.ChainId, val) //nolint:errcheck // ignore error } zone.ValidatorSelectionAllocation = 5000 diff --git a/x/tokenfactory/keeper/admins_test.go b/x/tokenfactory/keeper/admins_test.go index 947675be1..3d7a3d0b5 100644 --- a/x/tokenfactory/keeper/admins_test.go +++ b/x/tokenfactory/keeper/admins_test.go @@ -388,6 +388,7 @@ func (s *KeeperTestSuite) TestSetDenomMetaData() { }, } { s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + tc := tc bankKeeper := s.App.BankKeeper res, err := s.msgServer.SetDenomMetadata(sdk.WrapSDKContext(s.Ctx), &tc.msgSetDenomMetadata) if tc.expectedPass {