diff --git a/.golangci.yml b/.golangci.yml index b8c7d682f2..d0c4eec858 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -63,7 +63,7 @@ linters-settings: # Default: false extra-rules: true dogsled: - max-blank-identifiers: 3 + max-blank-identifiers: 5 maligned: # print struct with more effective memory layout or not, false by default suggest-new: true diff --git a/baseapp/block_gas_test.go b/baseapp/block_gas_test.go index 5c79772d2c..c1f4ff2f5c 100644 --- a/baseapp/block_gas_test.go +++ b/baseapp/block_gas_test.go @@ -221,7 +221,7 @@ func createTestTx(txConfig client.TxConfig, txBuilder client.TxBuilder, privs [] Sequence: accSeqs[i], } sigV2, err := tx.SignWithPrivKey( - nil, txConfig.SignModeHandler().DefaultMode(), signerData, //nolint:staticcheck + context.TODO(), txConfig.SignModeHandler().DefaultMode(), signerData, txBuilder, priv, txConfig, accSeqs[i]) if err != nil { return nil, nil, err diff --git a/client/context_test.go b/client/context_test.go index bc53104218..7145dada00 100644 --- a/client/context_test.go +++ b/client/context_test.go @@ -20,6 +20,11 @@ import ( "github.com/cosmos/cosmos-sdk/types/module/testutil" ) +const ( + text = "text" + jsonText = "json" +) + func TestMain(m *testing.M) { viper.Set(flags.FlagKeyringBackend, keyring.BackendMemory) os.Exit(m.Run()) @@ -46,7 +51,7 @@ func TestContext_PrintProto(t *testing.T) { // json buf := &bytes.Buffer{} ctx = ctx.WithOutput(buf) - ctx.OutputFormat = "json" //nolint:goconst + ctx.OutputFormat = jsonText err = ctx.PrintProto(hasAnimal) require.NoError(t, err) require.Equal(t, @@ -56,7 +61,7 @@ func TestContext_PrintProto(t *testing.T) { // yaml buf = &bytes.Buffer{} ctx = ctx.WithOutput(buf) - ctx.OutputFormat = "text" //nolint:goconst + ctx.OutputFormat = text err = ctx.PrintProto(hasAnimal) require.NoError(t, err) require.Equal(t, @@ -89,7 +94,7 @@ func TestContext_PrintObjectLegacy(t *testing.T) { // json buf := &bytes.Buffer{} ctx = ctx.WithOutput(buf) - ctx.OutputFormat = "json" + ctx.OutputFormat = jsonText err = ctx.PrintObjectLegacy(hasAnimal) require.NoError(t, err) require.Equal(t, @@ -99,7 +104,7 @@ func TestContext_PrintObjectLegacy(t *testing.T) { // yaml buf = &bytes.Buffer{} ctx = ctx.WithOutput(buf) - ctx.OutputFormat = "text" + ctx.OutputFormat = text err = ctx.PrintObjectLegacy(hasAnimal) require.NoError(t, err) require.Equal(t, @@ -121,7 +126,7 @@ func TestContext_PrintRaw(t *testing.T) { // json buf := &bytes.Buffer{} ctx = ctx.WithOutput(buf) - ctx.OutputFormat = "json" + ctx.OutputFormat = jsonText err := ctx.PrintRaw(hasAnimal) require.NoError(t, err) require.Equal(t, @@ -131,7 +136,7 @@ func TestContext_PrintRaw(t *testing.T) { // yaml buf = &bytes.Buffer{} ctx = ctx.WithOutput(buf) - ctx.OutputFormat = "text" + ctx.OutputFormat = text err = ctx.PrintRaw(hasAnimal) require.NoError(t, err) require.Equal(t, diff --git a/client/tx/tx.go b/client/tx/tx.go index 86c0caaa06..5fbc83eb13 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -107,11 +107,11 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error { buf := bufio.NewReader(os.Stdin) ok, err := input.GetConfirmation("confirm transaction before signing and broadcasting", buf, os.Stderr) if err != nil { - _, _ = fmt.Fprintf(os.Stderr, "error: %v\ncancelled transaction\n", err) + _, _ = fmt.Fprintf(os.Stderr, "error: %v\ncanceled transaction\n", err) return err } if !ok { - _, _ = fmt.Fprintln(os.Stderr, "cancelled transaction") + _, _ = fmt.Fprintln(os.Stderr, "canceled transaction") return nil } } diff --git a/codec/unknownproto/unknown_fields_test.go b/codec/unknownproto/unknown_fields_test.go index 7e0af479ad..1a8fd0affd 100644 --- a/codec/unknownproto/unknown_fields_test.go +++ b/codec/unknownproto/unknown_fields_test.go @@ -656,11 +656,11 @@ func TestRejectUnknownFieldsFlat(t *testing.T) { func TestPackedEncoding(t *testing.T) { data := testdata.TestRepeatedUints{Nums: []uint64{12, 13}} - marshalled, err := data.Marshal() + marshaled, err := data.Marshal() require.NoError(t, err) unmarshalled := &testdata.TestRepeatedUints{} - _, err = RejectUnknownFields(marshalled, unmarshalled, false, DefaultAnyResolver{}) + _, err = RejectUnknownFields(marshaled, unmarshalled, false, DefaultAnyResolver{}) require.NoError(t, err) } diff --git a/core/coins/format_test.go b/core/coins/format_test.go index ded6a8760b..ba487e2204 100644 --- a/core/coins/format_test.go +++ b/core/coins/format_test.go @@ -12,15 +12,15 @@ import ( ) // coinsJsonTest is the type of test cases in the coin.json file. -type coinJsonTest struct { +type coinJSONTest struct { Proto *basev1beta1.Coin Metadata *bankv1beta1.Metadata Text string Error bool } -// coinsJsonTest is the type of test cases in the coins.json file. -type coinsJsonTest struct { +// coinsJSONTest is the type of test cases in the coins.json file. +type coinsJSONTest struct { Proto []*basev1beta1.Coin Metadata map[string]*bankv1beta1.Metadata Text string @@ -28,7 +28,7 @@ type coinsJsonTest struct { } func TestFormatCoin(t *testing.T) { - var testcases []coinJsonTest + var testcases []coinJSONTest raw, err := os.ReadFile("../../x/tx/signing/textual/internal/testdata/coin.json") require.NoError(t, err) err = json.Unmarshal(raw, &testcases) @@ -52,7 +52,7 @@ func TestFormatCoin(t *testing.T) { } func TestFormatCoins(t *testing.T) { - var testcases []coinsJsonTest + var testcases []coinsJSONTest raw, err := os.ReadFile("../../x/tx/signing/textual/internal/testdata/coins.json") require.NoError(t, err) err = json.Unmarshal(raw, &testcases) diff --git a/crypto/keys/secp256r1/privkey_internal_test.go b/crypto/keys/secp256r1/privkey_internal_test.go index 771582d6a4..902ee6dafb 100644 --- a/crypto/keys/secp256r1/privkey_internal_test.go +++ b/crypto/keys/secp256r1/privkey_internal_test.go @@ -51,7 +51,7 @@ func (suite *SKSuite) TestBytes() { func (suite *SKSuite) TestMarshalProto() { require := suite.Require() - /**** test structure marshalling ****/ + /**** test structure marshaling ****/ var sk PrivKey bz, err := proto.Marshal(suite.sk) @@ -59,7 +59,7 @@ func (suite *SKSuite) TestMarshalProto() { require.NoError(proto.Unmarshal(bz, &sk)) require.True(sk.Equals(suite.sk)) - /**** test structure marshalling with codec ****/ + /**** test structure marshaling with codec ****/ sk = PrivKey{} registry := types.NewInterfaceRegistry() diff --git a/crypto/keys/secp256r1/pubkey_internal_test.go b/crypto/keys/secp256r1/pubkey_internal_test.go index 2015b32cb3..d3d2ed3823 100644 --- a/crypto/keys/secp256r1/pubkey_internal_test.go +++ b/crypto/keys/secp256r1/pubkey_internal_test.go @@ -68,7 +68,7 @@ func (suite *PKSuite) TestEquals() { func (suite *PKSuite) TestMarshalProto() { require := suite.Require() - /**** test structure marshalling ****/ + /**** test structure marshaling ****/ var pk PubKey bz, err := proto.Marshal(suite.pk) @@ -76,7 +76,7 @@ func (suite *PKSuite) TestMarshalProto() { require.NoError(proto.Unmarshal(bz, &pk)) require.True(pk.Equals(suite.pk)) - /**** test structure marshalling with codec ****/ + /**** test structure marshaling with codec ****/ pk = PubKey{} emptyRegistry := types.NewInterfaceRegistry() @@ -104,7 +104,7 @@ func (suite *PKSuite) TestMarshalProto() { require.Len(bz2, bufSize) require.Equal(bz, bz2[(bufSize-pk.Size()):]) - /**** test interface marshalling ****/ + /**** test interface marshaling ****/ bz, err = pubkeyCodec.MarshalInterface(suite.pk) require.NoError(err) var pkI cryptotypes.PubKey diff --git a/server/api/server.go b/server/api/server.go index 0f5090da1b..d48ef7a1a1 100644 --- a/server/api/server.go +++ b/server/api/server.go @@ -60,7 +60,7 @@ func CustomGRPCHeaderMatcher(key string) (string, bool) { func New(clientCtx client.Context, logger log.Logger, grpcSrv *grpc.Server) *Server { // The default JSON marshaller used by the gRPC-Gateway is unable to marshal non-nullable non-scalar fields. - // Using the gogo/gateway package with the gRPC-Gateway WithMarshaler option fixes the scalar field marshalling issue. + // Using the gogo/gateway package with the gRPC-Gateway WithMarshaler option fixes the scalar field marshaling issue. marshalerOption := &gateway.JSONPb{ EmitDefaults: true, Indent: " ", @@ -77,7 +77,7 @@ func New(clientCtx client.Context, logger log.Logger, grpcSrv *grpc.Server) *Ser runtime.WithMarshalerOption(runtime.MIMEWildcard, marshalerOption), // This is necessary to get error details properly - // marshalled in unary requests. + // marshaled in unary requests. runtime.WithProtoErrorHandler(runtime.DefaultHTTPProtoErrorHandler), // Custom header matcher for mapping request headers to @@ -159,7 +159,7 @@ func (s *Server) Start(ctx context.Context, cfg config.Config) error { // the server failed to start properly. select { case <-ctx.Done(): - // The calling process cancelled or closed the provided context, so we must + // The calling process canceled or closed the provided context, so we must // gracefully stop the API server. s.logger.Info("stopping API server...", "address", cfg.API.Address) return s.Close() diff --git a/simapp/app_v2.go b/simapp/app_v2.go index 01aaaeab73..89d77b2205 100644 --- a/simapp/app_v2.go +++ b/simapp/app_v2.go @@ -3,7 +3,6 @@ package simapp import ( - _ "embed" "io" "os" "path/filepath" diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 9d29ecd26e..cbd64162fb 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -221,8 +221,8 @@ func addModuleInitFlags(startCmd *cobra.Command) { func genesisCommand(encodingConfig params.EncodingConfig, cmds ...*cobra.Command) *cobra.Command { cmd := genutilcli.GenesisCoreCommand(encodingConfig.TxConfig, simapp.ModuleBasics, simapp.DefaultNodeHome) - for _, sub_cmd := range cmds { - cmd.AddCommand(sub_cmd) + for _, subCmd := range cmds { + cmd.AddCommand(subCmd) } return cmd } diff --git a/simapp/upgrades.go b/simapp/upgrades.go index fac518315d..1bce6df3f6 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -4,73 +4,22 @@ import ( storetypes "cosmossdk.io/store/types" upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade -// from v046 to v047. +// from v047 to v048. // // NOTE: This upgrade defines a reference implementation of what an upgrade // could look like when an application is migrating from Cosmos SDK version -// v0.46.x to v0.47.x. -const UpgradeName = "v046-to-v047" +// v0.47.x to v0.48.x. +const UpgradeName = "v047-to-v048" func (app SimApp) RegisterUpgradeHandlers() { - // Set param key table for params module migration - for _, subspace := range app.ParamsKeeper.GetSubspaces() { - subspace := subspace - - var keyTable paramstypes.KeyTable - switch subspace.Name() { - case authtypes.ModuleName: - keyTable = authtypes.ParamKeyTable() - case banktypes.ModuleName: - keyTable = banktypes.ParamKeyTable() - case stakingtypes.ModuleName: - keyTable = stakingtypes.ParamKeyTable() - case minttypes.ModuleName: - keyTable = minttypes.ParamKeyTable() - case distrtypes.ModuleName: - keyTable = distrtypes.ParamKeyTable() - case slashingtypes.ModuleName: - keyTable = slashingtypes.ParamKeyTable() - case govtypes.ModuleName: - keyTable = govv1.ParamKeyTable() //nolint:staticcheck // we still need this for upgrades - case crisistypes.ModuleName: - keyTable = crisistypes.ParamKeyTable() - } - - if !subspace.HasKeyTable() { - subspace.WithKeyTable(keyTable) - } - } - - baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) - app.UpgradeKeeper.SetUpgradeHandler( UpgradeName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // Migrate CometBFT consensus parameters from x/params module to a dedicated x/consensus module. - if err := baseapp.MigrateParams(ctx, baseAppLegacySS, app.ConsensusParamsKeeper.Params); err != nil { - return nil, err - } - - // Note: this migration is optional, - // You can include x/gov proposal migration documented in [UPGRADING.md](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md) - return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) }, ) @@ -81,12 +30,7 @@ func (app SimApp) RegisterUpgradeHandlers() { } if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{ - consensustypes.ModuleName, - crisistypes.ModuleName, - }, - } + storeUpgrades := storetypes.StoreUpgrades{} // configure store loader that checks if version == upgradeHeight and applies store upgrades app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) diff --git a/tests/e2e/gov/tx.go b/tests/e2e/gov/tx.go index a8e0669113..662c593a8a 100644 --- a/tests/e2e/gov/tx.go +++ b/tests/e2e/gov/tx.go @@ -243,7 +243,7 @@ func (s *E2ETestSuite) TestNewCmdSubmitLegacyProposal() { { "valid transaction", []string{ - fmt.Sprintf("--%s='Text Proposal'", cli.FlagTitle), //nolint:staticcheck // we are intentionally using a deprecated flag here. + fmt.Sprintf("--%s='Text Proposal'", cli.FlagTitle), fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription), //nolint:staticcheck // we are intentionally using a deprecated flag here. fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), //nolint:staticcheck // we are intentionally using a deprecated flag here. fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()), diff --git a/tests/e2e/tx/service_test.go b/tests/e2e/tx/service_test.go index 30b8142479..3295032363 100644 --- a/tests/e2e/tx/service_test.go +++ b/tests/e2e/tx/service_test.go @@ -1124,7 +1124,7 @@ type protoTxProvider interface { // txBuilderToProtoTx converts a txBuilder into a proto tx.Tx. // Deprecated: It's used for testing the deprecated Simulate gRPC endpoint // using a proto Tx field and for testing the TxEncode endpoint. -func txBuilderToProtoTx(txBuilder client.TxBuilder) (*tx.Tx, error) { // nolint +func txBuilderToProtoTx(txBuilder client.TxBuilder) (*tx.Tx, error) { protoProvider, ok := txBuilder.(protoTxProvider) if !ok { return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "expected proto tx builder, got %T", txBuilder) diff --git a/tests/integration/aminojson/aminojson_test.go b/tests/integration/aminojson/aminojson_test.go index 8d80bcda5c..5f629e9485 100644 --- a/tests/integration/aminojson/aminojson_test.go +++ b/tests/integration/aminojson/aminojson_test.go @@ -293,9 +293,9 @@ var ( genType(&stakingtypes.StakeAuthorization{}, &stakingapi.StakeAuthorization{}, genOpts), // upgrade + genType(&upgradetypes.CancelSoftwareUpgradeProposal{}, &upgradeapi.CancelSoftwareUpgradeProposal{}, genOpts), // nolint:staticcheck // testing legacy code path + genType(&upgradetypes.SoftwareUpgradeProposal{}, &upgradeapi.SoftwareUpgradeProposal{}, genOpts.WithDisallowNil()), // nolint:staticcheck // testing legacy code path genType(&upgradetypes.Plan{}, &upgradeapi.Plan{}, genOpts.WithDisallowNil()), - genType(&upgradetypes.SoftwareUpgradeProposal{}, &upgradeapi.SoftwareUpgradeProposal{}, genOpts.WithDisallowNil()), - genType(&upgradetypes.CancelSoftwareUpgradeProposal{}, &upgradeapi.CancelSoftwareUpgradeProposal{}, genOpts), genType(&upgradetypes.MsgSoftwareUpgrade{}, &upgradeapi.MsgSoftwareUpgrade{}, genOpts.WithDisallowNil()), genType(&upgradetypes.MsgCancelUpgrade{}, &upgradeapi.MsgCancelUpgrade{}, genOpts), @@ -340,12 +340,12 @@ func TestAminoJSON_Equivalence(t *testing.T) { fmt.Printf("testing %s\n", tt.pulsar.ProtoReflect().Descriptor().FullName()) rapid.Check(t, func(t *rapid.T) { // uncomment to debug; catch a panic and inspect application state - //defer func() { + // defer func() { // if r := recover(); r != nil { // //fmt.Printf("Panic: %+v\n", r) // t.FailNow() // } - //}() + // }() msg := gen.Draw(t, "msg") postFixPulsarMessage(msg) @@ -362,11 +362,11 @@ func TestAminoJSON_Equivalence(t *testing.T) { err = encCfg.Codec.Unmarshal(protoBz, gogo) require.NoError(t, err) - legacyAminoJson, err := encCfg.Amino.MarshalJSON(gogo) + legacyAminoJSON, err := encCfg.Amino.MarshalJSON(gogo) require.NoError(t, err) - aminoJson, err := aj.Marshal(msg) + aminoJSON, err := aj.Marshal(msg) require.NoError(t, err) - require.Equal(t, string(legacyAminoJson), string(aminoJson)) + require.Equal(t, string(legacyAminoJSON), string(aminoJSON)) }) }) } @@ -618,6 +618,7 @@ func TestAminoJSON_LegacyParity(t *testing.T) { require.NoError(t, err) newGogoBytes, err := encCfg.Amino.MarshalJSON(newGogo) + require.NoError(t, err) if tc.roundTripUnequal { require.NotEqual(t, string(gogoBytes), string(newGogoBytes)) return @@ -650,6 +651,7 @@ func TestSendAuthorization(t *testing.T) { require.NoError(t, err) err = proto.Unmarshal(protoBz, sanityPulsar) + require.NoError(t, err) // !!! // empty []string is not the same as nil []string. this is a bug in gogo. @@ -661,17 +663,19 @@ func TestSendAuthorization(t *testing.T) { require.NotNil(t, pulsar.SpendLimit) require.Zero(t, len(pulsar.SpendLimit)) - legacyAminoJson, err := encCfg.Amino.MarshalJSON(gogo) - aminoJson, err := aj.Marshal(sanityPulsar) + legacyAminoJSON, err := encCfg.Amino.MarshalJSON(gogo) + require.NoError(t, err) + aminoJSON, err := aj.Marshal(sanityPulsar) + require.NoError(t, err) - require.Equal(t, string(legacyAminoJson), string(aminoJson)) + require.Equal(t, string(legacyAminoJSON), string(aminoJSON)) - aminoJson, err = aj.Marshal(pulsar) + aminoJSON, err = aj.Marshal(pulsar) require.NoError(t, err) // at this point, pulsar.SpendLimit = [], and gogo.SpendLimit = nil, but they will both marshal to `[]` // this is *only* possible because of Cosmos SDK's custom MarshalJSON method for Coins - require.Equal(t, string(legacyAminoJson), string(aminoJson)) + require.Equal(t, string(legacyAminoJSON), string(aminoJSON)) } func TestDecimalMutation(t *testing.T) { @@ -695,8 +699,7 @@ func TestDecimalMutation(t *testing.T) { } func postFixPulsarMessage(msg proto.Message) { - switch m := msg.(type) { - case *authapi.ModuleAccount: + if m, ok := msg.(*authapi.ModuleAccount); ok { if m.BaseAccount == nil { m.BaseAccount = &authapi.BaseAccount{} } diff --git a/tests/integration/bank/keeper/keeper_test.go b/tests/integration/bank/keeper/keeper_test.go index 3daaa4f9a0..e9a2a12617 100644 --- a/tests/integration/bank/keeper/keeper_test.go +++ b/tests/integration/bank/keeper/keeper_test.go @@ -1245,26 +1245,26 @@ func TestBalanceTrackingEvents(t *testing.T) { for _, e := range f.ctx.EventManager().ABCIEvents() { switch e.Type { case types.EventTypeCoinBurn: - burnedCoins, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) + burnedCoins, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value) assert.NilError(t, err) supply = supply.Sub(burnedCoins...) case types.EventTypeCoinMint: - mintedCoins, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) + mintedCoins, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value) assert.NilError(t, err) supply = supply.Add(mintedCoins...) case types.EventTypeCoinSpent: - coinsSpent, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) + coinsSpent, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value) assert.NilError(t, err) - spender, err := sdk.AccAddressFromBech32((string)(e.Attributes[0].Value)) + spender, err := sdk.AccAddressFromBech32(e.Attributes[0].Value) assert.NilError(t, err) balances[spender.String()] = balances[spender.String()].Sub(coinsSpent...) case types.EventTypeCoinReceived: - coinsRecv, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) + coinsRecv, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value) assert.NilError(t, err) - receiver, err := sdk.AccAddressFromBech32((string)(e.Attributes[0].Value)) + receiver, err := sdk.AccAddressFromBech32(e.Attributes[0].Value) assert.NilError(t, err) balances[receiver.String()] = balances[receiver.String()].Add(coinsRecv...) } diff --git a/tests/integration/slashing/keeper/keeper_test.go b/tests/integration/slashing/keeper/keeper_test.go index ada343cf57..eb2cf73b2a 100644 --- a/tests/integration/slashing/keeper/keeper_test.go +++ b/tests/integration/slashing/keeper/keeper_test.go @@ -285,7 +285,7 @@ func TestValidatorDippingInAndOut(t *testing.T) { tstaking.CheckValidator(valAddr, stakingtypes.Unbonding, false) // 600 more blocks happened - height = height + 600 + height += 600 ctx = ctx.WithBlockHeight(height) // validator added back in diff --git a/tests/integration/staking/keeper/determinstic_test.go b/tests/integration/staking/keeper/determinstic_test.go index 23fb54c814..042882bf42 100644 --- a/tests/integration/staking/keeper/determinstic_test.go +++ b/tests/integration/staking/keeper/determinstic_test.go @@ -88,9 +88,9 @@ func pubKeyGenerator() *rapid.Generator[ed25519.PubKey] { } func bondTypeGenerator() *rapid.Generator[stakingtypes.BondStatus] { - bond_types := []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Unbonded, stakingtypes.Unbonding} + bondTypes := []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Unbonded, stakingtypes.Unbonding} return rapid.Custom(func(t *rapid.T) stakingtypes.BondStatus { - return bond_types[rapid.IntRange(0, 2).Draw(t, "range")] + return bondTypes[rapid.IntRange(0, 2).Draw(t, "range")] }) } diff --git a/tests/integration/staking/keeper/msg_server_test.go b/tests/integration/staking/keeper/msg_server_test.go index 3ccd554d5b..7ab5c27e48 100644 --- a/tests/integration/staking/keeper/msg_server_test.go +++ b/tests/integration/staking/keeper/msg_server_test.go @@ -165,7 +165,7 @@ func TestCancelUnbondingDelegation(t *testing.T) { assert.ErrorContains(t, err, testCase.expErrMsg) } else { assert.NilError(t, err) - balanceForNotBondedPool := bankKeeper.GetBalance(ctx, sdk.AccAddress(notBondedPool.GetAddress()), bondDenom) + balanceForNotBondedPool := bankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom) assert.DeepEqual(t, balanceForNotBondedPool, moduleBalance.Sub(testCase.req.Amount)) moduleBalance = moduleBalance.Sub(testCase.req.Amount) } diff --git a/tests/integration/staking/keeper/unbonding_test.go b/tests/integration/staking/keeper/unbonding_test.go index 0d0eba80eb..28fec36705 100644 --- a/tests/integration/staking/keeper/unbonding_test.go +++ b/tests/integration/staking/keeper/unbonding_test.go @@ -378,7 +378,7 @@ func TestUnbondingDelegationOnHold1(t *testing.T) { notBondedAmt5 := app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount assert.Assert(math.IntEq(t, bondedAmt1, bondedAmt5)) - // Not bonded amount back to what it was originaly + // Not bonded amount back to what it was originally assert.Assert(math.IntEq(t, notBondedAmt1.SubRaw(1), notBondedAmt5)) } @@ -414,6 +414,6 @@ func TestUnbondingDelegationOnHold2(t *testing.T) { notBondedAmt5 := app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount assert.Assert(math.IntEq(t, bondedAmt1, bondedAmt5)) - // Not bonded amount back to what it was originaly + // Not bonded amount back to what it was originally assert.Assert(math.IntEq(t, notBondedAmt1.SubRaw(1), notBondedAmt5)) } diff --git a/tests/integration/staking/keeper/validator_bench_test.go b/tests/integration/staking/keeper/validator_bench_test.go index 3667987138..e7eb60c512 100644 --- a/tests/integration/staking/keeper/validator_bench_test.go +++ b/tests/integration/staking/keeper/validator_bench_test.go @@ -7,7 +7,7 @@ func BenchmarkGetValidator(b *testing.B) { // panic: encoding/hex: odd length hex string powersNumber := 900 - var totalPower int64 = 0 + var totalPower int64 powers := make([]int64, powersNumber) for i := range powers { powers[i] = int64(i) diff --git a/tools/confix/cmd/diff.go b/tools/confix/cmd/diff.go index 28cd337a2f..4dc86dbf16 100644 --- a/tools/confix/cmd/diff.go +++ b/tools/confix/cmd/diff.go @@ -17,11 +17,13 @@ func DiffCommand() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { var filename string clientCtx := client.GetClientContextFromCmd(cmd) - if len(args) > 1 { + switch { + + case len(args) > 1: filename = args[1] - } else if clientCtx.HomeDir != "" { + case clientCtx.HomeDir != "": filename = fmt.Sprintf("%s/config/app.toml", clientCtx.HomeDir) - } else { + default: return fmt.Errorf("must provide a path to the app.toml file") } diff --git a/tools/confix/cmd/migrate.go b/tools/confix/cmd/migrate.go index f31425bfd3..18546b200f 100644 --- a/tools/confix/cmd/migrate.go +++ b/tools/confix/cmd/migrate.go @@ -27,11 +27,12 @@ In case of any error in updating the file, no output is written.`, RunE: func(cmd *cobra.Command, args []string) error { var filename string clientCtx := client.GetClientContextFromCmd(cmd) - if len(args) > 1 { + switch { + case len(args) > 1: filename = args[1] - } else if clientCtx.HomeDir != "" { + case clientCtx.HomeDir != "": filename = fmt.Sprintf("%s/config/app.toml", clientCtx.HomeDir) - } else { + default: return fmt.Errorf("must provide a path to the app.toml file") } diff --git a/tools/confix/diff.go b/tools/confix/diff.go index e5d1fede4e..9abc4cd87a 100644 --- a/tools/confix/diff.go +++ b/tools/confix/diff.go @@ -40,19 +40,21 @@ func DiffKeys(lhs, rhs *tomledit.Document) []Diff { i, j := 0, 0 for i < len(lsec) && j < len(rsec) { - if lsec[i].Name.Before(rsec[j].Name) { + switch { + + case lsec[i].Name.Before(rsec[j].Name): diff = append(diff, Diff{Type: Section, Deleted: true, KV: KV{Key: lsec[i].Name.String()}}) for _, kv := range allKVs(lsec[i]) { diff = append(diff, Diff{Type: Mapping, Deleted: true, KV: kv}) } i++ - } else if rsec[j].Name.Before(lsec[i].Name) { + case rsec[j].Name.Before(lsec[i].Name): diff = append(diff, Diff{Type: Section, KV: KV{Key: rsec[j].Name.String()}}) for _, kv := range allKVs(rsec[j]) { diff = append(diff, Diff{Type: Mapping, KV: kv}) } j++ - } else { + default: diff = append(diff, diffDocs(allKVs(lsec[i]), allKVs(rsec[j]), false)...) i++ j++ @@ -84,13 +86,14 @@ func DiffValues(lhs, rhs *tomledit.Document) []Diff { i, j := 0, 0 for i < len(lsec) && j < len(rsec) { - if lsec[i].Name.Before(rsec[j].Name) { + switch { + case lsec[i].Name.Before(rsec[j].Name): // skip keys present in lhs but not in rhs i++ - } else if rsec[j].Name.Before(lsec[i].Name) { + case rsec[j].Name.Before(lsec[i].Name): // skip keys present in rhs but not in lhs j++ - } else { + default: for _, d := range diffDocs(allKVs(lsec[i]), allKVs(rsec[j]), true) { if !d.Deleted { diff = append(diff, d) @@ -133,13 +136,14 @@ func diffDocs(lhs, rhs []KV, value bool) []Diff { i, j := 0, 0 for i < len(lhs) && j < len(rhs) { - if lhs[i].Key < rhs[j].Key { + switch { + case lhs[i].Key < rhs[j].Key: diff = append(diff, Diff{Type: Mapping, Deleted: true, KV: lhs[i]}) i++ - } else if lhs[i].Key > rhs[j].Key { + case lhs[i].Key > rhs[j].Key: diff = append(diff, Diff{Type: Mapping, KV: rhs[j]}) j++ - } else { + default: // key exists in both lhs and rhs // if value is true, compare the values if value && lhs[i].Value != rhs[j].Value { diff --git a/tools/cosmovisor/args.go b/tools/cosmovisor/args.go index 8c61c1f1c1..3d8c33a1e1 100644 --- a/tools/cosmovisor/args.go +++ b/tools/cosmovisor/args.go @@ -12,7 +12,6 @@ import ( "cosmossdk.io/log" cverrors "cosmossdk.io/tools/cosmovisor/errors" - upgradekeeper "cosmossdk.io/x/upgrade/keeper" "cosmossdk.io/x/upgrade/plan" upgradetypes "cosmossdk.io/x/upgrade/types" ) @@ -303,7 +302,7 @@ func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) (rerr error) { } cfg.currentUpgrade = u - f, err := os.Create(filepath.Join(upgrade, upgradekeeper.UpgradeInfoFileName)) + f, err := os.Create(filepath.Join(upgrade, upgradetypes.UpgradeInfoFilename)) if err != nil { return err } @@ -327,7 +326,7 @@ func (cfg *Config) UpgradeInfo() (upgradetypes.Plan, error) { return cfg.currentUpgrade, nil } - filename := filepath.Join(cfg.Root(), currentLink, upgradekeeper.UpgradeInfoFileName) + filename := filepath.Join(cfg.Root(), currentLink, upgradetypes.UpgradeInfoFilename) _, err := os.Lstat(filename) var u upgradetypes.Plan var bz []byte diff --git a/tools/cosmovisor/args_test.go b/tools/cosmovisor/args_test.go index 805255b2e0..80e0cc54df 100644 --- a/tools/cosmovisor/args_test.go +++ b/tools/cosmovisor/args_test.go @@ -609,15 +609,14 @@ func (s *argsTestSuite) TestGetConfigFromEnv() { cfg, err := GetConfigFromEnv() if tc.expectedErrCount == 0 { assert.NoError(t, err) - } else { - if assert.Error(t, err) { - errCount := 1 - if multi, isMulti := err.(*errors.MultiError); isMulti { - errCount = multi.Len() - } - assert.Equal(t, tc.expectedErrCount, errCount, "error count") + } else if assert.Error(t, err) { + errCount := 1 + if multi, isMulti := err.(*errors.MultiError); isMulti { + errCount = multi.Len() } + assert.Equal(t, tc.expectedErrCount, errCount, "error count") } + assert.Equal(t, tc.expectedCfg, cfg, "config") }) } diff --git a/tools/cosmovisor/buffer_test.go b/tools/cosmovisor/buffer_test.go deleted file mode 100644 index 04dd2bb4c5..0000000000 --- a/tools/cosmovisor/buffer_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package cosmovisor_test - -import ( - "bytes" - "sync" -) - -// buffer is a thread safe bytes buffer -type buffer struct { - b bytes.Buffer - m sync.Mutex -} - -func NewBuffer() *buffer { - return &buffer{} -} - -func (b *buffer) Write(bz []byte) (int, error) { - b.m.Lock() - defer b.m.Unlock() - return b.b.Write(bz) -} - -func (b *buffer) String() string { - b.m.Lock() - defer b.m.Unlock() - return b.b.String() -} - -func (b *buffer) Reset() { - b.m.Lock() - defer b.m.Unlock() - b.b.Reset() -} diff --git a/tools/cosmovisor/cmd/cosmovisor/help_test.go b/tools/cosmovisor/cmd/cosmovisor/help_test.go index 3e31774fa2..fe4e5d78c9 100644 --- a/tools/cosmovisor/cmd/cosmovisor/help_test.go +++ b/tools/cosmovisor/cmd/cosmovisor/help_test.go @@ -1,94 +1,14 @@ package main import ( - "fmt" - "os" "testing" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" + "github.com/stretchr/testify/assert" "cosmossdk.io/tools/cosmovisor" ) -type HelpTestSuite struct { - suite.Suite -} - -func TestHelpTestSuite(t *testing.T) { - suite.Run(t, new(HelpTestSuite)) -} - -// cosmovisorHelpEnv are some string values of environment variables used to configure Cosmovisor. -type cosmovisorHelpEnv struct { - Home string - Name string -} - -// ToMap creates a map of the cosmovisorHelpEnv where the keys are the env var names. -func (c cosmovisorHelpEnv) ToMap() map[string]string { - return map[string]string{ - cosmovisor.EnvHome: c.Home, - cosmovisor.EnvName: c.Name, - } -} - -// Set sets the field in this cosmovisorHelpEnv corresponding to the provided envVar to the given envVal. -func (c *cosmovisorHelpEnv) Set(envVar, envVal string) { - switch envVar { - case cosmovisor.EnvHome: - c.Home = envVal - case cosmovisor.EnvName: - c.Name = envVal - default: - panic(fmt.Errorf("Unknown environment variable [%s]. Ccannot set field to [%s]. ", envVar, envVal)) - } -} - -// clearEnv clears environment variables and returns what they were. -// Designed to be used like this: -// -// initialEnv := clearEnv() -// defer setEnv(nil, initialEnv) -func (s *HelpTestSuite) clearEnv() *cosmovisorHelpEnv { - s.T().Logf("Clearing environment variables.") - rv := cosmovisorHelpEnv{} - for envVar := range rv.ToMap() { - rv.Set(envVar, os.Getenv(envVar)) - s.Require().NoError(os.Unsetenv(envVar)) - } - return &rv -} - -// setEnv sets environment variables to the values provided. -// If t is not nil, and there's a problem, the test will fail immediately. -// If t is nil, problems will just be logged using s.T(). -func (s *HelpTestSuite) setEnv(t *testing.T, env *cosmovisorHelpEnv) { - if t == nil { - s.T().Logf("Restoring environment variables.") - } - for envVar, envVal := range env.ToMap() { - var err error - var msg string - if len(envVal) != 0 { - err = os.Setenv(envVar, envVal) - msg = fmt.Sprintf("setting %s to %s", envVar, envVal) - } else { - err = os.Unsetenv(envVar) - msg = fmt.Sprintf("unsetting %s", envVar) - } - switch { - case t != nil: - require.NoError(t, err, msg) - case err != nil: - s.T().Logf("error %s: %v", msg, err) - default: - s.T().Logf("done %s", msg) - } - } -} - -func (s *HelpTestSuite) TestGetHelpText() { +func TestGetHelpText(t *testing.T) { expectedPieces := []string{ "Cosmovisor", cosmovisor.EnvName, cosmovisor.EnvHome, @@ -97,6 +17,6 @@ func (s *HelpTestSuite) TestGetHelpText() { actual := GetHelpText() for _, piece := range expectedPieces { - s.Assert().Contains(actual, piece) + assert.Contains(t, actual, piece) } } diff --git a/tools/cosmovisor/process.go b/tools/cosmovisor/process.go index bdac5c8f8e..dea066e041 100644 --- a/tools/cosmovisor/process.go +++ b/tools/cosmovisor/process.go @@ -179,7 +179,7 @@ func (l *Launcher) doPreUpgrade() error { } if err := l.executePreUpgradeCmd(); err != nil { - counter += 1 + counter++ switch err.(*exec.ExitError).ProcessState.ExitCode() { case 1: diff --git a/tools/cosmovisor/process_test.go b/tools/cosmovisor/process_test.go index 02479f77e9..d071c480e6 100644 --- a/tools/cosmovisor/process_test.go +++ b/tools/cosmovisor/process_test.go @@ -4,8 +4,10 @@ package cosmovisor_test import ( + "bytes" "fmt" "os" + "sync" "testing" "time" @@ -35,7 +37,7 @@ func (s *processTestSuite) TestLaunchProcess() { logger := log.NewTestLogger(s.T()).With(log.ModuleKey, "cosmosvisor") // should run the genesis binary and produce expected output - stdout, stderr := NewBuffer(), NewBuffer() + stdout, stderr := newBuffer(), newBuffer() currentBin, err := cfg.CurrentBin() require.NoError(err) require.Equal(cfg.GenesisBin(), currentBin) @@ -79,7 +81,7 @@ func (s *processTestSuite) TestLaunchProcessWithRestartDelay() { logger := log.NewTestLogger(s.T()).With(log.ModuleKey, "cosmosvisor") // should run the genesis binary and produce expected output - stdout, stderr := NewBuffer(), NewBuffer() + stdout, stderr := newBuffer(), newBuffer() currentBin, err := cfg.CurrentBin() require.NoError(err) require.Equal(cfg.GenesisBin(), currentBin) @@ -123,7 +125,7 @@ func (s *processTestSuite) TestLaunchProcessWithDownloads() { launcher, err := cosmovisor.NewLauncher(logger, cfg) require.NoError(err) - stdout, stderr := NewBuffer(), NewBuffer() + stdout, stderr := newBuffer(), newBuffer() args := []string{"some", "args", upgradeFilename} doUpgrade, err := launcher.Run(args, stdout, stderr) @@ -240,3 +242,31 @@ func TestUpgradeSkipHeights(t *testing.T) { require.Equal(h, tc.expectRes) } } + +// buffer is a thread safe bytes buffer +type buffer struct { + b bytes.Buffer + m sync.Mutex +} + +func newBuffer() *buffer { + return &buffer{} +} + +func (b *buffer) Write(bz []byte) (int, error) { + b.m.Lock() + defer b.m.Unlock() + return b.b.Write(bz) +} + +func (b *buffer) String() string { + b.m.Lock() + defer b.m.Unlock() + return b.b.String() +} + +func (b *buffer) Reset() { + b.m.Lock() + defer b.m.Unlock() + b.b.Reset() +} diff --git a/tools/rosetta/converter.go b/tools/rosetta/converter.go index f71ad03e43..bae8519660 100644 --- a/tools/rosetta/converter.go +++ b/tools/rosetta/converter.go @@ -24,7 +24,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -338,8 +337,8 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations [] default: return nil, false case banktypes.EventTypeCoinSpent: - spender := sdk.MustAccAddressFromBech32(string(event.Attributes[0].Value)) - coins, err := sdk.ParseCoinsNormalized(string(event.Attributes[1].Value)) + spender := sdk.MustAccAddressFromBech32(event.Attributes[0].Value) + coins, err := sdk.ParseCoinsNormalized(event.Attributes[1].Value) if err != nil { panic(err) } @@ -349,8 +348,8 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations [] accountIdentifier = spender.String() case banktypes.EventTypeCoinReceived: - receiver := sdk.MustAccAddressFromBech32(string(event.Attributes[0].Value)) - coins, err := sdk.ParseCoinsNormalized(string(event.Attributes[1].Value)) + receiver := sdk.MustAccAddressFromBech32(event.Attributes[0].Value) + coins, err := sdk.ParseCoinsNormalized(event.Attributes[1].Value) if err != nil { panic(err) } @@ -362,7 +361,7 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations [] // rosetta does not have the concept of burning coins, so we need to mock // the burn as a send to an address that cannot be resolved to anything case banktypes.EventTypeCoinBurn: - coins, err := sdk.ParseCoinsNormalized(string(event.Attributes[1].Value)) + coins, err := sdk.ParseCoinsNormalized(event.Attributes[1].Value) if err != nil { panic(err) } @@ -755,7 +754,7 @@ func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMe // SignerData converts the given any account to signer data func (c converter) SignerData(anyAccount *codectypes.Any) (*SignerData, error) { - var acc auth.AccountI + var acc sdk.AccountI err := c.ir.UnpackAny(anyAccount, &acc) if err != nil { return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) diff --git a/tools/rosetta/lib/errors/errors_test.go b/tools/rosetta/lib/errors/errors_test.go index 1b35d6a20b..9782c654db 100644 --- a/tools/rosetta/lib/errors/errors_test.go +++ b/tools/rosetta/lib/errors/errors_test.go @@ -20,7 +20,7 @@ func TestRegisterError(t *testing.T) { registeredErrorsCount++ assert.Equal(t, len(ListErrors()), registeredErrorsCount) // re-register an error should not change anything - error = RegisterError(69, "nice!", false, "nice!") + RegisterError(69, "nice!", false, "nice!") assert.Equal(t, len(ListErrors()), registeredErrorsCount) // test sealing diff --git a/types/collections.go b/types/collections.go index 993855ac15..bda34cd0c8 100644 --- a/types/collections.go +++ b/types/collections.go @@ -8,7 +8,7 @@ import ( var ( // AccAddressKey follows the same semantics of collections.BytesKey. - // It just uses humanised format for the String() and EncodeJSON(). + // It just uses humanized format for the String() and EncodeJSON(). AccAddressKey collcodec.KeyCodec[AccAddress] = genericAddressKey[AccAddress]{ stringDecoder: AccAddressFromBech32, keyType: "sdk.AccAddress", diff --git a/types/errors/errors.go b/types/errors/errors.go index 7e4c42bb76..5e17f2df48 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -52,7 +52,7 @@ var ( // ErrNoSignatures to doc ErrNoSignatures = errorsmod.Register(RootCodespace, 15, "no signatures supplied") - // ErrJSONMarshal defines an ABCI typed JSON marshalling error + // ErrJSONMarshal defines an ABCI typed JSON marshaling error ErrJSONMarshal = errorsmod.Register(RootCodespace, 16, "failed to marshal JSON bytes") // ErrJSONUnmarshal defines an ABCI typed JSON unmarshalling error diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 79d485f25e..dd6d2dd5a1 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -1454,7 +1454,7 @@ func TestAnteHandlerReCheck(t *testing.T) { tx, err = suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT) require.NoError(t, err) txBytes, err := json.Marshal(tx) - require.Nil(t, err, "Error marshalling tx: %v", err) + require.Nil(t, err, "Error marshaling tx: %v", err) suite.ctx = suite.ctx.WithTxBytes(txBytes) // require that state machine param-dependent checking is still run on recheck since parameters can change between check and recheck diff --git a/x/gov/client/utils/query_test.go b/x/gov/client/utils/query_test.go index 458836cd8b..5539db456a 100644 --- a/x/gov/client/utils/query_test.go +++ b/x/gov/client/utils/query_test.go @@ -141,8 +141,8 @@ func TestGetPaginatedVotes(t *testing.T) { tc := tc t.Run(tc.description, func(t *testing.T) { - marshalled := make([]cmttypes.Tx, len(tc.msgs)) - cli := TxSearchMock{txs: marshalled, txConfig: encCfg.TxConfig} + marshaled := make([]cmttypes.Tx, len(tc.msgs)) + cli := TxSearchMock{txs: marshaled, txConfig: encCfg.TxConfig} clientCtx := client.Context{}. WithLegacyAmino(encCfg.Amino). WithClient(cli). @@ -155,7 +155,7 @@ func TestGetPaginatedVotes(t *testing.T) { tx, err := clientCtx.TxConfig.TxEncoder()(txBuilder.GetTx()) require.NoError(t, err) - marshalled[i] = tx + marshaled[i] = tx } params := v1.NewQueryProposalVotesParams(0, tc.page, tc.limit) diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index 24e79cde19..d1ed9ddbc0 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -170,7 +170,7 @@ func (q Keeper) Params(c context.Context, req *v1.QueryParamsRequest) (*v1.Query response := &v1.QueryParamsResponse{} - //nolint:staticcheck + //nolint:staticcheck // needed for legacy parameters switch req.ParamsType { case v1.ParamDeposit: depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) @@ -381,7 +381,7 @@ func (q legacyQueryServer) Votes(c context.Context, req *v1beta1.QueryVotesReque }, nil } -//nolint:staticcheck +//nolint:staticcheck // this is needed for legacy param support func (q legacyQueryServer) Params(c context.Context, req *v1beta1.QueryParamsRequest) (*v1beta1.QueryParamsResponse, error) { resp, err := q.keeper.Params(c, &v1.QueryParamsRequest{ ParamsType: req.ParamsType, diff --git a/x/gov/keeper/keeper_test.go b/x/gov/keeper/keeper_test.go index 028b071a65..f839eda270 100644 --- a/x/gov/keeper/keeper_test.go +++ b/x/gov/keeper/keeper_test.go @@ -73,7 +73,7 @@ func (suite *KeeperTestSuite) reset() { } func TestIncrementProposalNumber(t *testing.T) { - govKeeper, _, _, _, _, _, ctx := setupGovKeeper(t) //nolint:dogsled + govKeeper, _, _, _, _, _, ctx := setupGovKeeper(t) tp := TestProposal _, err := govKeeper.SubmitProposal(ctx, tp, "", "test", "summary", sdk.AccAddress("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r"), false) @@ -93,7 +93,7 @@ func TestIncrementProposalNumber(t *testing.T) { } func TestProposalQueues(t *testing.T) { - govKeeper, _, _, _, _, _, ctx := setupGovKeeper(t) //nolint:dogsled + govKeeper, _, _, _, _, _, ctx := setupGovKeeper(t) // create test proposals tp := TestProposal diff --git a/x/group/internal/orm/primary_key_property_test.go b/x/group/internal/orm/primary_key_property_test.go index 7a40cf8c2d..0149531af3 100644 --- a/x/group/internal/orm/primary_key_property_test.go +++ b/x/group/internal/orm/primary_key_property_test.go @@ -18,7 +18,7 @@ func TestPrimaryKeyTable(t *testing.T) { } // primaryKeyMachine is a state machine model of the PrimaryKeyTable. The state -// is modelled as a map of strings to TableModels. +// is modeled as a map of strings to TableModels. type primaryKeyMachine struct { store storetypes.KVStore table *PrimaryKeyTable diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index aa06e18725..5b36ea9f06 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -40,7 +40,7 @@ func (suite *HandlerTestSuite) SetupTest() { ctx := testutil.DefaultContext(key, tkey) paramsKeeper := keeper.NewKeeper(encodingCfg.Codec, encodingCfg.Amino, key, tkey) - paramsKeeper.Subspace("staking").WithKeyTable(stakingtypes.ParamKeyTable()) + paramsKeeper.Subspace("staking").WithKeyTable(stakingtypes.ParamKeyTable()) //nolint:staticcheck // TODO: depreacte this test case ctrl := gomock.NewController(suite.T()) stakingKeeper := paramstestutil.NewMockStakingKeeper(ctrl) stakingKeeper.EXPECT().MaxValidators(ctx).Return(uint32(1)) diff --git a/x/slashing/keeper/genesis_test.go b/x/slashing/keeper/genesis_test.go index 5aea8f4204..a05d501e93 100644 --- a/x/slashing/keeper/genesis_test.go +++ b/x/slashing/keeper/genesis_test.go @@ -46,7 +46,7 @@ func (s *KeeperTestSuite) TestExportAndInitGenesis() { s.stakingKeeper.EXPECT().IterateValidators(ctx, gomock.Any()).Return() keeper.InitGenesis(ctx, s.stakingKeeper, genesisState) - // Validator isTombstoned should return false as GenesisState is initialised + // Validator isTombstoned should return false as GenesisState is initialized ok = keeper.IsTombstoned(ctx, consAddr1) require.False(ok) diff --git a/x/slashing/types/expected_keepers.go b/x/slashing/types/expected_keepers.go index d3a856769f..22ebcd046b 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -42,7 +42,7 @@ type StakingKeeper interface { Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI // get a particular validator by operator address ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI // get a particular validator by consensus address - // slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction + // slash the validator and delegators of the validator, specifying offense height, offence power, and slash fraction Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int SlashWithInfractionReason(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, stakingtypes.Infraction) math.Int Jail(sdk.Context, sdk.ConsAddress) // jail a validator diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index e6e44ba3c7..771fd8ff53 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -61,7 +61,7 @@ type ValidatorSet interface { TotalBondedTokens(sdk.Context) math.Int // total bonded tokens within the validator set StakingTokenSupply(sdk.Context) math.Int // total staking token supply - // slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction + // slash the validator and delegators of the validator, specifying offense height, offence power, and slash fraction Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int SlashWithInfractionReason(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, Infraction) math.Int Jail(sdk.Context, sdk.ConsAddress) // jail a validator diff --git a/x/staking/types/params_legacy.go b/x/staking/types/params_legacy.go index df474c02ff..f2ab556249 100644 --- a/x/staking/types/params_legacy.go +++ b/x/staking/types/params_legacy.go @@ -13,14 +13,13 @@ var ( var _ paramtypes.ParamSet = (*Params)(nil) -// ParamTable for staking module // Deprecated: now params can be accessed on key `0x51` on the staking store. +// ParamTable for staking module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -// Implements params.ParamSet -// Deprecated. +// Deprecated: Implements params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyUnbondingTime, &p.UnbondingTime, validateUnbondingTime),