diff --git a/.golangci.yml b/.golangci.yml index ba3b4b5b9e..92c238d38d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,10 @@ run: - tests: false + tests: true # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 5m + sort-results: true + allow-parallel-runners: true + exclude-dir: testutil/testdata_pulsar linters: disable-all: true @@ -20,6 +23,7 @@ linters: - nakedret - nolintlint - staticcheck + - revive - stylecheck - typecheck - unconvert @@ -42,6 +46,9 @@ issues: text: "SA1019:" linters: - staticcheck + - text: "leading space" + linters: + - nolintlint max-issues-per-linter: 10000 max-same-issues: 10000 diff --git a/api/cosmos/distribution/v1beta1/query_grpc.pb.go b/api/cosmos/distribution/v1beta1/query_grpc.pb.go index edff38fb87..39d22a59e5 100644 --- a/api/cosmos/distribution/v1beta1/query_grpc.pb.go +++ b/api/cosmos/distribution/v1beta1/query_grpc.pb.go @@ -34,7 +34,7 @@ type QueryClient interface { ValidatorSlashes(ctx context.Context, in *QueryValidatorSlashesRequest, opts ...grpc.CallOption) (*QueryValidatorSlashesResponse, error) // DelegationRewards queries the total rewards accrued by a delegation. DelegationRewards(ctx context.Context, in *QueryDelegationRewardsRequest, opts ...grpc.CallOption) (*QueryDelegationRewardsResponse, error) - // DelegationTotalRewards queries the total rewards accrued by a each + // DelegationTotalRewards queries the total rewards accrued by each // validator. DelegationTotalRewards(ctx context.Context, in *QueryDelegationTotalRewardsRequest, opts ...grpc.CallOption) (*QueryDelegationTotalRewardsResponse, error) // DelegatorValidators queries the validators of a delegator. @@ -159,7 +159,7 @@ type QueryServer interface { ValidatorSlashes(context.Context, *QueryValidatorSlashesRequest) (*QueryValidatorSlashesResponse, error) // DelegationRewards queries the total rewards accrued by a delegation. DelegationRewards(context.Context, *QueryDelegationRewardsRequest) (*QueryDelegationRewardsResponse, error) - // DelegationTotalRewards queries the total rewards accrued by a each + // DelegationTotalRewards queries the total rewards accrued by each // validator. DelegationTotalRewards(context.Context, *QueryDelegationTotalRewardsRequest) (*QueryDelegationTotalRewardsResponse, error) // DelegatorValidators queries the validators of a delegator. diff --git a/baseapp/block_gas_test.go b/baseapp/block_gas_test.go index f3418ccd03..39313e7a98 100644 --- a/baseapp/block_gas_test.go +++ b/baseapp/block_gas_test.go @@ -214,7 +214,7 @@ func createTestTx(txConfig client.TxConfig, txBuilder client.TxBuilder, privs [] Sequence: accSeqs[i], } sigV2, err := tx.SignWithPrivKey( - nil, txConfig.SignModeHandler().DefaultMode(), signerData, + nil, txConfig.SignModeHandler().DefaultMode(), signerData, //nolint:staticcheck txBuilder, priv, txConfig, accSeqs[i]) if err != nil { return nil, nil, err diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go index 6c0c1adcf4..8ed59ca3f7 100644 --- a/baseapp/msg_service_router_test.go +++ b/baseapp/msg_service_router_test.go @@ -131,7 +131,7 @@ func TestMsgService(t *testing.T) { Sequence: 0, } sigV2, err = tx.SignWithPrivKey( - nil, txConfig.SignModeHandler().DefaultMode(), signerData, + nil, txConfig.SignModeHandler().DefaultMode(), signerData, //nolint:staticcheck // SA1019: txConfig.SignModeHandler().DefaultMode() is deprecated: use txConfig.SignModeHandler().DefaultMode() instead. txBuilder, priv, txConfig, 0) require.NoError(t, err) err = txBuilder.SetSignatures(sigV2) diff --git a/baseapp/utils_test.go b/baseapp/utils_test.go index cfa0694d94..7d3763f1c5 100644 --- a/baseapp/utils_test.go +++ b/baseapp/utils_test.go @@ -30,9 +30,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/signing" ) -var ( - ParamStoreKey = []byte("paramstore") -) +var ParamStoreKey = []byte("paramstore") func defaultLogger() log.Logger { if testing.Verbose() { diff --git a/client/config/config_test.go b/client/config/config_test.go index 287a976d39..e1feebc740 100644 --- a/client/config/config_test.go +++ b/client/config/config_test.go @@ -26,7 +26,7 @@ const ( // initClientContext initiates client Context for tests func initClientContext(t *testing.T, envVar string) (client.Context, func()) { home := t.TempDir() - chainId := "test-chain" + chainId := "test-chain" //nolint:revive clientCtx := client.Context{}. WithHomeDir(home). WithViper(""). @@ -58,7 +58,7 @@ func TestConfigCmd(t *testing.T) { _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args) require.NoError(t, err) - //./build/simd config node //http://localhost:1 + // ./build/simd config node //http://localhost:1 b := bytes.NewBufferString("") cmd.SetOut(b) cmd.SetArgs([]string{"node"}) diff --git a/client/context_test.go b/client/context_test.go index 0af1ccc6bd..2a01b6aa8c 100644 --- a/client/context_test.go +++ b/client/context_test.go @@ -46,7 +46,7 @@ func TestContext_PrintProto(t *testing.T) { // json buf := &bytes.Buffer{} ctx = ctx.WithOutput(buf) - ctx.OutputFormat = "json" + ctx.OutputFormat = "json" //nolint:goconst err = ctx.PrintProto(hasAnimal) require.NoError(t, err) require.Equal(t, @@ -56,7 +56,7 @@ func TestContext_PrintProto(t *testing.T) { // yaml buf = &bytes.Buffer{} ctx = ctx.WithOutput(buf) - ctx.OutputFormat = "text" + ctx.OutputFormat = "text" //nolint:goconst err = ctx.PrintProto(hasAnimal) require.NoError(t, err) require.Equal(t, diff --git a/client/grpc_query_test.go b/client/grpc_query_test.go index bc0dbeab1e..b3fd023171 100644 --- a/client/grpc_query_test.go +++ b/client/grpc_query_test.go @@ -26,7 +26,6 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) type IntegrationTestSuite struct { @@ -65,7 +64,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.genesisAccountBalance = 100000000000000 senderPrivKey := secp256k1.GenPrivKey() acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) - balance := banktypes.Balance{ + balance := types.Balance{ Address: acc.GetAddress().String(), Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(s.genesisAccountBalance))), } @@ -120,7 +119,7 @@ func (s *IntegrationTestSuite) TestGRPCQuery() { var header metadata.MD res, err := s.bankClient.Balance( context.Background(), - &banktypes.QueryBalanceRequest{Address: s.genesisAccount.GetAddress().String(), Denom: denom}, + &types.QueryBalanceRequest{Address: s.genesisAccount.GetAddress().String(), Denom: denom}, grpc.Header(&header), // Also fetch grpc header ) s.Require().NoError(err) diff --git a/client/keys/import_test.go b/client/keys/import_test.go index 5ab732632a..93027be6e5 100644 --- a/client/keys/import_test.go +++ b/client/keys/import_test.go @@ -94,7 +94,7 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO t.Cleanup(cleanupKeys(t, kb, "keyname1")) keyfile := filepath.Join(kbHome, "key.asc") - require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0o644)) + require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0o644)) //nolint:gosec defer func() { _ = os.RemoveAll(kbHome) diff --git a/client/keys/output_test.go b/client/keys/output_test.go index ecce674190..88ca42f9b1 100644 --- a/client/keys/output_test.go +++ b/client/keys/output_test.go @@ -2,10 +2,11 @@ package keys import ( "fmt" + "testing" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "testing" "github.com/stretchr/testify/require" diff --git a/client/pruning/main.go b/client/pruning/main.go index 7c16cd64b2..7d5f68b590 100644 --- a/client/pruning/main.go +++ b/client/pruning/main.go @@ -19,9 +19,9 @@ import ( const FlagAppDBBackend = "app-db-backend" -// PruningCmd prunes the sdk root multi store history versions based on the pruning options +// Cmd prunes the sdk root multi store history versions based on the pruning options // specified by command flags. -func PruningCmd(appCreator servertypes.AppCreator) *cobra.Command { +func Cmd(appCreator servertypes.AppCreator) *cobra.Command { cmd := &cobra.Command{ Use: "prune", Short: "Prune app history states by keeping the recent heights and deleting old heights", diff --git a/client/testutil/util.go b/client/testutil/util.go index 8d09f5de47..a26d11ad23 100644 --- a/client/testutil/util.go +++ b/client/testutil/util.go @@ -10,7 +10,7 @@ import ( "cosmossdk.io/core/appconfig" "cosmossdk.io/depinject" "github.com/cosmos/cosmos-sdk/codec" - _ "github.com/cosmos/cosmos-sdk/runtime" + _ "github.com/cosmos/cosmos-sdk/runtime" // Register runtime module ) var TestConfig = appconfig.Compose(&appv1alpha1.Config{ diff --git a/client/tx/legacy_test.go b/client/tx/legacy_test.go index 640995ae8a..c4c6271157 100644 --- a/client/tx/legacy_test.go +++ b/client/tx/legacy_test.go @@ -59,7 +59,6 @@ func buildTestTx(t *testing.T, builder client.TxBuilder) { type TestSuite struct { suite.Suite - codec codec.Codec amino *codec.LegacyAmino protoCfg client.TxConfig aminoCfg client.TxConfig diff --git a/client/tx/tx_test.go b/client/tx/tx_test.go index d42c5c59b4..fbe7aacfff 100644 --- a/client/tx/tx_test.go +++ b/client/tx/tx_test.go @@ -353,7 +353,7 @@ func TestSign(t *testing.T) { var prevSigs []signingtypes.SignatureV2 for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - err = tx.Sign(nil, tc.txf, tc.from, tc.txb, tc.overwrite) + err = tx.Sign(nil, tc.txf, tc.from, tc.txb, tc.overwrite) //nolint:staticcheck if len(tc.expectedPKs) == 0 { requireT.Error(err) } else { @@ -422,8 +422,9 @@ func TestPreprocessHook(t *testing.T) { msg1 := banktypes.NewMsgSend(addr1, sdk.AccAddress("to"), nil) msg2 := banktypes.NewMsgSend(addr2, sdk.AccAddress("to"), nil) txb, err := txfDirect.BuildUnsignedTx(msg1, msg2) + requireT.NoError(err) - err = tx.Sign(nil, txfDirect, from, txb, false) + err = tx.Sign(nil, txfDirect, from, txb, false) //nolint:staticcheck requireT.NoError(err) // Run preprocessing diff --git a/codec/any_test.go b/codec/any_test.go index 8df87279be..ccb63f1296 100644 --- a/codec/any_test.go +++ b/codec/any_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -14,8 +13,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/module/testutil" ) -func NewTestInterfaceRegistry() types.InterfaceRegistry { - registry := types.NewInterfaceRegistry() +func NewTestInterfaceRegistry() codectypes.InterfaceRegistry { + registry := codectypes.NewInterfaceRegistry() registry.RegisterInterface("Animal", (*testdata.Animal)(nil)) registry.RegisterImplementations( (*testdata.Animal)(nil), @@ -26,10 +25,10 @@ func NewTestInterfaceRegistry() types.InterfaceRegistry { } func TestMarshalAny(t *testing.T) { - catRegistry := types.NewInterfaceRegistry() + catRegistry := codectypes.NewInterfaceRegistry() catRegistry.RegisterImplementations((*testdata.Animal)(nil), &testdata.Cat{}) - registry := types.NewInterfaceRegistry() + registry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(registry) @@ -65,7 +64,7 @@ func TestMarshalAny(t *testing.T) { require.Equal(t, kitty, animal) // nil should fail - registry = NewTestInterfaceRegistry() + _ = NewTestInterfaceRegistry() err = cdc.UnmarshalInterface(catBz, nil) require.Error(t, err) } diff --git a/codec/proto_codec_test.go b/codec/proto_codec_test.go index fc2e97d000..9838be6b6c 100644 --- a/codec/proto_codec_test.go +++ b/codec/proto_codec_test.go @@ -92,7 +92,7 @@ func TestProtoCodecMarshal(t *testing.T) { err = cdc.UnmarshalInterface(bz, &animal) require.NoError(t, err) - bz, err = cdc.MarshalInterface(bird) + _, err = cdc.MarshalInterface(bird) require.ErrorContains(t, err, "does not have a registered interface") bz, err = cartoonCdc.MarshalInterface(bird) diff --git a/codec/types/any.go b/codec/types/any.go index bd48873371..b1d8973f57 100644 --- a/codec/types/any.go +++ b/codec/types/any.go @@ -1,3 +1,4 @@ +// nolint package types import ( diff --git a/codec/types/any_internal_test.go b/codec/types/any_internal_test.go index 9adab29466..b2b12b123b 100644 --- a/codec/types/any_internal_test.go +++ b/codec/types/any_internal_test.go @@ -17,7 +17,7 @@ func (d Dog) Greet() string { return d.Name } func (d *Dog) Reset() { d.Name = "" } func (d *Dog) String() string { return d.Name } func (d *Dog) ProtoMessage() {} -func (d *Dog) XXX_MessageName() string { return "tests/dog" } +func (d *Dog) XXX_MessageName() string { return "tests/dog" } //nolint:revive type Animal interface { Greet() string diff --git a/codec/types/any_test.go b/codec/types/any_test.go index 5e2b29fcca..656344414a 100644 --- a/codec/types/any_test.go +++ b/codec/types/any_test.go @@ -19,7 +19,7 @@ var _ proto.Message = (*errOnMarshal)(nil) var errAlways = fmt.Errorf("always erroring") -func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { //nolint:revive return nil, errAlways } diff --git a/codec/types/types_test.go b/codec/types/types_test.go index 3ae4a951a5..5db7758955 100644 --- a/codec/types/types_test.go +++ b/codec/types/types_test.go @@ -44,7 +44,7 @@ var ( func (dog FakeDog) Reset() {} func (dog FakeDog) String() string { return "fakedog" } func (dog FakeDog) ProtoMessage() {} -func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) } +func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) } //nolint:revive func (dog FakeDog) Greet() string { return "fakedog" } func TestRegister(t *testing.T) { diff --git a/crypto/hd/fundraiser_test.go b/crypto/hd/fundraiser_test.go index 674ab95c71..ec5f1251d2 100644 --- a/crypto/hd/fundraiser_test.go +++ b/crypto/hd/fundraiser_test.go @@ -75,7 +75,7 @@ func TestFundraiserCompatibility(t *testing.T) { require.Equal(t, seedB, seed) require.Equal(t, master[:], masterB, fmt.Sprintf("Expected masters to match for %d", i)) - require.Equal(t, priv[:], privB, "Expected priv keys to match") + require.Equal(t, priv, privB, "Expected priv keys to match") pubBFixed := make([]byte, secp256k1.PubKeySize) copy(pubBFixed, pubB) require.Equal(t, pub, &secp256k1.PubKey{Key: pubBFixed}, fmt.Sprintf("Expected pub keys to match for %d", i)) diff --git a/crypto/hd/hdpath_test.go b/crypto/hd/hdpath_test.go index 6ea418b92d..126a2a24f0 100644 --- a/crypto/hd/hdpath_test.go +++ b/crypto/hd/hdpath_test.go @@ -185,7 +185,7 @@ func TestDeriveHDPathRange(t *testing.T) { } } -func ExampleStringifyPathParams() { +func ExampleStringifyPathParams() { //nolint:govet path := hd.NewParams(44, 0, 0, false, 0) fmt.Println(path.String()) path = hd.NewParams(44, 33, 7, true, 9) @@ -195,7 +195,7 @@ func ExampleStringifyPathParams() { // m/44'/33'/7'/1/9 } -func ExampleSomeBIP32TestVecs() { +func ExampleSomeBIP32TestVecs() { //nolint:govet seed := mnemonicToSeed("barrel original fuel morning among eternal " + "filter ball stove pluck matrix mechanic") master, ch := hd.ComputeMastersFromSeed(seed) @@ -206,34 +206,34 @@ func ExampleSomeBIP32TestVecs() { if err != nil { fmt.Println("INVALID") } else { - fmt.Println(hex.EncodeToString(priv[:])) + fmt.Println(hex.EncodeToString(priv)) } // bitcoin priv, err = hd.DerivePrivateKeyForPath(master, ch, "44'/0'/0'/0/0") if err != nil { fmt.Println("INVALID") } else { - fmt.Println(hex.EncodeToString(priv[:])) + fmt.Println(hex.EncodeToString(priv)) } // ether priv, err = hd.DerivePrivateKeyForPath(master, ch, "44'/60'/0'/0/0") if err != nil { fmt.Println("INVALID") } else { - fmt.Println(hex.EncodeToString(priv[:])) + fmt.Println(hex.EncodeToString(priv)) } // INVALID priv, err = hd.DerivePrivateKeyForPath(master, ch, "X/0'/0'/0/0") if err != nil { fmt.Println("INVALID") } else { - fmt.Println(hex.EncodeToString(priv[:])) + fmt.Println(hex.EncodeToString(priv)) } priv, err = hd.DerivePrivateKeyForPath(master, ch, "-44/0'/0'/0/0") if err != nil { fmt.Println("INVALID") } else { - fmt.Println(hex.EncodeToString(priv[:])) + fmt.Println(hex.EncodeToString(priv)) } fmt.Println() @@ -245,13 +245,13 @@ func ExampleSomeBIP32TestVecs() { "gorilla ranch hour rival razor call lunar mention taste vacant woman sister") master, ch = hd.ComputeMastersFromSeed(seed) priv, _ = hd.DerivePrivateKeyForPath(master, ch, "44'/1'/1'/0/4") - fmt.Println(hex.EncodeToString(priv[:])) + fmt.Println(hex.EncodeToString(priv)) seed = mnemonicToSeed("idea naive region square margin day captain habit " + "gun second farm pact pulse someone armed") master, ch = hd.ComputeMastersFromSeed(seed) priv, _ = hd.DerivePrivateKeyForPath(master, ch, "44'/0'/0'/0/420") - fmt.Println(hex.EncodeToString(priv[:])) + fmt.Println(hex.EncodeToString(priv)) fmt.Println() fmt.Println("BIP 32 example") @@ -261,7 +261,7 @@ func ExampleSomeBIP32TestVecs() { seed = mnemonicToSeed("monitor flock loyal sick object grunt duty ride develop assault harsh history") master, ch = hd.ComputeMastersFromSeed(seed) priv, _ = hd.DerivePrivateKeyForPath(master, ch, "0/7") - fmt.Println(hex.EncodeToString(priv[:])) + fmt.Println(hex.EncodeToString(priv)) // Output: keys from fundraiser test-vector (cosmos, bitcoin, ether) // diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index e2d9941877..e73964610f 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -21,7 +21,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -160,8 +159,9 @@ func TestKeyManagementKeyRing(t *testing.T) { newPath := filepath.Join(tempDir, "random") require.NoError(t, os.Mkdir(newPath, 0o755)) items, err := os.ReadDir(tempDir) + require.NoError(t, err) require.GreaterOrEqual(t, len(items), 2) - keyS, err = kb.List() + _, err = kb.List() require.NoError(t, err) // addr cache gets nuked - and test skip flag @@ -457,14 +457,15 @@ func TestInMemoryLanguage(t *testing.T) { } func TestInMemoryWithKeyring(t *testing.T) { - priv := cryptotypes.PrivKey(secp256k1.GenPrivKey()) + priv := types.PrivKey(secp256k1.GenPrivKey()) pub := priv.PubKey() cdc := getCodec() _, err := NewLocalRecord("test record", priv, pub) + require.NoError(t, err) multi := multisig.NewLegacyAminoPubKey( - 1, []cryptotypes.PubKey{ + 1, []types.PubKey{ pub, }, ) @@ -1406,7 +1407,7 @@ func TestRenameKey(t *testing.T) { newRecord, err := kr.Key(newKeyUID) // new key should be in keyring require.NoError(t, err) requireEqualRenamedKey(t, newRecord, oldKeyRecord, false) // oldKeyRecord and newRecord should be the same except name - oldKeyRecord, err = kr.Key(oldKeyUID) // old key should be gone from keyring + _, err = kr.Key(oldKeyUID) // old key should be gone from keyring require.Error(t, err) }, }, diff --git a/crypto/keyring/migration_test.go b/crypto/keyring/migration_test.go index 066cd9ceb2..4f320c2f3f 100644 --- a/crypto/keyring/migration_test.go +++ b/crypto/keyring/migration_test.go @@ -134,6 +134,7 @@ func (s *MigrationTestSuite) TestMigrateLocalRecord() { s.Require().NoError(s.ks.SetItem(item)) k2, err := s.ks.migrate(n1) + s.Require().NoError(err) s.Require().Equal(k2.Name, k1.Name) pub, err := k2.GetPubKey() diff --git a/crypto/keyring/types_test.go b/crypto/keyring/types_test.go index fa3e425d17..60e8e54971 100644 --- a/crypto/keyring/types_test.go +++ b/crypto/keyring/types_test.go @@ -17,7 +17,7 @@ func Test_writeReadLedgerInfo(t *testing.T) { hexPK := "035AD6810A47F073553FF30D2FCC7E0D3B1C0B74B61A1AAA2582344037151E143A" bz, err := hex.DecodeString(hexPK) require.NoError(t, err) - copy(tmpKey[:], bz) + copy(tmpKey, bz) pk := &secp256k1.PubKey{Key: tmpKey} path := hd.NewFundraiserParams(5, sdk.CoinType, 1) diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 83622ee430..8ae5cb9e7d 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -31,7 +31,7 @@ func TestSignAndValidateEd25519(t *testing.T) { // ---- // Test cross packages verification - stdPrivKey := stded25519.PrivateKey(privKey.Key) + stdPrivKey := privKey.Key stdPubKey := stdPrivKey.Public().(stded25519.PublicKey) assert.Equal(t, stdPubKey, pubKey.(*ed25519.PubKey).Key) diff --git a/crypto/keys/internal/ecdsa/privkey_internal_test.go b/crypto/keys/internal/ecdsa/privkey_internal_test.go index 660a62aa2b..c8d66e1583 100644 --- a/crypto/keys/internal/ecdsa/privkey_internal_test.go +++ b/crypto/keys/internal/ecdsa/privkey_internal_test.go @@ -71,17 +71,17 @@ func (suite *SKSuite) TestSign() { // extract the r, s values from sig r := new(big.Int).SetBytes(sig[:32]) - low_s := new(big.Int).SetBytes(sig[32:64]) + lowS := new(big.Int).SetBytes(sig[32:64]) // test that NormalizeS simply returns an already // normalized s - require.Equal(NormalizeS(low_s), low_s) + require.Equal(NormalizeS(lowS), lowS) // flip the s value into high order of curve P256 // leave r untouched! - high_s := new(big.Int).Mod(new(big.Int).Neg(low_s), elliptic.P256().Params().N) + highS := new(big.Int).Mod(new(big.Int).Neg(lowS), elliptic.P256().Params().N) - require.False(suite.pk.VerifySignature(msg, signatureRaw(r, high_s))) + require.False(suite.pk.VerifySignature(msg, signatureRaw(r, highS))) // Valid signature using low_s, but too long sigCpy = make([]byte, len(sig)+2) @@ -92,8 +92,8 @@ func (suite *SKSuite) TestSign() { // check whether msg can be verified with same key, and high_s // value using "regular" ecdsa signature - hash := sha256.Sum256([]byte(msg)) - require.True(ecdsa.Verify(&suite.pk.PublicKey, hash[:], r, high_s)) + hash := sha256.Sum256(msg) + require.True(ecdsa.Verify(&suite.pk.PublicKey, hash[:], r, highS)) // Mutate the message msg[1] ^= byte(2) diff --git a/crypto/keys/multisig/multisig_test.go b/crypto/keys/multisig/multisig_test.go index 63ba064f9c..cc9b6cf176 100644 --- a/crypto/keys/multisig/multisig_test.go +++ b/crypto/keys/multisig/multisig_test.go @@ -267,7 +267,7 @@ func TestMultiSigMigration(t *testing.T) { require.NoError(t, multisig.AddSignatureFromPubKey(multisignature, sigs[0], pkSet[0], pkSet)) // create a StdSignature for msg, and convert it to sigV2 - sig := legacytx.StdSignature{PubKey: pkSet[1], Signature: sigs[1].(*signing.SingleSignatureData).Signature} + sig := legacytx.StdSignature{PubKey: pkSet[1], Signature: sigs[1].(*signing.SingleSignatureData).Signature} //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated: use Tx.Msgs, Signatures and Memo instead. sigV2, err := legacytx.StdSignatureToSignatureV2(cdc, sig) require.NoError(t, multisig.AddSignatureV2(multisignature, sigV2, pkSet)) diff --git a/crypto/keys/secp256k1/secp256k1_internal_test.go b/crypto/keys/secp256k1/secp256k1_internal_test.go index 8350f3faa9..f98f360ac2 100644 --- a/crypto/keys/secp256k1/secp256k1_internal_test.go +++ b/crypto/keys/secp256k1/secp256k1_internal_test.go @@ -16,7 +16,7 @@ func Test_genPrivKey(t *testing.T) { copy(onePadded[32-len(oneB):32], oneB) t.Logf("one padded: %v, len=%v", onePadded, len(onePadded)) - validOne := append(empty, onePadded...) + validOne := append(empty, onePadded...) //nolint:gocritic // append is fine here tests := []struct { name string notSoRand []byte @@ -36,7 +36,7 @@ func Test_genPrivKey(t *testing.T) { return } got := genPrivKey(bytes.NewReader(tt.notSoRand)) - fe := new(big.Int).SetBytes(got[:]) + fe := new(big.Int).SetBytes(got) require.True(t, fe.Cmp(btcSecp256k1.S256().N) < 0) require.True(t, fe.Sign() > 0) }) diff --git a/crypto/keys/secp256k1/secp256k1_test.go b/crypto/keys/secp256k1/secp256k1_test.go index 651665ad4e..72e9af8a5a 100644 --- a/crypto/keys/secp256k1/secp256k1_test.go +++ b/crypto/keys/secp256k1/secp256k1_test.go @@ -134,7 +134,7 @@ func TestGenPrivKeyFromSecret(t *testing.T) { gotPrivKey := secp256k1.GenPrivKeyFromSecret(tt.secret) require.NotNil(t, gotPrivKey) // interpret as a big.Int and make sure it is a valid field element: - fe := new(big.Int).SetBytes(gotPrivKey.Key[:]) + fe := new(big.Int).SetBytes(gotPrivKey.Key) require.True(t, fe.Cmp(N) < 0) require.True(t, fe.Sign() > 0) }) diff --git a/crypto/keys/secp256r1/pubkey_internal_test.go b/crypto/keys/secp256r1/pubkey_internal_test.go index eecbbb24d7..2015b32cb3 100644 --- a/crypto/keys/secp256r1/pubkey_internal_test.go +++ b/crypto/keys/secp256r1/pubkey_internal_test.go @@ -62,7 +62,7 @@ func (suite *PKSuite) TestEquals() { require.False(suite.pk.Equals(pkOther)) require.True(pkOther.Equals(pkOther2)) require.True(pkOther2.Equals(pkOther)) - require.True(pkOther.Equals(pkOther), "Equals must be reflexive") + require.True(pkOther.Equals(pkOther), "Equals must be reflexive") //nolint:gocritic // false positive } func (suite *PKSuite) TestMarshalProto() { diff --git a/crypto/ledger/encode_test.go b/crypto/ledger/encode_test.go index 7a60c3d147..2cc4961985 100644 --- a/crypto/ledger/encode_test.go +++ b/crypto/ledger/encode_test.go @@ -9,10 +9,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) -type byter interface { - Bytes() []byte -} - func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool) { // Marshal to JSON bytes. js, err := cdc.MarshalJSON(src) @@ -28,8 +24,7 @@ func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool) require.Nil(t, err, "%+v", err) } -// nolint: govet -func ExamplePrintRegisteredTypes() { +func ExamplePrintRegisteredTypes() { //nolint:govet _ = cdc.PrintTypes(os.Stdout) // | Type | Name | Prefix | Length | Notes | // | ---- | ---- | ------ | ----- | ------ | diff --git a/internal/conv/string_test.go b/internal/conv/string_test.go index 3a14517531..3e051d37b9 100644 --- a/internal/conv/string_test.go +++ b/internal/conv/string_test.go @@ -26,7 +26,7 @@ func (s *StringSuite) TestUnsafeStrToBytes() { b := unsafeConvertStr() runtime.GC() <-time.NewTimer(2 * time.Millisecond).C - b2 := append(b, 'd') + b2 := append(b, 'd') //nolint:gocritic // append is fine here s.Equal("abc", string(b)) s.Equal("abcd", string(b2)) } diff --git a/server/grpc/grpc_web_test.go b/server/grpc/grpc_web_test.go index 664d3632de..060ea811f5 100644 --- a/server/grpc/grpc_web_test.go +++ b/server/grpc/grpc_web_test.go @@ -13,7 +13,7 @@ import ( "strings" "testing" - "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/proto" //nolint:staticcheck // grpc-gateway uses deprecated golang/protobuf "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "google.golang.org/grpc/codes" @@ -170,7 +170,7 @@ func decodeMultipleBase64Chunks(b []byte) ([]byte, error) { if paddingIndex != -1 { // find the consecutive = for { - paddingIndex += 1 + paddingIndex++ if paddingIndex >= len(chunk) || chunk[paddingIndex] != '=' { break } diff --git a/server/grpc/server_test.go b/server/grpc/server_test.go index b49c2e5887..e5d79ed69a 100644 --- a/server/grpc/server_test.go +++ b/server/grpc/server_test.go @@ -55,7 +55,7 @@ func (s *IntegrationTestSuite) SetupSuite() { val0 := s.network.Validators[0] s.conn, err = grpc.Dial( val0.AppConfig.GRPC.Address, - grpc.WithInsecure(), // Or else we get "no transport security set" + grpc.WithInsecure(), //nolint:staticcheck // ignore SA1019, we don't need to use a secure connection for tests grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(s.cfg.InterfaceRegistry).GRPCCodec())), ) s.Require().NoError(err) @@ -96,7 +96,7 @@ func (s *IntegrationTestSuite) TestGRPCServer_BankBalance() { s.Require().NotEmpty(blockHeight[0]) // Should contain the block height // Request metadata should work - bankRes, err = bankClient.Balance( + _, err = bankClient.Balance( metadata.AppendToOutgoingContext(context.Background(), grpctypes.GRPCBlockHeightHeader, "1"), // Add metadata to request &banktypes.QueryBalanceRequest{Address: val0.Address.String(), Denom: denom}, grpc.Header(&header), @@ -239,7 +239,7 @@ func (s *IntegrationTestSuite) TestGRPCUnpacker() { } // mkTxBuilder creates a TxBuilder containing a signed tx from validator 0. -func (s IntegrationTestSuite) mkTxBuilder() client.TxBuilder { +func (s IntegrationTestSuite) mkTxBuilder() client.TxBuilder { //nolint:govet val := s.network.Validators[0] s.Require().NoError(s.network.WaitForNextBlock()) diff --git a/server/mock/app.go b/server/mock/app.go index 499c61e833..928836047e 100644 --- a/server/mock/app.go +++ b/server/mock/app.go @@ -36,7 +36,7 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) { baseApp.SetInitChainer(InitChainer(capKeyMainStore)) interfaceRegistry := codectypes.NewInterfaceRegistry() - interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), &kvstoreTx{}) + interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), &KVStoreTx{}) router := bam.NewMsgServiceRouter() router.SetInterfaceRegistry(interfaceRegistry) @@ -61,13 +61,13 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) { return baseApp, nil } -// KVStoreHandler is a simple handler that takes kvstoreTx and writes +// KVStoreHandler is a simple handler that takes KVStoreTx and writes // them to the db. func KVStoreHandler(storeKey storetypes.StoreKey) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - dTx, ok := msg.(*kvstoreTx) + dTx, ok := msg.(*KVStoreTx) if !ok { - return nil, errors.New("KVStoreHandler should only receive kvstoreTx") + return nil, errors.New("KVStoreHandler should only receive KVStoreTx") } key := dTx.key @@ -140,15 +140,15 @@ func AppGenStateEmpty(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMess // Manually write the handlers for this custom message type MsgServer interface { - Test(ctx context.Context, msg *kvstoreTx) (*sdk.Result, error) + Test(ctx context.Context, msg *KVStoreTx) (*sdk.Result, error) } type MsgServerImpl struct { capKeyMainStore *storetypes.KVStoreKey } -func _Msg_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(kvstoreTx) +func _Msg_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { //nolint:revive + in := new(KVStoreTx) if err := dec(in); err != nil { return nil, err } @@ -157,14 +157,14 @@ func _Msg_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{ } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kvstoreTx", + FullMethod: "/KVStoreTx", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Test(ctx, req.(*kvstoreTx)) + return srv.(MsgServer).Test(ctx, req.(*KVStoreTx)) } return interceptor(ctx, in, info, handler) } -func (m MsgServerImpl) Test(ctx context.Context, msg *kvstoreTx) (*sdk.Result, error) { +func (m MsgServerImpl) Test(ctx context.Context, msg *KVStoreTx) (*sdk.Result, error) { return KVStoreHandler(m.capKeyMainStore)(sdk.UnwrapSDKContext(ctx), msg) } diff --git a/server/mock/tx.go b/server/mock/tx.go index c4c8a778d6..18c42a3e92 100644 --- a/server/mock/tx.go +++ b/server/mock/tx.go @@ -13,7 +13,7 @@ import ( ) // An sdk.Tx which is its own sdk.Msg. -type kvstoreTx struct { +type KVStoreTx struct { key []byte value []byte bytes []byte @@ -41,7 +41,7 @@ func (t testPubKey) Equals(key cryptotypes.PubKey) bool { panic("not implemented func (t testPubKey) Type() string { panic("not implemented") } -func (msg *kvstoreTx) GetSignaturesV2() (res []txsigning.SignatureV2, err error) { +func (msg *KVStoreTx) GetSignaturesV2() (res []txsigning.SignatureV2, err error) { res = append(res, txsigning.SignatureV2{ PubKey: testPubKey{address: msg.address}, Data: nil, @@ -51,38 +51,38 @@ func (msg *kvstoreTx) GetSignaturesV2() (res []txsigning.SignatureV2, err error) return res, nil } -func (msg *kvstoreTx) VerifySignature(msgByte []byte, sig []byte) bool { +func (msg *KVStoreTx) VerifySignature(msgByte []byte, sig []byte) bool { panic("implement me") } -func (msg *kvstoreTx) Address() cryptotypes.Address { +func (msg *KVStoreTx) Address() cryptotypes.Address { panic("implement me") } -func (msg *kvstoreTx) Bytes() []byte { +func (msg *KVStoreTx) Bytes() []byte { panic("implement me") } -func (msg *kvstoreTx) Equals(key cryptotypes.PubKey) bool { +func (msg *KVStoreTx) Equals(key cryptotypes.PubKey) bool { panic("implement me") } // dummy implementation of proto.Message -func (msg *kvstoreTx) Reset() {} -func (msg *kvstoreTx) String() string { return "TODO" } -func (msg *kvstoreTx) ProtoMessage() {} +func (msg *KVStoreTx) Reset() {} +func (msg *KVStoreTx) String() string { return "TODO" } +func (msg *KVStoreTx) ProtoMessage() {} var ( - _ sdk.Tx = &kvstoreTx{} - _ sdk.Msg = &kvstoreTx{} - _ signing.SigVerifiableTx = &kvstoreTx{} - _ cryptotypes.PubKey = &kvstoreTx{} + _ sdk.Tx = &KVStoreTx{} + _ sdk.Msg = &KVStoreTx{} + _ signing.SigVerifiableTx = &KVStoreTx{} + _ cryptotypes.PubKey = &KVStoreTx{} _ cryptotypes.PubKey = &testPubKey{} ) -func NewTx(key, value string, accAddress sdk.AccAddress) *kvstoreTx { +func NewTx(key, value string, accAddress sdk.AccAddress) *KVStoreTx { bytes := fmt.Sprintf("%s=%s", key, value) - return &kvstoreTx{ + return &KVStoreTx{ key: []byte(key), value: []byte(value), bytes: []byte(bytes), @@ -90,28 +90,28 @@ func NewTx(key, value string, accAddress sdk.AccAddress) *kvstoreTx { } } -func (tx *kvstoreTx) Type() string { +func (msg *KVStoreTx) Type() string { return "kvstore_tx" } -func (tx *kvstoreTx) GetMsgs() []sdk.Msg { - return []sdk.Msg{tx} +func (msg *KVStoreTx) GetMsgs() []sdk.Msg { + return []sdk.Msg{msg} } -func (tx *kvstoreTx) GetSignBytes() []byte { - return tx.bytes +func (msg *KVStoreTx) GetSignBytes() []byte { + return msg.bytes } // Should the app be calling this? Or only handlers? -func (tx *kvstoreTx) ValidateBasic() error { +func (msg *KVStoreTx) ValidateBasic() error { return nil } -func (tx *kvstoreTx) GetSigners() []sdk.AccAddress { +func (msg *KVStoreTx) GetSigners() []sdk.AccAddress { return nil } -func (tx *kvstoreTx) GetPubKeys() ([]cryptotypes.PubKey, error) { panic("GetPubKeys not implemented") } +func (msg *KVStoreTx) GetPubKeys() ([]cryptotypes.PubKey, error) { panic("GetPubKeys not implemented") } // takes raw transaction bytes and decodes them into an sdk.Tx. An sdk.Tx has // all the signatures and can be used to authenticate. @@ -121,10 +121,10 @@ func decodeTx(txBytes []byte) (sdk.Tx, error) { split := bytes.Split(txBytes, []byte("=")) if len(split) == 1 { //nolint:gocritic k := split[0] - tx = &kvstoreTx{k, k, txBytes, nil} + tx = &KVStoreTx{k, k, txBytes, nil} } else if len(split) == 2 { k, v := split[0], split[1] - tx = &kvstoreTx{k, v, txBytes, nil} + tx = &KVStoreTx{k, v, txBytes, nil} } else { return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "too many '='") } diff --git a/server/swagger.go b/server/swagger.go index b621c8408e..e8ee5f8feb 100644 --- a/server/swagger.go +++ b/server/swagger.go @@ -8,7 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/rakyll/statik/fs" - _ "github.com/cosmos/cosmos-sdk/client/docs/statik" + _ "github.com/cosmos/cosmos-sdk/client/docs/statik" // we use this to help with sderving the docs ) // RegisterSwaggerAPI provides a common function which registers swagger route with API Server diff --git a/server/util_test.go b/server/util_test.go index eb4ec6fb2d..0a81bb7731 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -25,7 +25,7 @@ import ( genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" ) -var cancelledInPreRun = errors.New("Cancelled in prerun") +var errCanceledInPreRun = errors.New("canceled in prerun") // Used in each test to run the function under test via Cobra // but to always halt the command @@ -35,7 +35,7 @@ func preRunETestImpl(cmd *cobra.Command, args []string) error { return err } - return cancelledInPreRun + return errCanceledInPreRun } func TestInterceptConfigsPreRunHandlerCreatesConfigFilesWhenMissing(t *testing.T) { @@ -49,7 +49,7 @@ func TestInterceptConfigsPreRunHandlerCreatesConfigFilesWhenMissing(t *testing.T serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } @@ -126,7 +126,7 @@ func TestInterceptConfigsPreRunHandlerReadsConfigToml(t *testing.T) { serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } @@ -163,7 +163,7 @@ func TestInterceptConfigsPreRunHandlerReadsAppToml(t *testing.T) { serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } @@ -191,7 +191,7 @@ func TestInterceptConfigsPreRunHandlerReadsFlags(t *testing.T) { serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } @@ -226,7 +226,7 @@ func TestInterceptConfigsPreRunHandlerReadsEnvVars(t *testing.T) { serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } @@ -330,7 +330,7 @@ func TestInterceptConfigsPreRunHandlerPrecedenceFlag(t *testing.T) { serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } @@ -346,7 +346,7 @@ func TestInterceptConfigsPreRunHandlerPrecedenceEnvVar(t *testing.T) { serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } @@ -362,7 +362,7 @@ func TestInterceptConfigsPreRunHandlerPrecedenceConfigFile(t *testing.T) { serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } @@ -378,11 +378,11 @@ func TestInterceptConfigsPreRunHandlerPrecedenceConfigDefault(t *testing.T) { serverCtx := &server.Context{} ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != cancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); err != errCanceledInPreRun { t.Fatalf("function failed with [%T] %v", err, err) } - if "tcp://127.0.0.1:26657" != serverCtx.Config.RPC.ListenAddress { + if "tcp://127.0.0.1:26657" != serverCtx.Config.RPC.ListenAddress { //nolint:stylecheck t.Error("RPCListenAddress is not using default") } } diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 791ce1a312..737eaa4833 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -169,7 +169,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { NewTestnetCmd(simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}), debug.Cmd(), config.Cmd(), - pruning.PruningCmd(newApp), + pruning.Cmd(newApp), ) server.AddCommands(rootCmd, simapp.DefaultNodeHome, newApp, appExport, addModuleInitFlags) diff --git a/store/cachekv/benchmark_test.go b/store/cachekv/benchmark_test.go index 2db62ba5d6..b899068dec 100644 --- a/store/cachekv/benchmark_test.go +++ b/store/cachekv/benchmark_test.go @@ -53,6 +53,7 @@ func BenchmarkDeepContextStack1(b *testing.B) { func BenchmarkDeepContextStack3(b *testing.B) { DoBenchmarkDeepContextStack(b, 3) } + func BenchmarkDeepContextStack10(b *testing.B) { DoBenchmarkDeepContextStack(b, 10) } diff --git a/store/cachekv/internal/btree.go b/store/cachekv/internal/btree.go index 142f754bbd..c09b33fab2 100644 --- a/store/cachekv/internal/btree.go +++ b/store/cachekv/internal/btree.go @@ -49,14 +49,14 @@ func (bt *BTree) Delete(key []byte) { bt.tree.Delete(newItem(key, nil)) } -func (bt *BTree) Iterator(start, end []byte) (*memIterator, error) { +func (bt *BTree) Iterator(start, end []byte) (*memIterator, error) { //nolint:revive if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) { return nil, errKeyEmpty } return NewMemIterator(start, end, bt, make(map[string]struct{}), true), nil } -func (bt *BTree) ReverseIterator(start, end []byte) (*memIterator, error) { +func (bt *BTree) ReverseIterator(start, end []byte) (*memIterator, error) { //nolint:revive if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) { return nil, errKeyEmpty } diff --git a/store/cachekv/internal/memiterator.go b/store/cachekv/internal/memiterator.go index ba6b948465..34c3796c06 100644 --- a/store/cachekv/internal/memiterator.go +++ b/store/cachekv/internal/memiterator.go @@ -24,7 +24,7 @@ type memIterator struct { valid bool } -func NewMemIterator(start, end []byte, items *BTree, deleted map[string]struct{}, ascending bool) *memIterator { +func NewMemIterator(start, end []byte, items *BTree, deleted map[string]struct{}, ascending bool) *memIterator { //nolint:revive iter := items.tree.Iter() var valid bool if ascending { diff --git a/store/cachekv/internal/mergeiterator.go b/store/cachekv/internal/mergeiterator.go index 4186a178a8..293bc968e7 100644 --- a/store/cachekv/internal/mergeiterator.go +++ b/store/cachekv/internal/mergeiterator.go @@ -24,7 +24,7 @@ type cacheMergeIterator struct { var _ types.Iterator = (*cacheMergeIterator)(nil) -func NewCacheMergeIterator(parent, cache types.Iterator, ascending bool) *cacheMergeIterator { +func NewCacheMergeIterator(parent, cache types.Iterator, ascending bool) *cacheMergeIterator { //nolint:revive iter := &cacheMergeIterator{ parent: parent, cache: cache, diff --git a/store/iavl/store_test.go b/store/iavl/store_test.go index f9cb7227ec..2d7c634a98 100644 --- a/store/iavl/store_test.go +++ b/store/iavl/store_test.go @@ -116,14 +116,14 @@ func TestLoadStore(t *testing.T) { func TestGetImmutable(t *testing.T) { db := dbm.NewMemDB() - tree, cID := newAlohaTree(t, db) + tree, _ := newAlohaTree(t, db) store := UnsafeNewStore(tree) updated, err := tree.Set([]byte("hello"), []byte("adios")) require.NoError(t, err) require.True(t, updated) hash, ver, err := tree.SaveVersion() - cID = types.CommitID{Version: ver, Hash: hash} + cID := types.CommitID{Version: ver, Hash: hash} require.Nil(t, err) _, err = store.GetImmutable(cID.Version + 1) diff --git a/store/iavl/tree_test.go b/store/iavl/tree_test.go index 02d19a97bf..db061e8405 100644 --- a/store/iavl/tree_test.go +++ b/store/iavl/tree_test.go @@ -14,8 +14,8 @@ func TestImmutableTreePanics(t *testing.T) { it := &immutableTree{immTree} require.Panics(t, func() { it.Set([]byte{}, []byte{}) }) require.Panics(t, func() { it.Remove([]byte{}) }) - require.Panics(t, func() { it.SaveVersion() }) // nolint:errcheck - require.Panics(t, func() { it.DeleteVersion(int64(1)) }) // nolint:errcheck + require.Panics(t, func() { it.SaveVersion() }) //nolint:errcheck + require.Panics(t, func() { it.DeleteVersion(int64(1)) }) //nolint:errcheck val, proof, err := it.GetVersionedWithProof(nil, 1) require.Error(t, err) diff --git a/store/pruning/manager_test.go b/store/pruning/manager_test.go index adecdd161b..b78338b4fc 100644 --- a/store/pruning/manager_test.go +++ b/store/pruning/manager_test.go @@ -153,7 +153,7 @@ func TestStrategies(t *testing.T) { } func TestHandleHeight_Inputs(t *testing.T) { - var keepRecent int64 = int64(types.NewPruningOptions(types.PruningEverything).KeepRecent) + keepRecent := int64(types.NewPruningOptions(types.PruningEverything).KeepRecent) testcases := map[string]struct { height int64 @@ -284,7 +284,7 @@ func TestHandleHeight_FlushLoadFromDisk(t *testing.T) { require.NotNil(t, manager) manager.SetSnapshotInterval(tc.snapshotInterval) - manager.SetOptions(types.NewCustomPruningOptions(uint64(tc.keepRecent), uint64(10))) + manager.SetOptions(types.NewCustomPruningOptions(tc.keepRecent, uint64(10))) for _, snapshotHeight := range tc.movedSnapshotHeights { manager.HandleHeightSnapshot(snapshotHeight) diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index df75776433..ed28c117b7 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -246,7 +246,7 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { values := 0 for ; iterator.Valid(); iterator.Next() { - values += 1 + values++ } require.Zero(t, values) @@ -404,7 +404,8 @@ func TestMultiStoreQuery(t *testing.T) { k2, v2 := []byte("water"), []byte("flows") // v3 := []byte("is cold") - cid := multi.Commit() + // Commit the multistore. + _ = multi.Commit() // Make sure we can get by name. garbage := multi.GetStoreByName("bad-name") @@ -419,7 +420,7 @@ func TestMultiStoreQuery(t *testing.T) { store2.Set(k2, v2) // Commit the multistore. - cid = multi.Commit() + cid := multi.Commit() ver := cid.Version // Reload multistore from database @@ -533,7 +534,7 @@ func TestMultiStore_Pruning_SameHeightsTwice(t *testing.T) { require.Error(t, err, "expected error when loading pruned height: %d", v) } - for v := int64(numVersions - int64(keepRecent)); v < numVersions; v++ { + for v := (numVersions - int64(keepRecent)); v < numVersions; v++ { err := ms.LoadVersion(v) require.NoError(t, err, "expected no error when loading height: %d", v) } @@ -962,7 +963,7 @@ type commitKVStoreStub struct { func (stub *commitKVStoreStub) Commit() types.CommitID { commitID := stub.CommitKVStore.Commit() - stub.Committed += 1 + stub.Committed++ return commitID } diff --git a/store/snapshots/helpers_test.go b/store/snapshots/helpers_test.go index ec21693254..15620d9a02 100644 --- a/store/snapshots/helpers_test.go +++ b/store/snapshots/helpers_test.go @@ -258,7 +258,7 @@ func (s *extSnapshotter) SupportedFormats() []uint32 { func (s *extSnapshotter) SnapshotExtension(height uint64, payloadWriter snapshottypes.ExtensionPayloadWriter) error { for _, i := range s.state { - if err := payloadWriter(types.Uint64ToBigEndian(uint64(i))); err != nil { + if err := payloadWriter(types.Uint64ToBigEndian(i)); err != nil { return err } } diff --git a/store/streaming/constructor_test.go b/store/streaming/constructor_test.go index a70cbbabfb..03a3574f04 100644 --- a/store/streaming/constructor_test.go +++ b/store/streaming/constructor_test.go @@ -19,7 +19,6 @@ type fakeOptions struct{} func (f *fakeOptions) Get(key string) interface{} { if key == "streamers.file.write_dir" { return "data/file_streamer" - } return nil } diff --git a/store/streaming/file/service_test.go b/store/streaming/file/service_test.go index 2327efac68..1e6af5b025 100644 --- a/store/streaming/file/service_test.go +++ b/store/streaming/file/service_test.go @@ -296,6 +296,7 @@ func testListenBlock(t *testing.T) { metaFileName := fmt.Sprintf("%s-block-%d-meta", testPrefix, testBeginBlockReq.GetHeader().Height) dataFileName := fmt.Sprintf("%s-block-%d-data", testPrefix, testBeginBlockReq.GetHeader().Height) metaFileBytes, err := readInFile(metaFileName) + require.Nil(t, err) dataFileBytes, err := readInFile(dataFileName) require.Nil(t, err) diff --git a/store/types/utils_test.go b/store/types/utils_test.go index b400d61d7b..ef73f2f19b 100644 --- a/store/types/utils_test.go +++ b/store/types/utils_test.go @@ -5,25 +5,10 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/libs/log" - dbm "github.com/tendermint/tm-db" - "github.com/cosmos/cosmos-sdk/store/rootmulti" "github.com/cosmos/cosmos-sdk/store/types" ) -func initTestStores(t *testing.T) (types.KVStore, types.KVStore) { - db := dbm.NewMemDB() - ms := rootmulti.NewStore(db, log.NewNopLogger()) - - key1 := types.NewKVStoreKey("store1") - key2 := types.NewKVStoreKey("store2") - require.NotPanics(t, func() { ms.MountStoreWithDB(key1, types.StoreTypeIAVL, db) }) - require.NotPanics(t, func() { ms.MountStoreWithDB(key2, types.StoreTypeIAVL, db) }) - require.NoError(t, ms.LoadLatestVersion()) - return ms.GetKVStore(key1), ms.GetKVStore(key2) -} - func TestPrefixEndBytes(t *testing.T) { t.Parallel() bs1 := []byte{0x23, 0xA5, 0x06} diff --git a/tests/go.mod b/tests/go.mod index 161d8900ef..7f4cd5abd8 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/math v1.0.0-beta.4 cosmossdk.io/simapp v0.0.0-00010101000000-000000000000 - github.com/cosmos/cosmos-sdk v0.47.0-alpha2 + github.com/cosmos/cosmos-sdk v0.47.0-alpha2.0.20221213010017-b27353d3116b github.com/cosmos/gogoproto v1.4.3 github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 diff --git a/testutil/network/network.go b/testutil/network/network.go index 443849ab4a..c24de69ace 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -45,15 +45,15 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - _ "github.com/cosmos/cosmos-sdk/x/consensus" + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) diff --git a/testutil/testdata_pulsar/query.go b/testutil/testdata_pulsar/query.go index 7103798a22..6fa228011b 100644 --- a/testutil/testdata_pulsar/query.go +++ b/testutil/testdata_pulsar/query.go @@ -1,3 +1,4 @@ +//nolint:revive package testdata_pulsar import ( diff --git a/types/address/hash_test.go b/types/address/hash_test.go index 06fede6594..dd4cd01dc2 100644 --- a/types/address/hash_test.go +++ b/types/address/hash_test.go @@ -56,7 +56,7 @@ func (suite *AddressSuite) TestComposed() { assert.NotEqual(ac, ac2, "NewComposed must be sensitive to type") // changing order of addresses shouldn't impact a composed address - ac2, err = Compose(typ, []Addressable{a1, addrMock{make([]byte, 300, 300)}}) + _, err = Compose(typ, []Addressable{a1, addrMock{make([]byte, 300)}}) assert.Error(err) assert.Contains(err.Error(), "should be max 255 bytes, got 300") } diff --git a/types/address_test.go b/types/address_test.go index 18bb929c61..8dc4530dc0 100644 --- a/types/address_test.go +++ b/types/address_test.go @@ -16,7 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" + "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" //nolint:staticcheck // SA1019: legacybech32 is deprecated: use the bech32 package instead. ) type addressTestSuite struct { @@ -236,7 +236,7 @@ func (s *addressTestSuite) TestConfiguredPrefix() { acc.String(), prefix+types.PrefixAccount), acc.String()) - bech32Pub := legacybech32.MustMarshalPubKey(legacybech32.AccPK, pub) + bech32Pub := legacybech32.MustMarshalPubKey(legacybech32.AccPK, pub) //nolint:staticcheck // SA1019: legacybech32 is deprecated: use the bech32 package instead. s.Require().True(strings.HasPrefix( bech32Pub, prefix+types.PrefixPublic)) @@ -250,7 +250,7 @@ func (s *addressTestSuite) TestConfiguredPrefix() { val.String(), prefix+types.PrefixValidator+types.PrefixAddress)) - bech32ValPub := legacybech32.MustMarshalPubKey(legacybech32.ValPK, pub) + bech32ValPub := legacybech32.MustMarshalPubKey(legacybech32.ValPK, pub) //nolint:staticcheck // SA1019: legacybech32 is deprecated: use the bech32 package instead. s.Require().True(strings.HasPrefix( bech32ValPub, prefix+types.PrefixValidator+types.PrefixPublic)) @@ -264,7 +264,7 @@ func (s *addressTestSuite) TestConfiguredPrefix() { cons.String(), prefix+types.PrefixConsensus+types.PrefixAddress)) - bech32ConsPub := legacybech32.MustMarshalPubKey(legacybech32.ConsPK, pub) + bech32ConsPub := legacybech32.MustMarshalPubKey(legacybech32.ConsPK, pub) //nolint:staticcheck // SA1019: legacybech32 is deprecated: use the bech32 package instead. s.Require().True(strings.HasPrefix( bech32ConsPub, prefix+types.PrefixConsensus+types.PrefixPublic)) @@ -437,25 +437,25 @@ func (s *addressTestSuite) TestAddressTypesEquals() { valAddr2 := types.ValAddress(addr2) // equality - s.Require().True(accAddr1.Equals(accAddr1)) - s.Require().True(consAddr1.Equals(consAddr1)) - s.Require().True(valAddr1.Equals(valAddr1)) + s.Require().True(accAddr1.Equals(accAddr1)) //nolint:gocritic // checking if these are the same + s.Require().True(consAddr1.Equals(consAddr1)) //nolint:gocritic // checking if these are the same + s.Require().True(valAddr1.Equals(valAddr1)) //nolint:gocritic // checking if these are the same // emptiness - s.Require().True(types.AccAddress{}.Equals(types.AccAddress{})) + s.Require().True(types.AccAddress{}.Equals(types.AccAddress{})) //nolint:gocritic // checking if these are the same s.Require().True(types.AccAddress{}.Equals(types.AccAddress(nil))) s.Require().True(types.AccAddress(nil).Equals(types.AccAddress{})) - s.Require().True(types.AccAddress(nil).Equals(types.AccAddress(nil))) + s.Require().True(types.AccAddress(nil).Equals(types.AccAddress(nil))) //nolint:gocritic // checking if these are the same - s.Require().True(types.ConsAddress{}.Equals(types.ConsAddress{})) + s.Require().True(types.ConsAddress{}.Equals(types.ConsAddress{})) //nolint:gocritic // checking if these are the same s.Require().True(types.ConsAddress{}.Equals(types.ConsAddress(nil))) s.Require().True(types.ConsAddress(nil).Equals(types.ConsAddress{})) - s.Require().True(types.ConsAddress(nil).Equals(types.ConsAddress(nil))) + s.Require().True(types.ConsAddress(nil).Equals(types.ConsAddress(nil))) //nolint:gocritic // checking if these are the same - s.Require().True(types.ValAddress{}.Equals(types.ValAddress{})) + s.Require().True(types.ValAddress{}.Equals(types.ValAddress{})) //nolint:gocritic // checking if these are the same s.Require().True(types.ValAddress{}.Equals(types.ValAddress(nil))) s.Require().True(types.ValAddress(nil).Equals(types.ValAddress{})) - s.Require().True(types.ValAddress(nil).Equals(types.ValAddress(nil))) + s.Require().True(types.ValAddress(nil).Equals(types.ValAddress(nil))) //nolint:gocritic // checking if these are the same s.Require().False(accAddr1.Equals(accAddr2)) s.Require().Equal(accAddr1.Equals(accAddr2), accAddr2.Equals(accAddr1)) diff --git a/types/coin_test.go b/types/coin_test.go index 8ac8e5faae..cb012b55d5 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -147,12 +147,12 @@ func (s *coinTestSuite) TestCoinsDenoms() { if len(expectedOutput) == len(tc.testOutput) { for k := range tc.testOutput { if tc.testOutput[k] != expectedOutput[k] { - count += 1 + count++ break } } } else { - count += 1 + count++ } s.Require().Equal(count == 0, tc.expectPass, "unexpected result for coins.Denoms, tc #%d", i) } diff --git a/types/context_test.go b/types/context_test.go index 6608681a39..67b2e25103 100644 --- a/types/context_test.go +++ b/types/context_test.go @@ -137,7 +137,7 @@ func (s *contextTestSuite) TestContextWithCustom() { s.Require().Equal(cp, ctx.WithConsensusParams(cp).ConsensusParams()) // test inner context - newContext := context.WithValue(ctx.Context(), "key", "value") //nolint:golint,staticcheck + newContext := context.WithValue(ctx.Context(), "key", "value") //nolint:golint,staticcheck,revive s.Require().NotEqual(ctx.Context(), ctx.WithContext(newContext).Context()) } @@ -228,7 +228,7 @@ func (s *contextTestSuite) TestUnwrapSDKContext() { s.Require().Panics(func() { types.UnwrapSDKContext(ctx) }) // test unwrapping when we've used context.WithValue - ctx = context.WithValue(sdkCtx, "foo", "bar") + ctx = context.WithValue(sdkCtx, "foo", "bar") //nolint:golint,staticcheck,revive sdkCtx2 = types.UnwrapSDKContext(ctx) s.Require().Equal(sdkCtx, sdkCtx2) } diff --git a/types/denom_internal_test.go b/types/denom_internal_test.go index 8c957353eb..d135d0a765 100644 --- a/types/denom_internal_test.go +++ b/types/denom_internal_test.go @@ -180,6 +180,7 @@ func (s *internalDenomTestSuite) TestDecOperationOrder() { s.Require().NoError(err) s.Require().NoError(RegisterDenom("unit1", dec)) dec, err = NewDecFromStr("100000011") + s.Require().NoError(err) s.Require().NoError(RegisterDenom("unit2", dec)) coin, err := ConvertCoin(NewCoin("unit1", NewInt(100000011)), "unit2") diff --git a/types/events_test.go b/types/events_test.go index f95f8a1612..a9aad20839 100644 --- a/types/events_test.go +++ b/types/events_test.go @@ -76,8 +76,8 @@ func (s *eventsTestSuite) TestEmitTypedEvent() { s.Require().Len(em.Events(), 1) attrs := em.Events()[0].Attributes s.Require().Len(attrs, 2) - s.Require().Equal(string(attrs[0].Key), "amount") - s.Require().Equal(string(attrs[1].Key), "denom") + s.Require().Equal(attrs[0].Key, "amount") + s.Require().Equal(attrs[1].Key, "denom") } }) } diff --git a/types/mempool/mempool_test.go b/types/mempool/mempool_test.go index e18504c0c5..a80b320bd3 100644 --- a/types/mempool/mempool_test.go +++ b/types/mempool/mempool_test.go @@ -84,15 +84,15 @@ type sigErrTx struct { getSigs func() ([]txsigning.SignatureV2, error) } -func (_ sigErrTx) Size() int64 { return 0 } +func (sigErrTx) Size() int64 { return 0 } -func (_ sigErrTx) GetMsgs() []sdk.Msg { return nil } +func (sigErrTx) GetMsgs() []sdk.Msg { return nil } -func (_ sigErrTx) ValidateBasic() error { return nil } +func (sigErrTx) ValidateBasic() error { return nil } -func (_ sigErrTx) GetSigners() []sdk.AccAddress { return nil } +func (sigErrTx) GetSigners() []sdk.AccAddress { return nil } -func (_ sigErrTx) GetPubKeys() ([]cryptotypes.PubKey, error) { return nil, nil } +func (sigErrTx) GetPubKeys() ([]cryptotypes.PubKey, error) { return nil, nil } func (t sigErrTx) GetSignaturesV2() ([]txsigning.SignatureV2, error) { return t.getSigs() } diff --git a/types/mempool/priority_nonce_test.go b/types/mempool/priority_nonce_test.go index d5d76d747b..ee6ea2db2c 100644 --- a/types/mempool/priority_nonce_test.go +++ b/types/mempool/priority_nonce_test.go @@ -36,7 +36,8 @@ func TestOutOfOrder(t *testing.T) { {priority: 21, nonce: 4, address: sa}, {priority: 8, nonce: 3, address: sa}, {priority: 6, nonce: 2, address: sa}, - }} + }, + } for _, outOfOrder := range outOfOrders { var mtxs []sdk.Tx @@ -56,7 +57,6 @@ func TestOutOfOrder(t *testing.T) { } require.Error(t, validateOrder(rmtxs)) - } func (s *MempoolTestSuite) TestPriorityNonceTxOrder() { @@ -347,22 +347,20 @@ func validateOrder(mtxs []sdk.Tx) error { if a.n > b.n { return fmt.Errorf("same sender tx have wrong nonce order\n%v\n%v", a, b) } - } else { - // different sender - if a.p < b.p { - // find a tx with same sender as b and lower nonce - found := false - for _, c := range itxs { - iterations++ - if c.a.Equals(b.a) && c.n < b.n && c.p <= a.p { - found = true - break - } - } - if !found { - return fmt.Errorf("different sender tx have wrong order\n%v\n%v", b, a) + } else if a.p < b.p { // different sender + // find a tx with same sender as b and lower nonce + found := false + for _, c := range itxs { + iterations++ + if c.a.Equals(b.a) && c.n < b.n && c.p <= a.p { + found = true + break } } + if !found { + return fmt.Errorf("different sender tx have wrong order\n%v\n%v", b, a) + } + } } } @@ -477,7 +475,8 @@ func genRandomTxs(seed int64, countTx int, countAccount int) (res []testTx) { priority: priority, nonce: nonce, address: addr, - id: i}) + id: i, + }) } return res diff --git a/types/module/module_int_test.go b/types/module/module_int_test.go index 13bf6aa97c..c4a421027f 100644 --- a/types/module/module_int_test.go +++ b/types/module/module_int_test.go @@ -15,7 +15,7 @@ type TestSuite struct { suite.Suite } -func (s TestSuite) TestAssertNoForgottenModules() { +func (s TestSuite) TestAssertNoForgottenModules() { //nolint:govet m := Manager{ Modules: map[string]interface{}{"a": nil, "b": nil}, } @@ -37,7 +37,7 @@ func (s TestSuite) TestAssertNoForgottenModules() { } } -func (s TestSuite) TestModuleNames() { +func (s TestSuite) TestModuleNames() { //nolint:govet // this is a test m := Manager{ Modules: map[string]interface{}{"a": nil, "b": nil}, } @@ -46,7 +46,7 @@ func (s TestSuite) TestModuleNames() { s.Require().Equal([]string{"a", "b"}, ms) } -func (s TestSuite) TestDefaultMigrationsOrder() { +func (s TestSuite) TestDefaultMigrationsOrder() { //nolint:govet // this is a test require := s.Require() require.Equal( []string{"auth2", "d", "z", "auth"}, diff --git a/types/query/filtered_pagination_test.go b/types/query/filtered_pagination_test.go index 0fd697def1..c04a078881 100644 --- a/types/query/filtered_pagination_test.go +++ b/types/query/filtered_pagination_test.go @@ -56,7 +56,7 @@ func (s *paginationTestSuite) TestFilteredPaginations() { s.Require().NotNil(res) s.Require().Equal(2, len(balances)) s.Require().NotNil(res.NextKey) - s.Require().Equal(string(res.NextKey), fmt.Sprintf("test2denom")) + s.Require().Equal(string(res.NextKey), "test2denom") s.Require().Equal(uint64(4), res.Total) s.T().Log("verify both key and offset can't be given") @@ -152,7 +152,7 @@ func (s *paginationTestSuite) TestReverseFilteredPaginations() { s.Require().NotNil(res) s.Require().Equal(2, len(balns)) s.Require().NotNil(res.NextKey) - s.Require().Equal(string(res.NextKey), fmt.Sprintf("test5denom")) + s.Require().Equal(string(res.NextKey), "test5denom") s.T().Log("verify last page records, nextKey for query and reverse true") pageReq = &query.PageRequest{Key: res.NextKey, Reverse: true} diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index 53597c1be8..a3e4c55254 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -194,7 +194,7 @@ func (s *paginationTestSuite) TestPagination() { s.T().Log("verify paginate with offset and key - error") pageReq = &query.PageRequest{Key: res.Pagination.NextKey, Offset: 100, Limit: defaultLimit, CountTotal: false} request = types.NewQueryAllBalancesRequest(addr1, pageReq) - res, err = queryClient.AllBalances(gocontext.Background(), request) + _, err = queryClient.AllBalances(gocontext.Background(), request) s.Require().Error(err) s.Require().Equal("rpc error: code = InvalidArgument desc = paginate: invalid request, either offset or key is expected, got both", err.Error()) @@ -317,7 +317,7 @@ func (s *paginationTestSuite) TestReversePagination() { s.T().Log("verify paginate with offset and key - error") pageReq = &query.PageRequest{Key: res1.Pagination.NextKey, Offset: 100, Limit: defaultLimit, CountTotal: false} request = types.NewQueryAllBalancesRequest(addr1, pageReq) - res, err = queryClient.AllBalances(gocontext.Background(), request) + _, err = queryClient.AllBalances(gocontext.Background(), request) s.Require().Error(err) s.Require().Equal("rpc error: code = InvalidArgument desc = paginate: invalid request, either offset or key is expected, got both", err.Error()) diff --git a/types/result_test.go b/types/result_test.go index a58425c04a..bbbfd268cc 100644 --- a/types/result_test.go +++ b/types/result_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/proto" //nolint:staticcheck // grpc-gateway uses deprecated golang/protobuf "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" diff --git a/types/store_test.go b/types/store_test.go index dc7b1e48ae..e52112ca72 100644 --- a/types/store_test.go +++ b/types/store_test.go @@ -63,7 +63,7 @@ func (s *storeTestSuite) TestNewTransientStoreKeys() { func (s *storeTestSuite) TestNewInfiniteGasMeter() { gm := sdk.NewInfiniteGasMeter() s.Require().NotNil(gm) - _, ok := gm.(types.GasMeter) + _, ok := gm.(types.GasMeter) //nolint:gosimple s.Require().True(ok) } @@ -101,7 +101,7 @@ func (s *storeTestSuite) TestDiffKVStores() { // Same keys, different value. Comparisons will be nil as prefixes are skipped. prefix := []byte("prefix:") - k1Prefixed := append(prefix, k1...) + k1Prefixed := append(prefix, k1...) //nolint:gocritic // append is fine here store1.Set(k1Prefixed, v1) store2.Set(k1Prefixed, v2) s.checkDiffResults(store1, store2) diff --git a/types/tx/direct_aux_test.go b/types/tx/direct_aux_test.go index 7120126c02..5f8c7aefc3 100644 --- a/types/tx/direct_aux_test.go +++ b/types/tx/direct_aux_test.go @@ -63,8 +63,8 @@ func TestAuxSignerData(t *testing.T) { }{ {"empty address", tx.AuxSignerData{}, true}, {"empty sign mode", tx.AuxSignerData{Address: addr.String()}, true}, - {"SIGN_MODE_DIRECT", tx.AuxSignerData{Address: addr.String(), Mode: signing.SignMode(signing.SignMode_SIGN_MODE_DIRECT)}, true}, - {"no sig", tx.AuxSignerData{Address: addr.String(), Mode: signing.SignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX)}, true}, + {"SIGN_MODE_DIRECT", tx.AuxSignerData{Address: addr.String(), Mode: signing.SignMode_SIGN_MODE_DIRECT}, true}, + {"no sig", tx.AuxSignerData{Address: addr.String(), Mode: signing.SignMode_SIGN_MODE_DIRECT_AUX}, true}, {"happy case WITH DIRECT_AUX", tx.AuxSignerData{Address: addr.String(), Mode: signing.SignMode_SIGN_MODE_DIRECT_AUX, SignDoc: sd, Sig: sig}, false}, {"happy case WITH DIRECT_AUX", tx.AuxSignerData{Address: addr.String(), Mode: signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, SignDoc: sd, Sig: sig}, false}, } diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 0ff3cdaefb..c42e792f89 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -1249,9 +1249,9 @@ func generatePubKeysAndSignatures(n int, msg []byte, _ bool) (pubkeys []cryptoty // TODO: also generate ed25519 keys as below when ed25519 keys are // actually supported, https://github.com/cosmos/cosmos-sdk/issues/4789 // for now this fails: - //if rand.Int63()%2 == 0 { + // if rand.Int63()%2 == 0 { // privkey = ed25519.GenPrivKey() - //} else { + // } else { // privkey = secp256k1.GenPrivKey() //} diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index c14d511e6b..e9f1e0999e 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -122,7 +122,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim } // use stdsignature to mock the size of a full signature - simSig := legacytx.StdSignature{ //nolint:staticcheck // this will be removed when proto is ready + simSig := legacytx.StdSignature{ //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated Signature: simSecp256k1Sig[:], PubKey: pubkey, } diff --git a/x/auth/ante/setup_test.go b/x/auth/ante/setup_test.go index e7138af70e..675deed778 100644 --- a/x/auth/ante/setup_test.go +++ b/x/auth/ante/setup_test.go @@ -79,7 +79,7 @@ func TestRecoverPanic(t *testing.T) { require.Equal(t, gasLimit, newCtx.GasMeter().Limit()) antehandler = sdk.ChainAnteDecorators(sud, PanicDecorator{}) - require.Panics(t, func() { antehandler(suite.ctx, tx, false) }, "Recovered from non-Out-of-Gas panic") // nolint:errcheck + require.Panics(t, func() { antehandler(suite.ctx, tx, false) }, "Recovered from non-Out-of-Gas panic") //nolint:errcheck } type OutOfGasDecorator struct{} diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index 9f7a14f5e9..8155d28a90 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -76,7 +76,7 @@ func TestConsumeSignatureVerificationGas(t *testing.T) { multisignature1 := multisig.NewMultisig(len(pkSet1)) expectedCost1 := expectedGasCostByKeys(pkSet1) for i := 0; i < len(pkSet1); i++ { - stdSig := legacytx.StdSignature{PubKey: pkSet1[i], Signature: sigSet1[i]} + stdSig := legacytx.StdSignature{PubKey: pkSet1[i], Signature: sigSet1[i]} //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated sigV2, err := legacytx.StdSignatureToSignatureV2(suite.clientCtx.LegacyAmino, stdSig) require.NoError(t, err) err = multisig.AddSignatureV2(multisignature1, sigV2, pkSet1) diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index c00846057d..7fbaf58880 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -205,7 +205,7 @@ func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums [] Sequence: accSeqs[i], } sigV2, err := tx.SignWithPrivKey( - nil, suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, + nil, suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, // nolint:staticcheck // SA1019: signing.SignerData is deprecated suite.txBuilder, priv, suite.clientCtx.TxConfig, accSeqs[i]) if err != nil { return nil, err diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index 9be7a90156..b7f0f170aa 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -114,14 +114,14 @@ func TestBatchScanner_Scan(t *testing.T) { bldr.SetGasLimit(50000) bldr.SetFeeAmount(sdk.NewCoins(sdk.NewInt64Coin("atom", 150))) bldr.SetMemo("foomemo") - txJson, err := txGen.TxJSONEncoder()(bldr.GetTx()) + txJSON, err := txGen.TxJSONEncoder()(bldr.GetTx()) require.NoError(t, err) // use the tx JSON to generate some tx batches (it doesn't matter that we use the same JSON because we don't care about the actual context) - goodBatchOf3Txs := fmt.Sprintf("%s\n%s\n%s\n", txJson, txJson, txJson) - malformedBatch := fmt.Sprintf("%s\nmalformed\n%s\n", txJson, txJson) - batchOf2TxsWithNoNewline := fmt.Sprintf("%s\n%s", txJson, txJson) - batchWithEmptyLine := fmt.Sprintf("%s\n\n%s", txJson, txJson) + goodBatchOf3Txs := fmt.Sprintf("%s\n%s\n%s\n", txJSON, txJSON, txJSON) + malformedBatch := fmt.Sprintf("%s\nmalformed\n%s\n", txJSON, txJSON) + batchOf2TxsWithNoNewline := fmt.Sprintf("%s\n%s", txJSON, txJSON) + batchWithEmptyLine := fmt.Sprintf("%s\n\n%s", txJSON, txJSON) tests := []struct { name string @@ -153,7 +153,7 @@ func TestBatchScanner_Scan(t *testing.T) { func compareEncoders(t *testing.T, expected sdk.TxEncoder, actual sdk.TxEncoder) { msgs := []sdk.Msg{testdata.NewTestMsg(addr)} - tx := legacytx.NewStdTx(msgs, legacytx.StdFee{}, []legacytx.StdSignature{}, "") + tx := legacytx.NewStdTx(msgs, legacytx.StdFee{}, []legacytx.StdSignature{}, "") //nolint:staticcheck // SA1019: legacytx.StdFee is deprecated: use FeeTx interface instead defaultEncoderBytes, err := expected(tx) require.NoError(t, err) diff --git a/x/auth/helpers/genaccounts.go b/x/auth/helpers/genaccounts.go index 00ee73c18e..f2af64e4c0 100644 --- a/x/auth/helpers/genaccounts.go +++ b/x/auth/helpers/genaccounts.go @@ -24,7 +24,7 @@ func AddGenesisAccount( cdc codec.Codec, accAddr sdk.AccAddress, appendAcct bool, - genesisFileUrl, amountStr, vestingAmtStr string, + genesisFileURL, amountStr, vestingAmtStr string, vestingStart, vestingEnd int64, ) error { coins, err := sdk.ParseCoinsNormalized(amountStr) @@ -69,7 +69,7 @@ func AddGenesisAccount( return fmt.Errorf("failed to validate new genesis account: %w", err) } - appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genesisFileUrl) + appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genesisFileURL) if err != nil { return fmt.Errorf("failed to unmarshal genesis state: %w", err) } @@ -133,5 +133,5 @@ func AddGenesisAccount( } genDoc.AppState = appStateJSON - return genutil.ExportGenesisFile(genDoc, genesisFileUrl) + return genutil.ExportGenesisFile(genDoc, genesisFileURL) } diff --git a/x/auth/keeper/grpc_query.go b/x/auth/keeper/grpc_query.go index 983da9c5a3..7a9d99150a 100644 --- a/x/auth/keeper/grpc_query.go +++ b/x/auth/keeper/grpc_query.go @@ -28,10 +28,10 @@ func (ak AccountKeeper) AccountAddressByID(c context.Context, req *types.QueryAc return nil, status.Error(codes.InvalidArgument, "requesting with id isn't supported, try to request using account-id") } - accId := req.AccountId + accID := req.AccountId ctx := sdk.UnwrapSDKContext(c) - address := ak.GetAccountAddressByID(ctx, accId) + address := ak.GetAccountAddressByID(ctx, accID) if len(address) == 0 { return nil, status.Errorf(codes.NotFound, "account address not found with account number %d", req.Id) } diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index 16c7ffabb2..fc58d2f4e9 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -63,7 +63,7 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { // set the account without map to accAddr to accNumber. // // NOTE: This is used for testing purposes only. -func (m Migrator) V45_SetAccount(ctx sdk.Context, acc types.AccountI) error { +func (m Migrator) V45_SetAccount(ctx sdk.Context, acc types.AccountI) error { //nolint:revive addr := acc.GetAddress() store := ctx.KVStore(m.keeper.storeKey) diff --git a/x/auth/migrations/legacytx/amino_signing_test.go b/x/auth/migrations/legacytx/amino_signing_test.go index 568ea8b7c2..98afa6aab4 100644 --- a/x/auth/migrations/legacytx/amino_signing_test.go +++ b/x/auth/migrations/legacytx/amino_signing_test.go @@ -30,7 +30,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { } var ( - chainId = "test-chain" + chainID = "test-chain" accNum uint64 = 7 seqNum uint64 = 7 timeoutHeight uint64 = 10 @@ -47,7 +47,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { handler := stdTxSignModeHandler{} signingData := signing.SignerData{ Address: addr1.String(), - ChainID: chainId, + ChainID: chainID, AccountNumber: accNum, Sequence: seqNum, PubKey: priv1.PubKey(), @@ -55,7 +55,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) require.NoError(t, err) - expectedSignBz := StdSignBytes(chainId, accNum, seqNum, timeoutHeight, fee, msgs, memo, nil) + expectedSignBz := StdSignBytes(chainID, accNum, seqNum, timeoutHeight, fee, msgs, memo, nil) require.Equal(t, expectedSignBz, signBz) diff --git a/x/auth/migrations/legacytx/stdtx_test.go b/x/auth/migrations/legacytx/stdtx_test.go index 2e69427c5a..ea84b4b4d3 100644 --- a/x/auth/migrations/legacytx/stdtx_test.go +++ b/x/auth/migrations/legacytx/stdtx_test.go @@ -30,14 +30,14 @@ func init() { RegisterLegacyAminoCodec(amino) } -// Deprecated, use fee amount and gas limit separately on TxBuilder. +// Deprecated: use fee amount and gas limit separately on TxBuilder. func NewTestStdFee() StdFee { return NewStdFee(100000, sdk.NewCoins(sdk.NewInt64Coin("atom", 150)), ) } -// Deprecated, use TxBuilder. +// Deprecated: use TxBuilder. func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, accNums []uint64, seqs []uint64, timeout uint64, fee StdFee) sdk.Tx { sigs := make([]StdSignature, len(privs)) for i, priv := range privs { diff --git a/x/auth/module.go b/x/auth/module.go index ee1cbd137f..6c3c5ba854 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -203,6 +203,7 @@ func init() { ) } +//nolint:revive type AuthInputs struct { depinject.In @@ -217,6 +218,7 @@ type AuthInputs struct { LegacySubspace exported.Subspace `optional:"true"` } +//nolint:revive type AuthOutputs struct { depinject.Out diff --git a/x/auth/signing/handler_map_test.go b/x/auth/signing/handler_map_test.go index c672ff37ae..2e374019c2 100644 --- a/x/auth/signing/handler_map_test.go +++ b/x/auth/signing/handler_map_test.go @@ -51,7 +51,7 @@ func TestHandlerMap_GetSignBytes(t *testing.T) { } var ( - chainId = "test-chain" + chainID = "test-chain" accNum uint64 = 7 seqNum uint64 = 7 ) @@ -61,7 +61,7 @@ func TestHandlerMap_GetSignBytes(t *testing.T) { signingData := signing.SignerData{ Address: addr1.String(), - ChainID: chainId, + ChainID: chainID, AccountNumber: accNum, Sequence: seqNum, PubKey: priv1.PubKey(), diff --git a/x/auth/signing/verify.go b/x/auth/signing/verify.go index 0b7ed3fb4e..826df596bc 100644 --- a/x/auth/signing/verify.go +++ b/x/auth/signing/verify.go @@ -33,9 +33,8 @@ func VerifySignature(ctx context.Context, pubKey cryptotypes.PubKey, signerData handlerWithContext, ok := handler.(SignModeHandlerWithContext) if ok { return handlerWithContext.GetSignBytesWithContext(ctx, mode, signerData, tx) - } else { - return handler.GetSignBytes(mode, signerData, tx) } + return handler.GetSignBytes(mode, signerData, tx) }, data) if err != nil { return err @@ -50,11 +49,10 @@ func VerifySignature(ctx context.Context, pubKey cryptotypes.PubKey, signerData // checks if the sign mode handler supports SignModeHandlerWithContext, in // which case it passes the context.Context argument. Otherwise, it fallbacks // to GetSignBytes. -func GetSignBytesWithContext(h SignModeHandler, ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error) { +func GetSignBytesWithContext(h SignModeHandler, ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error) { //nolint:revive hWithCtx, ok := h.(SignModeHandlerWithContext) if ok { return hWithCtx.GetSignBytesWithContext(ctx, mode, data, tx) - } else { - return h.GetSignBytes(mode, data, tx) } + return h.GetSignBytes(mode, data, tx) } diff --git a/x/auth/signing/verify_test.go b/x/auth/signing/verify_test.go index 29deaaaa4d..ecedbcee23 100644 --- a/x/auth/signing/verify_test.go +++ b/x/auth/signing/verify_test.go @@ -28,7 +28,7 @@ func TestVerifySignature(t *testing.T) { const ( memo = "testmemo" - chainId = "test-chain" + chainID = "test-chain" ) encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) @@ -63,10 +63,10 @@ func TestVerifySignature(t *testing.T) { require.NoError(t, err) msgs := []sdk.Msg{testdata.NewTestMsg(addr)} - fee := legacytx.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) + fee := legacytx.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) //nolint:staticcheck // SA1019: legacytx.StdFee is deprecated: use StdFeeV2 signerData := signing.SignerData{ Address: addr.String(), - ChainID: chainId, + ChainID: chainID, AccountNumber: acc.GetAccountNumber(), Sequence: acc.GetSequence(), PubKey: pubKey, @@ -75,14 +75,14 @@ func TestVerifySignature(t *testing.T) { signature, err := priv.Sign(signBytes) require.NoError(t, err) - stdSig := legacytx.StdSignature{PubKey: pubKey, Signature: signature} + stdSig := legacytx.StdSignature{PubKey: pubKey, Signature: signature} //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated: use SignatureV2 sigV2, err := legacytx.StdSignatureToSignatureV2(encCfg.Amino, stdSig) require.NoError(t, err) handler := MakeTestHandlerMap() - stdTx := legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig}, memo) + stdTx := legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig}, memo) //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated: use SignatureV2 stdTx.TimeoutHeight = 10 - err = signing.VerifySignature(nil, pubKey, signerData, sigV2.Data, handler, stdTx) + err = signing.VerifySignature(nil, pubKey, signerData, sigV2.Data, handler, stdTx) //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated: use SignatureV2 require.NoError(t, err) pkSet := []cryptotypes.PubKey{pubKey, pubKey1} @@ -93,13 +93,13 @@ func TestVerifySignature(t *testing.T) { sig1, err := priv.Sign(multiSignBytes) require.NoError(t, err) - stdSig1 := legacytx.StdSignature{PubKey: pubKey, Signature: sig1} + stdSig1 := legacytx.StdSignature{PubKey: pubKey, Signature: sig1} //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated: use SignatureV2 sig1V2, err := legacytx.StdSignatureToSignatureV2(encCfg.Amino, stdSig1) require.NoError(t, err) sig2, err := priv1.Sign(multiSignBytes) require.NoError(t, err) - stdSig2 := legacytx.StdSignature{PubKey: pubKey, Signature: sig2} + stdSig2 := legacytx.StdSignature{PubKey: pubKey, Signature: sig2} //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated: use SignatureV2 sig2V2, err := legacytx.StdSignatureToSignatureV2(encCfg.Amino, stdSig2) require.NoError(t, err) @@ -108,9 +108,9 @@ func TestVerifySignature(t *testing.T) { err = multisig.AddSignatureFromPubKey(multisignature, sig2V2.Data, pkSet[1], pkSet) require.NoError(t, err) - stdTx = legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig1, stdSig2}, memo) + stdTx = legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig1, stdSig2}, memo) //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated: use SignatureV2 stdTx.TimeoutHeight = 10 - err = signing.VerifySignature(nil, multisigKey, signerData, multisignature, handler, stdTx) + err = signing.VerifySignature(nil, multisigKey, signerData, multisignature, handler, stdTx) //nolint:staticcheck // SA1019: legacytx.StdSignature is deprecated: use SignatureV2 require.NoError(t, err) } diff --git a/x/auth/testutil/app_config.go b/x/auth/testutil/app_config.go index 26409bfb1a..294d12c118 100644 --- a/x/auth/testutil/app_config.go +++ b/x/auth/testutil/app_config.go @@ -1,15 +1,15 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/feegrant/module" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" // import vesting as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/feegrant/module" // import feegrant as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/auth/tx/aux_test.go b/x/auth/tx/aux_test.go index 023b7b477a..0f813917f1 100644 --- a/x/auth/tx/aux_test.go +++ b/x/auth/tx/aux_test.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/depinject" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" clienttx "github.com/cosmos/cosmos-sdk/client/tx" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -196,7 +195,7 @@ func TestBuilderWithAux(t *testing.T) { }, sigs[2]) } -func makeTipperTxBuilder(t *testing.T) (tx.AuxTxBuilder, []byte) { +func makeTipperTxBuilder(t *testing.T) (clienttx.AuxTxBuilder, []byte) { tipperBuilder := clienttx.NewAuxTxBuilder() tipperBuilder.SetAddress(tipperAddr.String()) tipperBuilder.SetAccountNumber(1) diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index f7122dd392..41d7c7d891 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -21,7 +21,7 @@ func TestTxBuilder(t *testing.T) { marshaler := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) txBuilder := newBuilder(nil) - memo := "sometestmemo" + memo := "sometestmemo" //nolint:goconst msgs := []sdk.Msg{testdata.NewTestMsg(addr)} accSeq := uint64(2) // Arbitrary account sequence any, err := codectypes.NewAnyWithValue(pubkey) @@ -40,7 +40,7 @@ func TestTxBuilder(t *testing.T) { Sequence: accSeq, }) - var sig signing.SignatureV2 = signing.SignatureV2{ + sig := signing.SignatureV2{ PubKey: pubkey, Data: &signing.SingleSignatureData{ SignMode: signing.SignMode_SIGN_MODE_DIRECT, diff --git a/x/auth/tx/config/config.go b/x/auth/tx/config/config.go index fe1c529bf5..3f6085836e 100644 --- a/x/auth/tx/config/config.go +++ b/x/auth/tx/config/config.go @@ -24,6 +24,7 @@ func init() { ) } +//nolint:revive type TxInputs struct { depinject.In @@ -35,6 +36,7 @@ type TxInputs struct { FeeGrantKeeper feegrantkeeper.Keeper `optional:"true"` } +//nolint:revive type TxOutputs struct { depinject.Out diff --git a/x/auth/tx/encode_decode_test.go b/x/auth/tx/encode_decode_test.go index db6c3d995e..9d7512ffd0 100644 --- a/x/auth/tx/encode_decode_test.go +++ b/x/auth/tx/encode_decode_test.go @@ -171,6 +171,7 @@ func TestRejectNonADR027(t *testing.T) { require.NoError(t, err) authInfo := &testdata.TestUpdatedAuthInfo{Fee: &tx.Fee{GasLimit: 127}} // Look for "127" when debugging the bytes stream. authInfoBz, err := authInfo.Marshal() + require.NoError(t, err) txRaw := &tx.TxRaw{ BodyBytes: bodyBz, AuthInfoBytes: authInfoBz, diff --git a/x/auth/tx/legacy_amino_json_test.go b/x/auth/tx/legacy_amino_json_test.go index 7df42f92b1..63afe9dd5d 100644 --- a/x/auth/tx/legacy_amino_json_test.go +++ b/x/auth/tx/legacy_amino_json_test.go @@ -35,10 +35,10 @@ func buildTx(t *testing.T, bldr *wrapper) { func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { var ( - chainId = "test-chain" - accNum uint64 = 7 - seqNum uint64 = 7 - tip *tx.Tip = &tx.Tip{Tipper: addr1.String(), Amount: coins} + chainID = "test-chain" + accNum uint64 = 7 + seqNum uint64 = 7 + tip = &tx.Tip{Tipper: addr1.String(), Amount: coins} ) testcases := []struct { @@ -50,22 +50,22 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { { "signer which is also fee payer (no tips)", addr1.String(), func(w *wrapper) {}, - legacytx.StdSignBytes(chainId, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas}, []sdk.Msg{msg}, memo, nil), + legacytx.StdSignBytes(chainID, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas}, []sdk.Msg{msg}, memo, nil), }, { "signer which is also fee payer (with tips)", addr2.String(), func(w *wrapper) { w.SetTip(tip) }, - legacytx.StdSignBytes(chainId, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas}, []sdk.Msg{msg}, memo, tip), + legacytx.StdSignBytes(chainID, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas}, []sdk.Msg{msg}, memo, tip), }, { "explicit fee payer", addr1.String(), func(w *wrapper) { w.SetFeePayer(addr2) }, - legacytx.StdSignBytes(chainId, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas, Payer: addr2.String()}, []sdk.Msg{msg}, memo, nil), + legacytx.StdSignBytes(chainID, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas, Payer: addr2.String()}, []sdk.Msg{msg}, memo, nil), }, { "explicit fee granter", addr1.String(), func(w *wrapper) { w.SetFeeGranter(addr2) }, - legacytx.StdSignBytes(chainId, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas, Granter: addr2.String()}, []sdk.Msg{msg}, memo, nil), + legacytx.StdSignBytes(chainID, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas, Granter: addr2.String()}, []sdk.Msg{msg}, memo, nil), }, { "explicit fee payer and fee granter", addr1.String(), @@ -73,12 +73,12 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { w.SetFeePayer(addr2) w.SetFeeGranter(addr2) }, - legacytx.StdSignBytes(chainId, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas, Payer: addr2.String(), Granter: addr2.String()}, []sdk.Msg{msg}, memo, nil), + legacytx.StdSignBytes(chainID, accNum, seqNum, timeout, legacytx.StdFee{Amount: coins, Gas: gas, Payer: addr2.String(), Granter: addr2.String()}, []sdk.Msg{msg}, memo, nil), }, { "signer which is also tipper", addr1.String(), func(w *wrapper) { w.SetTip(tip) }, - legacytx.StdSignBytes(chainId, accNum, seqNum, timeout, legacytx.StdFee{}, []sdk.Msg{msg}, memo, tip), + legacytx.StdSignBytes(chainID, accNum, seqNum, timeout, legacytx.StdFee{}, []sdk.Msg{msg}, memo, tip), }, } @@ -93,7 +93,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { signingData := signing.SignerData{ Address: tc.signer, - ChainID: chainId, + ChainID: chainID, AccountNumber: accNum, Sequence: seqNum, } @@ -109,7 +109,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { tx := bldr.GetTx() signingData := signing.SignerData{ Address: addr1.String(), - ChainID: chainId, + ChainID: chainID, AccountNumber: accNum, Sequence: seqNum, PubKey: pubkey1, diff --git a/x/auth/tx/testutil/suite.go b/x/auth/tx/testutil/suite.go index 7b6ad4673b..b9f2d41c74 100644 --- a/x/auth/tx/testutil/suite.go +++ b/x/auth/tx/testutil/suite.go @@ -16,7 +16,7 @@ import ( ) // TxConfigTestSuite provides a test suite that can be used to test that a TxConfig implementation is correct. -type TxConfigTestSuite struct { +type TxConfigTestSuite struct { //nolint:revive suite.Suite TxConfig client.TxConfig } diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index f74cac7141..49dfc83b96 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -129,6 +129,7 @@ func init() { ) } +//nolint:revive type VestingInputs struct { depinject.In @@ -136,6 +137,7 @@ type VestingInputs struct { BankKeeper types.BankKeeper } +//nolint:revive type VestingOutputs struct { depinject.Out diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 16e4e7d84b..a76ca3c9dd 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -171,6 +171,7 @@ func init() { ) } +//nolint:revive type AuthzInputs struct { depinject.In @@ -182,6 +183,7 @@ type AuthzInputs struct { MsgServiceRouter *baseapp.MsgServiceRouter } +//nolint:revive type AuthzOutputs struct { depinject.Out diff --git a/x/authz/simulation/decoder_test.go b/x/authz/simulation/decoder_test.go index 0b854bf76a..487deae31f 100644 --- a/x/authz/simulation/decoder_test.go +++ b/x/authz/simulation/decoder_test.go @@ -32,7 +32,7 @@ func TestDecodeStore(t *testing.T) { require.NoError(t, err) kvPairs := kv.Pairs{ Pairs: []kv.Pair{ - {Key: []byte(keeper.GrantKey), Value: grantBz}, + {Key: keeper.GrantKey, Value: grantBz}, {Key: []byte{0x99}, Value: []byte{0x99}}, }, } diff --git a/x/authz/testutil/app_config.go b/x/authz/testutil/app_config.go index 7d2d2c0196..59d8c0b3c9 100644 --- a/x/authz/testutil/app_config.go +++ b/x/authz/testutil/app_config.go @@ -1,16 +1,16 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/authz/module" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/gov" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/authz/module" // import authz as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/gov" // import gov as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/mint" // import mint as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1" "cosmossdk.io/core/appconfig" diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 1fe15ad143..f598d88e85 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -356,16 +356,16 @@ func TestMsgSetSendEnabled(t *testing.T) { []sdk.Msg{ types.NewMsgSetSendEnabled(govAddr, nil, nil), }, - sdk.Coins{{"foocoin", sdk.NewInt(5)}}, + sdk.Coins{{Denom: "foocoin", Amount: sdk.NewInt(5)}}, addr1Str, "set default send enabled to true", ) require.NoError(t, err, "making goodGovProp") badGovProp, err := govv1.NewMsgSubmitProposal( []sdk.Msg{ - types.NewMsgSetSendEnabled(govAddr, []*types.SendEnabled{{"bad coin name!", true}}, nil), + types.NewMsgSetSendEnabled(govAddr, []*types.SendEnabled{{Denom: "bad coin name!", Enabled: true}}, nil), }, - sdk.Coins{{"foocoin", sdk.NewInt(5)}}, + sdk.Coins{{Denom: "foocoin", Amount: sdk.NewInt(5)}}, addr1Str, "set default send enabled to true", ) diff --git a/x/bank/bench_test.go b/x/bank/bench_test.go index fa936df15c..4563a0b7e7 100644 --- a/x/bank/bench_test.go +++ b/x/bank/bench_test.go @@ -14,7 +14,6 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -68,7 +67,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { } // construct genesis state - genAccs := []types.GenesisAccount{&acc} + genAccs := []authtypes.GenesisAccount{&acc} s := createTestSuite(&testing.T{}, genAccs) baseApp := s.App.BaseApp ctx := baseApp.NewContext(false, tmproto.Header{}) diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index 1fe4685209..7e7e9e8162 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -39,7 +39,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { exportGenesis := suite.bankKeeper.ExportGenesis(ctx) - suite.Require().Len(exportGenesis.Params.SendEnabled, 0) + suite.Require().Len(exportGenesis.Params.SendEnabled, 0) //nolint:staticcheck // SA1019: types.DefaultParams().SendEnabled is deprecated: Use DefaultSendEnabled instead. (staticcheck) suite.Require().Equal(types.DefaultParams().DefaultSendEnabled, exportGenesis.Params.DefaultSendEnabled) suite.Require().Equal(expTotalSupply, exportGenesis.Supply) suite.Require().Subset(exportGenesis.Balances, expectedBalances) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 9779031288..d37e14ac8e 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -284,18 +284,18 @@ func (suite *KeeperTestSuite) TestSupply_SendCoins() { authKeeper.EXPECT().GetModuleAddress("").Return(nil) require.Panics(func() { - _ = keeper.SendCoinsFromModuleToModule(ctx, "", holderAcc.GetName(), initCoins) // nolint:errcheck + _ = keeper.SendCoinsFromModuleToModule(ctx, "", holderAcc.GetName(), initCoins) //nolint:errcheck }) authKeeper.EXPECT().GetModuleAddress(burnerAcc.Name).Return(burnerAcc.GetAddress()) authKeeper.EXPECT().GetModuleAccount(ctx, "").Return(nil) require.Panics(func() { - _ = keeper.SendCoinsFromModuleToModule(ctx, authtypes.Burner, "", initCoins) // nolint:errcheck + _ = keeper.SendCoinsFromModuleToModule(ctx, authtypes.Burner, "", initCoins) //nolint:errcheck }) authKeeper.EXPECT().GetModuleAddress("").Return(nil) require.Panics(func() { - _ = keeper.SendCoinsFromModuleToAccount(ctx, "", baseAcc.GetAddress(), initCoins) // nolint:errcheck + _ = keeper.SendCoinsFromModuleToAccount(ctx, "", baseAcc.GetAddress(), initCoins) //nolint:errcheck }) authKeeper.EXPECT().GetModuleAddress(holderAcc.Name).Return(holderAcc.GetAddress()) @@ -334,16 +334,16 @@ func (suite *KeeperTestSuite) TestSupply_MintCoins() { require.NoError(err) authKeeper.EXPECT().GetModuleAccount(ctx, "").Return(nil) - require.Panics(func() { _ = keeper.MintCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck + require.Panics(func() { _ = keeper.MintCoins(ctx, "", initCoins) }, "no module account") //nolint:errcheck suite.mockMintCoins(burnerAcc) - require.Panics(func() { _ = keeper.MintCoins(ctx, authtypes.Burner, initCoins) }, "invalid permission") // nolint:errcheck + require.Panics(func() { _ = keeper.MintCoins(ctx, authtypes.Burner, initCoins) }, "invalid permission") //nolint:errcheck suite.mockMintCoins(minterAcc) require.Error(keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}), "insufficient coins") authKeeper.EXPECT().GetModuleAccount(ctx, randomPerm).Return(nil) - require.Panics(func() { _ = keeper.MintCoins(ctx, randomPerm, initCoins) }) // nolint:errcheck + require.Panics(func() { _ = keeper.MintCoins(ctx, randomPerm, initCoins) }) //nolint:errcheck suite.mockMintCoins(minterAcc) require.NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) @@ -387,13 +387,13 @@ func (suite *KeeperTestSuite) TestSupply_BurnCoins() { require.NoError(err) authKeeper.EXPECT().GetModuleAccount(ctx, "").Return(nil) - require.Panics(func() { _ = keeper.BurnCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck + require.Panics(func() { _ = keeper.BurnCoins(ctx, "", initCoins) }, "no module account") //nolint:errcheck authKeeper.EXPECT().GetModuleAccount(ctx, minterAcc.Name).Return(nil) - require.Panics(func() { _ = keeper.BurnCoins(ctx, authtypes.Minter, initCoins) }, "invalid permission") // nolint:errcheck + require.Panics(func() { _ = keeper.BurnCoins(ctx, authtypes.Minter, initCoins) }, "invalid permission") //nolint:errcheck authKeeper.EXPECT().GetModuleAccount(ctx, randomPerm).Return(nil) - require.Panics(func() { _ = keeper.BurnCoins(ctx, randomPerm, supplyAfterInflation) }, "random permission") // nolint:errcheck + require.Panics(func() { _ = keeper.BurnCoins(ctx, randomPerm, supplyAfterInflation) }, "random permission") //nolint:errcheck suite.mockBurnCoins(burnerAcc) require.Error(keeper.BurnCoins(ctx, authtypes.Burner, supplyAfterInflation), "insufficient coins") @@ -1197,26 +1197,26 @@ func (suite *KeeperTestSuite) TestBalanceTrackingEvents() { for _, e := range suite.ctx.EventManager().ABCIEvents() { switch e.Type { case banktypes.EventTypeCoinBurn: - burnedCoins, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) + burnedCoins, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value) require.NoError(err) supply = supply.Sub(burnedCoins...) case banktypes.EventTypeCoinMint: - mintedCoins, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) + mintedCoins, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value) require.NoError(err) supply = supply.Add(mintedCoins...) case banktypes.EventTypeCoinSpent: - coinsSpent, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) + coinsSpent, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value) require.NoError(err) - spender, err := sdk.AccAddressFromBech32((string)(e.Attributes[0].Value)) + spender, err := sdk.AccAddressFromBech32(e.Attributes[0].Value) require.NoError(err) balances[spender.String()] = balances[spender.String()].Sub(coinsSpent...) case banktypes.EventTypeCoinReceived: - coinsRecv, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) + coinsRecv, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value) require.NoError(err) - receiver, err := sdk.AccAddressFromBech32((string)(e.Attributes[0].Value)) + receiver, err := sdk.AccAddressFromBech32(e.Attributes[0].Value) require.NoError(err) balances[receiver.String()] = balances[receiver.String()].Add(coinsRecv...) } @@ -1737,10 +1737,10 @@ func (suite *KeeperTestSuite) TestMigrator_Migrate3to4() { require.NoError(migrator.Migrate3to4(ctx)) newParams := bankKeeper.GetParams(ctx) - require.Len(newParams.SendEnabled, 0) + require.Len(newParams.SendEnabled, 0) //nolint:staticcheck // SA1019: banktypes.Params.SendEnabled is deprecated: Use bankkeeper.IsSendEnabledDenom instead. require.Equal(def, newParams.DefaultSendEnabled) - for _, se := range params.SendEnabled { + for _, se := range params.SendEnabled { //nolint:staticcheck // SA1019: banktypes.Params.SendEnabled is deprecated: Use bankkeeper.IsSendEnabledDenom instead. actual := bankKeeper.IsSendEnabledDenom(ctx, se.Denom) require.Equal(se.Enabled, actual, se.Denom) } @@ -1753,7 +1753,7 @@ func (suite *KeeperTestSuite) TestSetParams() { require := suite.Require() params := banktypes.NewParams(true) - params.SendEnabled = []*banktypes.SendEnabled{ + params.SendEnabled = []*banktypes.SendEnabled{ //nolint:staticcheck // SA1019: banktypes.Params.SendEnabled is deprecated: Use bankkeeper.IsSendEnabledDenom instead. {Denom: "paramscointrue", Enabled: true}, {Denom: "paramscoinfalse", Enabled: false}, } @@ -1762,7 +1762,7 @@ func (suite *KeeperTestSuite) TestSetParams() { suite.Run("stored params are as expected", func() { actual := bankKeeper.GetParams(ctx) require.True(actual.DefaultSendEnabled, "DefaultSendEnabled") - require.Len(actual.SendEnabled, 0, "SendEnabled") + require.Len(actual.SendEnabled, 0, "SendEnabled") //nolint:staticcheck // SA1019: banktypes.Params.SendEnabled is deprecated: Use bankkeeper.IsSendEnabledDenom instead. }) suite.Run("send enabled params converted to store", func() { diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index f1573a6c1d..95f14fe7fa 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -103,14 +103,13 @@ func (k BaseSendKeeper) GetParams(ctx sdk.Context) (params types.Params) { // SetParams sets the total set of bank parameters. // // Note: params.SendEnabled is deprecated but it should be here regardless. -// -//nolint:staticcheck + func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) error { // Normally SendEnabled is deprecated but we still support it for backwards // compatibility. Using params.Validate() would fail due to the SendEnabled // deprecation. - if len(params.SendEnabled) > 0 { - k.SetAllSendEnabled(ctx, params.SendEnabled) + if len(params.SendEnabled) > 0 { //nolint:staticcheck // SA1019: params.SendEnabled is deprecated + k.SetAllSendEnabled(ctx, params.SendEnabled) //nolint:staticcheck // SA1019: params.SendEnabled is deprecated // override params without SendEnabled params = types.NewParams(params.DefaultSendEnabled) diff --git a/x/bank/migrations/v2/store_test.go b/x/bank/migrations/v2/store_test.go index 96bd7e15e6..4cb1feadf7 100644 --- a/x/bank/migrations/v2/store_test.go +++ b/x/bank/migrations/v2/store_test.go @@ -29,8 +29,7 @@ func TestSupplyMigration(t *testing.T) { oldFooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) // to ensure the zero denom coins pruned. // Old supply was stored as a single blob under the `SupplyKey`. - var oldSupply v1bank.SupplyI - oldSupply = &types.Supply{Total: sdk.Coins{oldFooCoin, oldBarCoin, oldFooBarCoin}} + oldSupply := &types.Supply{Total: sdk.Coins{oldFooCoin, oldBarCoin, oldFooBarCoin}} oldSupplyBz, err := encCfg.Codec.MarshalInterface(oldSupply) require.NoError(t, err) store.Set(v1bank.SupplyKey, oldSupplyBz) diff --git a/x/bank/migrations/v3/store_test.go b/x/bank/migrations/v3/store_test.go index 52e9efdcd3..9325476144 100644 --- a/x/bank/migrations/v3/store_test.go +++ b/x/bank/migrations/v3/store_test.go @@ -32,7 +32,7 @@ func TestMigrateStore(t *testing.T) { ) for _, b := range balances { - bz, err := encCfg.Codec.Marshal(&b) + bz, err := encCfg.Codec.Marshal(&b) //nolint:gosec // G601: Implicit memory aliasing in for loop. require.NoError(t, err) prefixAccStore.Set([]byte(b.Denom), bz) @@ -107,7 +107,7 @@ func TestMigrateDenomMetaData(t *testing.T) { newKey := denomMetadataIter.Key() // make sure old entry is deleted - oldKey := append(newKey, newKey[0:]...) + oldKey := append(newKey, newKey[0:]...) //nolint:gocritic // append is ok here bz := denomMetadataStore.Get(oldKey) require.Nil(t, bz) diff --git a/x/bank/module.go b/x/bank/module.go index 01b7df315c..1cd522fa08 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -205,6 +205,7 @@ func init() { ) } +//nolint:revive type BankInputs struct { depinject.In @@ -218,6 +219,7 @@ type BankInputs struct { LegacySubspace exported.Subspace `optional:"true"` } +//nolint:revive type BankOutputs struct { depinject.Out diff --git a/x/bank/simulation/genesis_test.go b/x/bank/simulation/genesis_test.go index 7782b6cd79..69e1a69234 100644 --- a/x/bank/simulation/genesis_test.go +++ b/x/bank/simulation/genesis_test.go @@ -41,7 +41,7 @@ func TestRandomizedGenState(t *testing.T) { simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &bankGenesis) assert.Equal(t, true, bankGenesis.Params.GetDefaultSendEnabled(), "Params.GetDefaultSendEnabled") - assert.Len(t, bankGenesis.Params.GetSendEnabled(), 0, "Params.GetSendEnabled") + assert.Len(t, bankGenesis.Params.GetSendEnabled(), 0, "Params.GetSendEnabled") //nolint:staticcheck // SA1019: Params.GetSendEnabled is deprecated: use SendEnabled instead. if assert.Len(t, bankGenesis.Balances, 3) { assert.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", bankGenesis.Balances[2].GetAddress().String(), "Balances[2] address") assert.Equal(t, "1000stake", bankGenesis.Balances[2].GetCoins().String(), "Balances[2] coins") diff --git a/x/bank/types/genesis.go b/x/bank/types/genesis.go index e414247f3c..54d290f5ed 100644 --- a/x/bank/types/genesis.go +++ b/x/bank/types/genesis.go @@ -114,27 +114,27 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R // If the main SendEnabled slice already has entries, the Params.SendEnabled // entries are added. In case of the same demon in both, preference is given to // the existing (main GenesisState field) entry. -func (g *GenesisState) MigrateSendEnabled() { - g.SendEnabled = g.GetAllSendEnabled() - g.Params.SendEnabled = nil +func (gs *GenesisState) MigrateSendEnabled() { + gs.SendEnabled = gs.GetAllSendEnabled() + gs.Params.SendEnabled = nil } // GetAllSendEnabled returns all the SendEnabled entries from both the SendEnabled // field and the Params. If a denom has an entry in both, the entry in the // SendEnabled field takes precedence over one in Params. -func (g GenesisState) GetAllSendEnabled() []SendEnabled { - if len(g.Params.SendEnabled) == 0 { - return g.SendEnabled +func (gs GenesisState) GetAllSendEnabled() []SendEnabled { + if len(gs.Params.SendEnabled) == 0 { + return gs.SendEnabled } - rv := make([]SendEnabled, len(g.SendEnabled)) + rv := make([]SendEnabled, len(gs.SendEnabled)) knownSendEnabled := map[string]bool{} - for i, se := range g.SendEnabled { + for i, se := range gs.SendEnabled { rv[i] = se knownSendEnabled[se.Denom] = true } - for _, se := range g.Params.SendEnabled { + for _, se := range gs.Params.SendEnabled { if _, known := knownSendEnabled[se.Denom]; !known { rv = append(rv, *se) } diff --git a/x/capability/keeper/keeper_test.go b/x/capability/keeper/keeper_test.go index c859032013..db948e642a 100644 --- a/x/capability/keeper/keeper_test.go +++ b/x/capability/keeper/keeper_test.go @@ -15,8 +15,8 @@ import ( ) var ( - stakingModuleName string = "staking" - bankModuleName string = "bank" + stakingModuleName = "staking" + bankModuleName = "bank" ) type KeeperTestSuite struct { @@ -272,7 +272,7 @@ func (suite *KeeperTestSuite) TestReleaseCapability() { suite.Require().Error(sk1.ReleaseCapability(suite.ctx, nil)) } -func (suite KeeperTestSuite) TestRevertCapability() { +func (suite KeeperTestSuite) TestRevertCapability() { //nolint:govet // this is a test, we can copy locks sk := suite.keeper.ScopeToModule(bankModuleName) ms := suite.ctx.MultiStore() diff --git a/x/capability/module.go b/x/capability/module.go index 8971e9e8d4..b6cfda874b 100644 --- a/x/capability/module.go +++ b/x/capability/module.go @@ -187,6 +187,7 @@ func init() { ) } +//nolint:revive type CapabilityInputs struct { depinject.In @@ -197,6 +198,7 @@ type CapabilityInputs struct { Cdc codec.Codec } +//nolint:revive type CapabilityOutputs struct { depinject.Out diff --git a/x/capability/testutil/app_config.go b/x/capability/testutil/app_config.go index bd6bad2b58..419a5dfa1f 100644 --- a/x/capability/testutil/app_config.go +++ b/x/capability/testutil/app_config.go @@ -1,14 +1,14 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/capability" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/capability" // import capability as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/consensus/module.go b/x/consensus/module.go index 13463ac31b..c045c79945 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -137,6 +137,7 @@ func init() { ) } +//nolint:revive type ConsensusInputs struct { depinject.In @@ -145,6 +146,7 @@ type ConsensusInputs struct { Key *store.KVStoreKey } +//nolint:revive type ConsensusOutputs struct { depinject.Out diff --git a/x/crisis/module.go b/x/crisis/module.go index 0e8676e950..1ea6e0b5b0 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -191,6 +191,7 @@ func init() { ) } +//nolint:revive type CrisisInputs struct { depinject.In @@ -205,6 +206,7 @@ type CrisisInputs struct { LegacySubspace exported.Subspace } +//nolint:revive type CrisisOutputs struct { depinject.Out diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 7750beb571..f31bb37146 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -957,7 +957,7 @@ func Test100PercentCommissionReward(t *testing.T) { // allocate some more rewards distrKeeper.AllocateTokensToValidator(ctx, val, tokens) - rewards, err := distrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(addr), valAddr) + rewards, err := distrKeeper.WithdrawDelegationRewards(ctx, addr, valAddr) require.NoError(t, err) zeroRewards := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, math.ZeroInt())} diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index 7392d1c5d7..66c43c5cb8 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -22,7 +22,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/distribution/keeper" "github.com/cosmos/cosmos-sdk/x/distribution/simulation" "github.com/cosmos/cosmos-sdk/x/distribution/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -108,7 +107,7 @@ func (suite *SimTestSuite) TestSimulateMsgWithdrawDelegatorReward() { delegator := accounts[1] delegation := stakingtypes.NewDelegation(delegator.Address, validator0.GetOperator(), issuedShares) suite.stakingKeeper.SetDelegation(suite.ctx, delegation) - suite.distrKeeper.SetDelegatorStartingInfo(suite.ctx, validator0.GetOperator(), delegator.Address, distrtypes.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200)) + suite.distrKeeper.SetDelegatorStartingInfo(suite.ctx, validator0.GetOperator(), delegator.Address, types.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200)) suite.setupValidatorRewards(validator0.GetOperator()) @@ -306,10 +305,10 @@ func (suite *SimTestSuite) getTestingValidator(accounts []simtypes.Account, comm func (suite *SimTestSuite) setupValidatorRewards(valAddress sdk.ValAddress) { decCoins := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyOneDec())} - historicalRewards := distrtypes.NewValidatorHistoricalRewards(decCoins, 2) + historicalRewards := types.NewValidatorHistoricalRewards(decCoins, 2) suite.distrKeeper.SetValidatorHistoricalRewards(suite.ctx, valAddress, 2, historicalRewards) // setup current revards - currentRewards := distrtypes.NewValidatorCurrentRewards(decCoins, 3) + currentRewards := types.NewValidatorCurrentRewards(decCoins, 3) suite.distrKeeper.SetValidatorCurrentRewards(suite.ctx, valAddress, currentRewards) } diff --git a/x/distribution/testutil/app_config.go b/x/distribution/testutil/app_config.go index d35022f9cc..e131439246 100644 --- a/x/distribution/testutil/app_config.go +++ b/x/distribution/testutil/app_config.go @@ -1,15 +1,15 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/distribution" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/distribution" // import distribution as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/mint" // import mint as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/distribution/types/common_test.go b/x/distribution/types/common_test.go index 44461f07ed..fd74434eee 100644 --- a/x/distribution/types/common_test.go +++ b/x/distribution/types/common_test.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// nolint:deadcode,varcheck var ( delPk1 = ed25519.GenPrivKey().PubKey() delPk2 = ed25519.GenPrivKey().PubKey() diff --git a/x/distribution/types/query.pb.go b/x/distribution/types/query.pb.go index 0112b6cb02..25c11551bc 100644 --- a/x/distribution/types/query.pb.go +++ b/x/distribution/types/query.pb.go @@ -1086,7 +1086,7 @@ type QueryClient interface { ValidatorSlashes(ctx context.Context, in *QueryValidatorSlashesRequest, opts ...grpc.CallOption) (*QueryValidatorSlashesResponse, error) // DelegationRewards queries the total rewards accrued by a delegation. DelegationRewards(ctx context.Context, in *QueryDelegationRewardsRequest, opts ...grpc.CallOption) (*QueryDelegationRewardsResponse, error) - // DelegationTotalRewards queries the total rewards accrued by a each + // DelegationTotalRewards queries the total rewards accrued by each // validator. DelegationTotalRewards(ctx context.Context, in *QueryDelegationTotalRewardsRequest, opts ...grpc.CallOption) (*QueryDelegationTotalRewardsResponse, error) // DelegatorValidators queries the validators of a delegator. @@ -1209,7 +1209,7 @@ type QueryServer interface { ValidatorSlashes(context.Context, *QueryValidatorSlashesRequest) (*QueryValidatorSlashesResponse, error) // DelegationRewards queries the total rewards accrued by a delegation. DelegationRewards(context.Context, *QueryDelegationRewardsRequest) (*QueryDelegationRewardsResponse, error) - // DelegationTotalRewards queries the total rewards accrued by a each + // DelegationTotalRewards queries the total rewards accrued by each // validator. DelegationTotalRewards(context.Context, *QueryDelegationTotalRewardsRequest) (*QueryDelegationTotalRewardsResponse, error) // DelegatorValidators queries the validators of a delegator. diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index a2ddefb1eb..d66d5c0285 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -34,10 +34,6 @@ var ( sdk.ValAddress(pubkeys[1].Address()), sdk.ValAddress(pubkeys[2].Address()), } - - // The default power validators are initialized to have within tests - initAmt = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) - initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) ) func newPubKey(pk string) (res cryptotypes.PubKey) { diff --git a/x/evidence/module.go b/x/evidence/module.go index 225c53c4d2..d5a8c2cb0b 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -202,6 +202,7 @@ func init() { ) } +//nolint:revive type EvidenceInputs struct { depinject.In @@ -212,6 +213,7 @@ type EvidenceInputs struct { SlashingKeeper types.SlashingKeeper } +//nolint:revive type EvidenceOutputs struct { depinject.Out diff --git a/x/evidence/testutil/app_config.go b/x/evidence/testutil/app_config.go index b66008b1ee..6d4ea068e7 100644 --- a/x/evidence/testutil/app_config.go +++ b/x/evidence/testutil/app_config.go @@ -1,15 +1,15 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/evidence" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/slashing" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/evidence" // import evidence as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/slashing" // import slashing as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/feegrant/client/cli/tx_test.go b/x/feegrant/client/cli/tx_test.go index 021d5819ed..e6f44b9176 100644 --- a/x/feegrant/client/cli/tx_test.go +++ b/x/feegrant/client/cli/tx_test.go @@ -613,9 +613,9 @@ func (s *CLITestSuite) msgSubmitLegacyProposal(clientCtx client.Context, from, t } args := append([]string{ - fmt.Sprintf("--%s=%s", govcli.FlagTitle, title), - fmt.Sprintf("--%s=%s", govcli.FlagDescription, description), - fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType), + fmt.Sprintf("--%s=%s", govcli.FlagTitle, title), //nolint:staticcheck // SA1019: govcli.FlagTitle is deprecated: use FlagTitle instead + fmt.Sprintf("--%s=%s", govcli.FlagDescription, description), //nolint:staticcheck // SA1019: govcli.FlagDescription is deprecated: use FlagDescription instead + fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType), //nolint:staticcheck // SA1019: govcli.FlagProposalType is deprecated: use FlagProposalType instead fmt.Sprintf("--%s=%s", flags.FlagFrom, from), }, commonArgs...) diff --git a/x/feegrant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go index 055b99db86..fd794a7837 100644 --- a/x/feegrant/simulation/decoder_test.go +++ b/x/feegrant/simulation/decoder_test.go @@ -38,7 +38,7 @@ func TestDecodeStore(t *testing.T) { kvPairs := kv.Pairs{ Pairs: []kv.Pair{ - {Key: []byte(feegrant.FeeAllowanceKeyPrefix), Value: grantBz}, + {Key: feegrant.FeeAllowanceKeyPrefix, Value: grantBz}, {Key: []byte{0x99}, Value: []byte{0x99}}, }, } diff --git a/x/feegrant/testutil/app_config.go b/x/feegrant/testutil/app_config.go index ee94a7a841..186c218a94 100644 --- a/x/feegrant/testutil/app_config.go +++ b/x/feegrant/testutil/app_config.go @@ -1,16 +1,16 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/feegrant/module" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" // import auth vesting as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/feegrant/module" // import feegrant as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/mint" // import mint as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index b933bb45dd..20b3d07a19 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -90,9 +90,7 @@ func (suite *GenTxTestSuite) setAccountBalance(balances []banktypes.Balance) jso }, Supply: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, } - for _, balance := range balances { - bankGenesisState.Balances = append(bankGenesisState.Balances, balance) - } + bankGenesisState.Balances = append(bankGenesisState.Balances, balances...) for _, balance := range bankGenesisState.Balances { bankGenesisState.Supply.Add(balance.Coins...) } diff --git a/x/genutil/module.go b/x/genutil/module.go index a4f660ee42..4f29c0f5e8 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -132,6 +132,9 @@ func init() { ) } +// GenutilInputs defines the inputs needed for the genutil module. +// +//nolint:revive type GenutilInputs struct { depinject.In diff --git a/x/gov/client/cli/tx_test.go b/x/gov/client/cli/tx_test.go index bd16204a07..35fde2a3da 100644 --- a/x/gov/client/cli/tx_test.go +++ b/x/gov/client/cli/tx_test.go @@ -200,7 +200,7 @@ func (s *CLITestSuite) TestNewCmdSubmitLegacyProposal() { { "invalid proposal (file)", []string{ - fmt.Sprintf("--%s=%s", cli.FlagProposal, invalidPropFile.Name()), //nolint:staticcheck // we are intentionally using a deprecated flag here. + fmt.Sprintf("--%s=%s", cli.FlagProposal, invalidPropFile.Name()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val[0].Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(10))).String()), @@ -210,8 +210,8 @@ func (s *CLITestSuite) TestNewCmdSubmitLegacyProposal() { { "invalid proposal", []string{ - 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='Where is the title!?'", cli.FlagDescription), + fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin("stake", sdk.NewInt(5431)).String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val[0].Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), @@ -221,7 +221,7 @@ func (s *CLITestSuite) TestNewCmdSubmitLegacyProposal() { }, { "valid transaction (file)", - //nolint:staticcheck // we are intentionally using a deprecated flag here. + []string{ fmt.Sprintf("--%s=%s", cli.FlagProposal, validPropFile.Name()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val[0].Address.String()), @@ -234,9 +234,9 @@ func (s *CLITestSuite) TestNewCmdSubmitLegacyProposal() { { "valid transaction", []string{ - fmt.Sprintf("--%s='Text Proposal'", cli.FlagTitle), //nolint:staticcheck // we are intentionally using a deprecated flag here. - 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='Text Proposal'", cli.FlagTitle), + fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription), + fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin("stake", sdk.NewInt(5431)).String()), fmt.Sprintf("--%s=%s", flags.FlagFrom, val[0].Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index 03c77a3e07..2f057d7922 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -34,7 +34,7 @@ func TestDeposits(t *testing.T) { require.True(t, sdk.NewCoins(proposal.TotalDeposit...).IsEqual(sdk.NewCoins())) // Check no deposits at beginning - deposit, found := govKeeper.GetDeposit(ctx, proposalID, TestAddrs[1]) + _, found := govKeeper.GetDeposit(ctx, proposalID, TestAddrs[1]) require.False(t, found) proposal, ok := govKeeper.GetProposal(ctx, proposalID) require.True(t, ok) @@ -44,7 +44,7 @@ func TestDeposits(t *testing.T) { votingStarted, err := govKeeper.AddDeposit(ctx, proposalID, TestAddrs[0], fourStake) require.NoError(t, err) require.False(t, votingStarted) - deposit, found = govKeeper.GetDeposit(ctx, proposalID, TestAddrs[0]) + deposit, found := govKeeper.GetDeposit(ctx, proposalID, TestAddrs[0]) require.True(t, found) require.Equal(t, fourStake, sdk.NewCoins(deposit.Amount...)) require.Equal(t, TestAddrs[0].String(), deposit.Depositor) diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index 56011bbbf5..059b921ff2 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -805,7 +805,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() { "deposit params request", func() { req = &v1.QueryParamsRequest{ParamsType: v1.ParamDeposit} - depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) + depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) //nolint:staticcheck // SA1019: params.MinDeposit is deprecated: Use MinInitialDeposit instead. expRes = &v1.QueryParamsResponse{ DepositParams: &depositParams, } @@ -816,7 +816,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() { "voting params request", func() { req = &v1.QueryParamsRequest{ParamsType: v1.ParamVoting} - votingParams := v1.NewVotingParams(params.VotingPeriod) + votingParams := v1.NewVotingParams(params.VotingPeriod) //nolint:staticcheck // SA1019: params.VotingPeriod is deprecated: Use VotingPeriod instead. expRes = &v1.QueryParamsResponse{ VotingParams: &votingParams, } @@ -827,7 +827,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() { "tally params request", func() { req = &v1.QueryParamsRequest{ParamsType: v1.ParamTallying} - tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) + tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) //nolint:staticcheck // SA1019: params.Quorum is deprecated: Use Quorum instead. expRes = &v1.QueryParamsResponse{ TallyParams: &tallyParams, } @@ -852,9 +852,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() { if testCase.expPass { suite.Require().NoError(err) - suite.Require().Equal(expRes.GetDepositParams(), params.GetDepositParams()) - suite.Require().Equal(expRes.GetVotingParams(), params.GetVotingParams()) - suite.Require().Equal(expRes.GetTallyParams(), params.GetTallyParams()) + suite.Require().Equal(expRes.GetDepositParams(), params.GetDepositParams()) //nolint:staticcheck // SA1019: params.MinDeposit is deprecated: Use MinInitialDeposit instead. + suite.Require().Equal(expRes.GetVotingParams(), params.GetVotingParams()) //nolint:staticcheck // SA1019: params.VotingPeriod is deprecated: Use VotingPeriod instead. + suite.Require().Equal(expRes.GetTallyParams(), params.GetTallyParams()) //nolint:staticcheck // SA1019: params.Quorum is deprecated: Use Quorum instead. } else { suite.Require().Error(err) suite.Require().Nil(params) diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 6810eb2d1e..15ee1db46e 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -90,80 +90,80 @@ func NewKeeper( } // Hooks gets the hooks for governance *Keeper { -func (keeper *Keeper) Hooks() types.GovHooks { - if keeper.hooks == nil { +func (k *Keeper) Hooks() types.GovHooks { + if k.hooks == nil { // return a no-op implementation if no hooks are set return types.MultiGovHooks{} } - return keeper.hooks + return k.hooks } // SetHooks sets the hooks for governance -func (keeper *Keeper) SetHooks(gh types.GovHooks) *Keeper { - if keeper.hooks != nil { +func (k *Keeper) SetHooks(gh types.GovHooks) *Keeper { + if k.hooks != nil { panic("cannot set governance hooks twice") } - keeper.hooks = gh + k.hooks = gh - return keeper + return k } // SetLegacyRouter sets the legacy router for governance -func (keeper *Keeper) SetLegacyRouter(router v1beta1.Router) { +func (k *Keeper) SetLegacyRouter(router v1beta1.Router) { // It is vital to seal the governance proposal router here as to not allow // further handlers to be registered after the keeper is created since this // could create invalid or non-deterministic behavior. router.Seal() - keeper.legacyRouter = router + k.legacyRouter = router } // Logger returns a module-specific logger. -func (keeper Keeper) Logger(ctx sdk.Context) log.Logger { +func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } // Router returns the gov keeper's router -func (keeper Keeper) Router() *baseapp.MsgServiceRouter { - return keeper.router +func (k Keeper) Router() *baseapp.MsgServiceRouter { + return k.router } // LegacyRouter returns the gov keeper's legacy router -func (keeper Keeper) LegacyRouter() v1beta1.Router { - return keeper.legacyRouter +func (k Keeper) LegacyRouter() v1beta1.Router { + return k.legacyRouter } // GetGovernanceAccount returns the governance ModuleAccount -func (keeper Keeper) GetGovernanceAccount(ctx sdk.Context) authtypes.ModuleAccountI { - return keeper.authKeeper.GetModuleAccount(ctx, types.ModuleName) +func (k Keeper) GetGovernanceAccount(ctx sdk.Context) authtypes.ModuleAccountI { + return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) } // ProposalQueues // InsertActiveProposalQueue inserts a proposalID into the active proposal queue at endTime -func (keeper Keeper) InsertActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) { - store := ctx.KVStore(keeper.storeKey) +func (k Keeper) InsertActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) { + store := ctx.KVStore(k.storeKey) bz := types.GetProposalIDBytes(proposalID) store.Set(types.ActiveProposalQueueKey(proposalID, endTime), bz) } // RemoveFromActiveProposalQueue removes a proposalID from the Active Proposal Queue -func (keeper Keeper) RemoveFromActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) { - store := ctx.KVStore(keeper.storeKey) +func (k Keeper) RemoveFromActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) { + store := ctx.KVStore(k.storeKey) store.Delete(types.ActiveProposalQueueKey(proposalID, endTime)) } // InsertInactiveProposalQueue inserts a proposalID into the inactive proposal queue at endTime -func (keeper Keeper) InsertInactiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) { - store := ctx.KVStore(keeper.storeKey) +func (k Keeper) InsertInactiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) { + store := ctx.KVStore(k.storeKey) bz := types.GetProposalIDBytes(proposalID) store.Set(types.InactiveProposalQueueKey(proposalID, endTime), bz) } // RemoveFromInactiveProposalQueue removes a proposalID from the Inactive Proposal Queue -func (keeper Keeper) RemoveFromInactiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) { - store := ctx.KVStore(keeper.storeKey) +func (k Keeper) RemoveFromInactiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) { + store := ctx.KVStore(k.storeKey) store.Delete(types.InactiveProposalQueueKey(proposalID, endTime)) } @@ -171,13 +171,13 @@ func (keeper Keeper) RemoveFromInactiveProposalQueue(ctx sdk.Context, proposalID // IterateActiveProposalsQueue iterates over the proposals in the active proposal queue // and performs a callback function -func (keeper Keeper) IterateActiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal v1.Proposal) (stop bool)) { - iterator := keeper.ActiveProposalQueueIterator(ctx, endTime) +func (k Keeper) IterateActiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal v1.Proposal) (stop bool)) { + iterator := k.ActiveProposalQueueIterator(ctx, endTime) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { proposalID, _ := types.SplitActiveProposalQueueKey(iterator.Key()) - proposal, found := keeper.GetProposal(ctx, proposalID) + proposal, found := k.GetProposal(ctx, proposalID) if !found { panic(fmt.Sprintf("proposal %d does not exist", proposalID)) } @@ -190,13 +190,13 @@ func (keeper Keeper) IterateActiveProposalsQueue(ctx sdk.Context, endTime time.T // IterateInactiveProposalsQueue iterates over the proposals in the inactive proposal queue // and performs a callback function -func (keeper Keeper) IterateInactiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal v1.Proposal) (stop bool)) { - iterator := keeper.InactiveProposalQueueIterator(ctx, endTime) +func (k Keeper) IterateInactiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal v1.Proposal) (stop bool)) { + iterator := k.InactiveProposalQueueIterator(ctx, endTime) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { proposalID, _ := types.SplitInactiveProposalQueueKey(iterator.Key()) - proposal, found := keeper.GetProposal(ctx, proposalID) + proposal, found := k.GetProposal(ctx, proposalID) if !found { panic(fmt.Sprintf("proposal %d does not exist", proposalID)) } @@ -208,21 +208,21 @@ func (keeper Keeper) IterateInactiveProposalsQueue(ctx sdk.Context, endTime time } // ActiveProposalQueueIterator returns an sdk.Iterator for all the proposals in the Active Queue that expire by endTime -func (keeper Keeper) ActiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { - store := ctx.KVStore(keeper.storeKey) +func (k Keeper) ActiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { + store := ctx.KVStore(k.storeKey) return store.Iterator(types.ActiveProposalQueuePrefix, sdk.PrefixEndBytes(types.ActiveProposalByTimeKey(endTime))) } // InactiveProposalQueueIterator returns an sdk.Iterator for all the proposals in the Inactive Queue that expire by endTime -func (keeper Keeper) InactiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { - store := ctx.KVStore(keeper.storeKey) +func (k Keeper) InactiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { + store := ctx.KVStore(k.storeKey) return store.Iterator(types.InactiveProposalQueuePrefix, sdk.PrefixEndBytes(types.InactiveProposalByTimeKey(endTime))) } // assertMetadataLength returns an error if given metadata length // is greater than a pre-defined MaxMetadataLen. -func (keeper Keeper) assertMetadataLength(metadata string) error { - if metadata != "" && uint64(len(metadata)) > keeper.config.MaxMetadataLen { +func (k Keeper) assertMetadataLength(metadata string) error { + if metadata != "" && uint64(len(metadata)) > k.config.MaxMetadataLen { return types.ErrMetadataTooLong.Wrapf("got metadata with length %d", len(metadata)) } return nil diff --git a/x/gov/keeper/keeper_test.go b/x/gov/keeper/keeper_test.go index c064e3abd6..abe9ac7920 100644 --- a/x/gov/keeper/keeper_test.go +++ b/x/gov/keeper/keeper_test.go @@ -71,7 +71,7 @@ func (suite *KeeperTestSuite) reset() { } func TestIncrementProposalNumber(t *testing.T) { - govKeeper, _, _, _, _, ctx := setupGovKeeper(t) + govKeeper, _, _, _, _, ctx := setupGovKeeper(t) //nolint:dogsled tp := TestProposal _, err := govKeeper.SubmitProposal(ctx, tp, "") @@ -91,7 +91,7 @@ func TestIncrementProposalNumber(t *testing.T) { } func TestProposalQueues(t *testing.T) { - govKeeper, _, _, _, _, ctx := setupGovKeeper(t) + govKeeper, _, _, _, _, ctx := setupGovKeeper(t) //nolint:dogsled // create test proposals tp := TestProposal diff --git a/x/gov/keeper/msg_server_test.go b/x/gov/keeper/msg_server_test.go index 160e245724..b8408c9214 100644 --- a/x/gov/keeper/msg_server_test.go +++ b/x/gov/keeper/msg_server_test.go @@ -145,7 +145,7 @@ func (suite *KeeperTestSuite) TestVoteReq() { res, err := suite.msgSrvr.SubmitProposal(suite.ctx, msg) suite.Require().NoError(err) suite.Require().NotNil(res.ProposalId) - proposalId := res.ProposalId + proposalID := res.ProposalId cases := map[string]struct { preRun func() uint64 @@ -178,7 +178,7 @@ func (suite *KeeperTestSuite) TestVoteReq() { }, "metadata too long": { preRun: func() uint64 { - return proposalId + return proposalID }, option: v1.VoteOption_VOTE_OPTION_YES, voter: proposer, @@ -188,7 +188,7 @@ func (suite *KeeperTestSuite) TestVoteReq() { }, "voter error": { preRun: func() uint64 { - return proposalId + return proposalID }, option: v1.VoteOption_VOTE_OPTION_YES, voter: sdk.AccAddress(strings.Repeat("a", 300)), @@ -220,8 +220,8 @@ func (suite *KeeperTestSuite) TestVoteReq() { for name, tc := range cases { suite.Run(name, func() { - pId := tc.preRun() - voteReq := v1.NewMsgVote(tc.voter, pId, tc.option, tc.metadata) + pID := tc.preRun() + voteReq := v1.NewMsgVote(tc.voter, pID, tc.option, tc.metadata) _, err := suite.msgSrvr.Vote(suite.ctx, voteReq) if tc.expErr { suite.Require().Error(err) @@ -258,7 +258,7 @@ func (suite *KeeperTestSuite) TestVoteWeightedReq() { res, err := suite.msgSrvr.SubmitProposal(suite.ctx, msg) suite.Require().NoError(err) suite.Require().NotNil(res.ProposalId) - proposalId := res.ProposalId + proposalID := res.ProposalId cases := map[string]struct { preRun func() uint64 @@ -292,7 +292,7 @@ func (suite *KeeperTestSuite) TestVoteWeightedReq() { }, "metadata too long": { preRun: func() uint64 { - return proposalId + return proposalID }, option: v1.VoteOption_VOTE_OPTION_YES, voter: proposer, @@ -302,7 +302,7 @@ func (suite *KeeperTestSuite) TestVoteWeightedReq() { }, "voter error": { preRun: func() uint64 { - return proposalId + return proposalID }, option: v1.VoteOption_VOTE_OPTION_YES, voter: sdk.AccAddress(strings.Repeat("a", 300)), @@ -334,8 +334,8 @@ func (suite *KeeperTestSuite) TestVoteWeightedReq() { for name, tc := range cases { suite.Run(name, func() { - pId := tc.preRun() - voteReq := v1.NewMsgVoteWeighted(tc.voter, pId, v1.NewNonSplitVoteOption(tc.option), tc.metadata) + pID := tc.preRun() + voteReq := v1.NewMsgVoteWeighted(tc.voter, pID, v1.NewNonSplitVoteOption(tc.option), tc.metadata) _, err := suite.msgSrvr.VoteWeighted(suite.ctx, voteReq) if tc.expErr { suite.Require().Error(err) @@ -371,12 +371,12 @@ func (suite *KeeperTestSuite) TestDepositReq() { res, err := suite.msgSrvr.SubmitProposal(suite.ctx, msg) suite.Require().NoError(err) suite.Require().NotNil(res.ProposalId) - pId := res.ProposalId + pID := res.ProposalId cases := map[string]struct { preRun func() uint64 expErr bool - proposalId uint64 + proposalID uint64 depositor sdk.AccAddress deposit sdk.Coins options v1.WeightedVoteOptions @@ -392,7 +392,7 @@ func (suite *KeeperTestSuite) TestDepositReq() { }, "all good": { preRun: func() uint64 { - return pId + return pID }, depositor: proposer, deposit: minDeposit, @@ -403,8 +403,8 @@ func (suite *KeeperTestSuite) TestDepositReq() { for name, tc := range cases { suite.Run(name, func() { - proposalId := tc.preRun() - depositReq := v1.NewMsgDeposit(tc.depositor, proposalId, tc.deposit) + proposalID := tc.preRun() + depositReq := v1.NewMsgDeposit(tc.depositor, proposalID, tc.deposit) _, err := suite.msgSrvr.Deposit(suite.ctx, depositReq) if tc.expErr { suite.Require().Error(err) @@ -489,7 +489,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgVote() { res, err := suite.msgSrvr.SubmitProposal(suite.ctx, msg) suite.Require().NoError(err) suite.Require().NotNil(res.ProposalId) - proposalId := res.ProposalId + proposalID := res.ProposalId cases := map[string]struct { preRun func() uint64 @@ -522,7 +522,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgVote() { }, "voter error": { preRun: func() uint64 { - return proposalId + return proposalID }, option: v1beta1.OptionYes, voter: sdk.AccAddress(strings.Repeat("a", 300)), @@ -554,8 +554,8 @@ func (suite *KeeperTestSuite) TestLegacyMsgVote() { for name, tc := range cases { suite.Run(name, func() { - pId := tc.preRun() - voteReq := v1beta1.NewMsgVote(tc.voter, pId, tc.option) + pID := tc.preRun() + voteReq := v1beta1.NewMsgVote(tc.voter, pID, tc.option) _, err := suite.legacyMsgSrvr.Vote(suite.ctx, voteReq) if tc.expErr { suite.Require().Error(err) @@ -592,7 +592,7 @@ func (suite *KeeperTestSuite) TestLegacyVoteWeighted() { res, err := suite.msgSrvr.SubmitProposal(suite.ctx, msg) suite.Require().NoError(err) suite.Require().NotNil(res.ProposalId) - proposalId := res.ProposalId + proposalID := res.ProposalId cases := map[string]struct { preRun func() uint64 @@ -626,7 +626,7 @@ func (suite *KeeperTestSuite) TestLegacyVoteWeighted() { }, "voter error": { preRun: func() uint64 { - return proposalId + return proposalID }, option: v1beta1.OptionYes, voter: sdk.AccAddress(strings.Repeat("a", 300)), @@ -658,8 +658,8 @@ func (suite *KeeperTestSuite) TestLegacyVoteWeighted() { for name, tc := range cases { suite.Run(name, func() { - pId := tc.preRun() - voteReq := v1beta1.NewMsgVoteWeighted(tc.voter, pId, v1beta1.NewNonSplitVoteOption(v1beta1.VoteOption(tc.option))) + pID := tc.preRun() + voteReq := v1beta1.NewMsgVoteWeighted(tc.voter, pID, v1beta1.NewNonSplitVoteOption(tc.option)) _, err := suite.legacyMsgSrvr.VoteWeighted(suite.ctx, voteReq) if tc.expErr { suite.Require().Error(err) @@ -695,12 +695,12 @@ func (suite *KeeperTestSuite) TestLegacyMsgDeposit() { res, err := suite.msgSrvr.SubmitProposal(suite.ctx, msg) suite.Require().NoError(err) suite.Require().NotNil(res.ProposalId) - pId := res.ProposalId + pID := res.ProposalId cases := map[string]struct { preRun func() uint64 expErr bool - proposalId uint64 + proposalID uint64 depositor sdk.AccAddress deposit sdk.Coins options v1beta1.WeightedVoteOptions @@ -716,7 +716,7 @@ func (suite *KeeperTestSuite) TestLegacyMsgDeposit() { }, "all good": { preRun: func() uint64 { - return pId + return pID }, depositor: proposer, deposit: minDeposit, @@ -727,8 +727,8 @@ func (suite *KeeperTestSuite) TestLegacyMsgDeposit() { for name, tc := range cases { suite.Run(name, func() { - proposalId := tc.preRun() - depositReq := v1beta1.NewMsgDeposit(tc.depositor, proposalId, tc.deposit) + proposalID := tc.preRun() + depositReq := v1beta1.NewMsgDeposit(tc.depositor, proposalID, tc.deposit) _, err := suite.legacyMsgSrvr.Deposit(suite.ctx, depositReq) if tc.expErr { suite.Require().Error(err) @@ -833,7 +833,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() { name: "invalid quorum", input: func() *v1.MsgUpdateParams { params1 := params - params1.Quorum = "abc" + params1.Quorum = "abc" //nolint:goconst return &v1.MsgUpdateParams{ Authority: authority, @@ -847,7 +847,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() { name: "negative quorum", input: func() *v1.MsgUpdateParams { params1 := params - params1.Quorum = "-0.1" + params1.Quorum = "-0.1" //nolint:goconst return &v1.MsgUpdateParams{ Authority: authority, diff --git a/x/gov/migrations/v3/convert_test.go b/x/gov/migrations/v3/convert_test.go index fcb45a0746..5196a8f33b 100644 --- a/x/gov/migrations/v3/convert_test.go +++ b/x/gov/migrations/v3/convert_test.go @@ -46,6 +46,7 @@ func TestConvertToLegacyProposal(t *testing.T) { for name, tc := range testCases { t.Run(name, func(t *testing.T) { + tc := tc proposal.FinalTallyResult = &tc.tallyResult v1beta1Proposal, err := v3.ConvertToLegacyProposal(proposal) if tc.expErr { diff --git a/x/gov/module.go b/x/gov/module.go index 5f67fa1236..d49c3cea89 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -160,6 +160,7 @@ func init() { appmodule.Invoke(InvokeAddRoutes, InvokeSetHooks)) } +//nolint:revive type GovInputs struct { depinject.In @@ -177,6 +178,7 @@ type GovInputs struct { LegacySubspace govtypes.ParamSubspace } +//nolint:revive type GovOutputs struct { depinject.Out @@ -186,9 +188,9 @@ type GovOutputs struct { } func ProvideModule(in GovInputs) GovOutputs { - kConfig := govtypes.DefaultConfig() + defaultConfig := govtypes.DefaultConfig() if in.Config.MaxMetadataLen != 0 { - kConfig.MaxMetadataLen = in.Config.MaxMetadataLen + defaultConfig.MaxMetadataLen = in.Config.MaxMetadataLen } // default to governance authority if not provided @@ -204,7 +206,7 @@ func ProvideModule(in GovInputs) GovOutputs { in.BankKeeper, in.StakingKeeper, in.MsgServiceRouter, - kConfig, + defaultConfig, authority.String(), ) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.LegacySubspace) diff --git a/x/gov/types/metadata.go b/x/gov/types/metadata.go index 8b7b961f22..1d4669b96d 100644 --- a/x/gov/types/metadata.go +++ b/x/gov/types/metadata.go @@ -7,6 +7,6 @@ type ProposalMetadata struct { Authors string `json:"authors"` Summary string `json:"summary"` Details string `json:"details"` - ProposalForumUrl string `json:"proposal_forum_url"` // named 'Url' instead of 'URL' for avoiding the camel case split + ProposalForumUrl string `json:"proposal_forum_url"` //nolint:revive // named 'Url' instead of 'URL' for avoiding the camel case split VoteOptionContext string `json:"vote_option_context"` } diff --git a/x/gov/types/v1/msgs_test.go b/x/gov/types/v1/msgs_test.go index 4ea6f96b1c..0bb2ce924c 100644 --- a/x/gov/types/v1/msgs_test.go +++ b/x/gov/types/v1/msgs_test.go @@ -62,7 +62,7 @@ func TestMsgDeposit(t *testing.T) { // test ValidateBasic for MsgVote func TestMsgVote(t *testing.T) { - metadata := "metadata" + metadata := "metadata" //nolint:goconst tests := []struct { proposalID uint64 voterAddr sdk.AccAddress diff --git a/x/group/expected_keepers.go b/x/group/expected_keepers.go index d80500efc9..f8677fc3c2 100644 --- a/x/group/expected_keepers.go +++ b/x/group/expected_keepers.go @@ -14,7 +14,8 @@ type AccountKeeper interface { // SetAccount sets an account in the store. SetAccount(sdk.Context, authtypes.AccountI) - // RemoveAccount removes an account in the store. + + // RemoveAccount Remove an account in the store. RemoveAccount(ctx sdk.Context, acc authtypes.AccountI) } diff --git a/x/group/internal/math/dec_test.go b/x/group/internal/math/dec_test.go index c524716934..bc29404217 100644 --- a/x/group/internal/math/dec_test.go +++ b/x/group/internal/math/dec_test.go @@ -28,7 +28,7 @@ func TestDec(t *testing.T) { t.Run("TestSubAdd", rapid.MakeCheck(testSubAdd)) t.Run("TestAddSub", rapid.MakeCheck(testAddSub)) - // Properties about comparision and equality + // Properties about comparison and equality t.Run("TestCmpInverse", rapid.MakeCheck(testCmpInverse)) t.Run("TestEqualCommutative", rapid.MakeCheck(testEqualCommutative)) @@ -258,7 +258,7 @@ func testIsNegative(t *rapid.T) { require.Equal(t, f < 0, dec.IsNegative()) } -func floatDecimalPlaces(t *rapid.T, f float64) uint32 { +func floatDecimalPlaces(t *rapid.T, f float64) uint32 { //nolint:unused reScientific := regexp.MustCompile(`^\-?(?:[[:digit:]]+(?:\.([[:digit:]]+))?|\.([[:digit:]]+))(?:e?(?:\+?([[:digit:]]+)|(-[[:digit:]]+)))?$`) fStr := fmt.Sprintf("%g", f) matches := reScientific.FindAllStringSubmatch(fStr, 1) @@ -291,7 +291,7 @@ func floatDecimalPlaces(t *rapid.T, f float64) uint32 { // Subtract exponent from base and check if negative if res := basePlaces - exp; res <= 0 { return 0 - } else { + } else { //nolint:revive return uint32(res) } } diff --git a/x/group/internal/orm/auto_uint64_test.go b/x/group/internal/orm/auto_uint64_test.go index 529fce314e..345a846509 100644 --- a/x/group/internal/orm/auto_uint64_test.go +++ b/x/group/internal/orm/auto_uint64_test.go @@ -41,6 +41,7 @@ func TestAutoUInt64PrefixScan(t *testing.T) { Metadata: metadata, } for _, g := range []testdata.TableModel{t1, t2, t3} { + g := g _, err := tb.Create(store, &g) require.NoError(t, err) } @@ -49,7 +50,7 @@ func TestAutoUInt64PrefixScan(t *testing.T) { start, end uint64 expResult []testdata.TableModel expRowIDs []RowID - expError *sdkerrors.Error + expError *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package method func(store sdk.KVStore, start uint64, end uint64) (Iterator, error) }{ "first element": { diff --git a/x/group/internal/orm/example_test.go b/x/group/internal/orm/example_test.go index d182efeb03..4cc422e02d 100644 --- a/x/group/internal/orm/example_test.go +++ b/x/group/internal/orm/example_test.go @@ -15,13 +15,13 @@ type TestKeeper struct { } var ( - AutoUInt64TablePrefix [2]byte = [2]byte{0x0} - PrimaryKeyTablePrefix [2]byte = [2]byte{0x1} - AutoUInt64TableSeqPrefix byte = 0x2 - AutoUInt64TableModelByMetadataPrefix byte = 0x4 - PrimaryKeyTableModelByNamePrefix byte = 0x5 - PrimaryKeyTableModelByNumberPrefix byte = 0x6 - PrimaryKeyTableModelByMetadataPrefix byte = 0x7 + AutoUInt64TablePrefix = [2]byte{0x0} + PrimaryKeyTablePrefix = [2]byte{0x1} + AutoUInt64TableSeqPrefix byte = 0x2 + AutoUInt64TableModelByMetadataPrefix byte = 0x4 + PrimaryKeyTableModelByNamePrefix byte = 0x5 + PrimaryKeyTableModelByNumberPrefix byte = 0x6 + PrimaryKeyTableModelByMetadataPrefix byte = 0x7 ) func NewTestKeeper(cdc codec.Codec) TestKeeper { diff --git a/x/group/internal/orm/index_property_test.go b/x/group/internal/orm/index_property_test.go index e48de3c122..4c42bceb2f 100644 --- a/x/group/internal/orm/index_property_test.go +++ b/x/group/internal/orm/index_property_test.go @@ -46,7 +46,7 @@ func TestPrefixRangeProperty(t *testing.T) { // index, one greater at overflow and 0 from // then on for i, b := range start { - if i < overflowIndex { + if i < overflowIndex { //nolint:gocritic // ifElseChain: rewrite if-else to switch statement require.Equal(t, b, end[i]) } else if i == overflowIndex { require.Equal(t, b+1, end[i]) diff --git a/x/group/internal/orm/index_test.go b/x/group/internal/orm/index_test.go index 521bb9d6c9..1172de745a 100644 --- a/x/group/internal/orm/index_test.go +++ b/x/group/internal/orm/index_test.go @@ -119,6 +119,7 @@ func TestIndexPrefixScan(t *testing.T) { Metadata: []byte("metadata-b"), } for _, g := range []testdata.TableModel{g1, g2, g3} { + g := g _, err := tb.Create(store, &g) require.NoError(t, err) } @@ -127,7 +128,7 @@ func TestIndexPrefixScan(t *testing.T) { start, end interface{} expResult []testdata.TableModel expRowIDs []RowID - expError *sdkerrors.Error + expError *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package method func(store sdk.KVStore, start, end interface{}) (Iterator, error) }{ "exact match with a single result": { diff --git a/x/group/internal/orm/indexer_test.go b/x/group/internal/orm/indexer_test.go index 79278418c9..8b4707f2f8 100644 --- a/x/group/internal/orm/indexer_test.go +++ b/x/group/internal/orm/indexer_test.go @@ -375,7 +375,7 @@ func TestUniqueKeyAddFunc(t *testing.T) { specs := map[string]struct { srcKey []byte - expErr *sdkerrors.Error + expErr *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package. expExistingEntry []byte }{ "create when not exists": { @@ -418,7 +418,7 @@ func TestMultiKeyAddFunc(t *testing.T) { specs := map[string]struct { srcKey []byte - expErr *sdkerrors.Error + expErr *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package. expExistingEntry []byte }{ "create when not exists": { diff --git a/x/group/internal/orm/iterator_property_test.go b/x/group/internal/orm/iterator_property_test.go index 2b3a0e565b..618c918d88 100644 --- a/x/group/internal/orm/iterator_property_test.go +++ b/x/group/internal/orm/iterator_property_test.go @@ -53,7 +53,7 @@ func TestPaginationProperty(t *testing.T) { // Reconstruct the slice from keyed pages reconstructedTableModels = make([]*testdata.TableModel, 0, len(tableModels)) - var start uint64 = 0 + var start uint64 key := EncodeSequence(0) for key != nil { pageRequest := &query.PageRequest{ diff --git a/x/group/internal/orm/iterator_test.go b/x/group/internal/orm/iterator_test.go index 54abe52457..96c4072dcd 100644 --- a/x/group/internal/orm/iterator_test.go +++ b/x/group/internal/orm/iterator_test.go @@ -20,7 +20,7 @@ func TestReadAll(t *testing.T) { specs := map[string]struct { srcIT Iterator destSlice func() ModelSlicePtr - expErr *sdkerrors.Error + expErr *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package. expIDs []RowID expResult ModelSlicePtr }{ @@ -203,7 +203,7 @@ func TestPaginate(t *testing.T) { tb, err := NewAutoUInt64Table(AutoUInt64TablePrefix, AutoUInt64TableSeqPrefix, &testdata.TableModel{}, cdc) require.NoError(t, err) idx, err := NewIndex(tb, AutoUInt64TableModelByMetadataPrefix, func(val interface{}) ([]interface{}, error) { - return []interface{}{[]byte(val.(*testdata.TableModel).Metadata)}, nil + return []interface{}{val.(*testdata.TableModel).Metadata}, nil }, testdata.TableModel{}.Metadata) require.NoError(t, err) @@ -238,6 +238,7 @@ func TestPaginate(t *testing.T) { } for _, g := range []testdata.TableModel{t1, t2, t3, t4, t5} { + g := g _, err := tb.Create(store, &g) require.NoError(t, err) } diff --git a/x/group/internal/orm/orm_scenario_test.go b/x/group/internal/orm/orm_scenario_test.go index 45f64f6265..f35f1fccfd 100644 --- a/x/group/internal/orm/orm_scenario_test.go +++ b/x/group/internal/orm/orm_scenario_test.go @@ -273,7 +273,9 @@ func TestGasCostsPrimaryKeyTable(t *testing.T) { for i, m := range tms { gCtx.ResetGasMeter() + m := m err = k.primaryKeyTable.Delete(gCtx.KVStore(store), &m) + require.NoError(t, err) t.Logf("%d: gas consumed on delete: %d", i, gCtx.GasConsumed()) } diff --git a/x/group/internal/orm/primary_key_property_test.go b/x/group/internal/orm/primary_key_property_test.go index 3b7f371053..ff5bb4826c 100644 --- a/x/group/internal/orm/primary_key_property_test.go +++ b/x/group/internal/orm/primary_key_property_test.go @@ -1,3 +1,4 @@ +//nolint:unused // this file contains tests package orm import ( @@ -47,9 +48,8 @@ func (m *primaryKeyMachine) genTableModel() *rapid.Generator[*testdata.TableMode if len(m.stateKeys()) == 0 { return genTableModel - } else { - return rapid.OneOf(genTableModel, genStateTableModel) } + return rapid.OneOf(genTableModel, genStateTableModel) } // Init creates a new instance of the state machine model by building the real diff --git a/x/group/internal/orm/primary_key_test.go b/x/group/internal/orm/primary_key_test.go index 66adb3240d..898f13282b 100644 --- a/x/group/internal/orm/primary_key_test.go +++ b/x/group/internal/orm/primary_key_test.go @@ -41,6 +41,7 @@ func TestPrimaryKeyTablePrefixScan(t *testing.T) { Metadata: metadata, } for _, g := range []testdata.TableModel{t1, t2, t3} { + g := g require.NoError(t, tb.Create(store, &g)) } @@ -48,7 +49,7 @@ func TestPrimaryKeyTablePrefixScan(t *testing.T) { start, end []byte expResult []testdata.TableModel expRowIDs []RowID - expError *sdkerrors.Error + expError *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package. method func(store sdk.KVStore, start, end []byte) (Iterator, error) }{ "exact match with a single result": { diff --git a/x/group/internal/orm/sequence_property_test.go b/x/group/internal/orm/sequence_property_test.go index 0872e429a0..3525f890d3 100644 --- a/x/group/internal/orm/sequence_property_test.go +++ b/x/group/internal/orm/sequence_property_test.go @@ -1,3 +1,4 @@ +//nolint:unused // contains tests package orm import ( diff --git a/x/group/internal/orm/table_test.go b/x/group/internal/orm/table_test.go index 633c4b1618..27633a0cc0 100644 --- a/x/group/internal/orm/table_test.go +++ b/x/group/internal/orm/table_test.go @@ -57,7 +57,7 @@ func TestCreate(t *testing.T) { specs := map[string]struct { rowID RowID src proto.Message - expErr *sdkerrors.Error + expErr *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package. }{ "empty rowID": { rowID: []byte{}, @@ -125,7 +125,7 @@ func TestCreate(t *testing.T) { func TestUpdate(t *testing.T) { specs := map[string]struct { src proto.Message - expErr *sdkerrors.Error + expErr *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package. }{ "happy path": { src: &testdata.TableModel{ @@ -186,14 +186,14 @@ func TestUpdate(t *testing.T) { func TestDelete(t *testing.T) { specs := map[string]struct { - rowId []byte - expErr *sdkerrors.Error + rowID []byte + expErr *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package. }{ "happy path": { - rowId: EncodeSequence(1), + rowID: EncodeSequence(1), }, "not found": { - rowId: []byte("not-found"), + rowID: []byte("not-found"), expErr: sdkerrors.ErrNotFound, }, } @@ -218,7 +218,7 @@ func TestDelete(t *testing.T) { require.NoError(t, err) // when - err = myTable.Delete(store, spec.rowId) + err = myTable.Delete(store, spec.rowID) require.True(t, spec.expErr.Is(err), "got ", err) // then diff --git a/x/group/internal/orm/types_test.go b/x/group/internal/orm/types_test.go index 130f31bdde..94c05d0c43 100644 --- a/x/group/internal/orm/types_test.go +++ b/x/group/internal/orm/types_test.go @@ -32,7 +32,7 @@ func TestTypeSafeRowGetter(t *testing.T) { srcRowID RowID srcModelType reflect.Type expObj interface{} - expErr *sdkerrors.Error + expErr *sdkerrors.Error //nolint:staticcheck // SA1019: sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module. Please use the above module instead of this package. }{ "happy path": { srcRowID: EncodeSequence(1), diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index aa19189aeb..f8c24db880 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -119,7 +119,7 @@ func (s *TestSuite) SetupTest() { s.bankKeeper.SendCoinsFromModuleToAccount(s.sdkCtx, minttypes.ModuleName, s.groupPolicyAddr, sdk.Coins{sdk.NewInt64Coin("test", 10000)}) } -func (s TestSuite) setNextAccount() { +func (s TestSuite) setNextAccount() { //nolint:govet // this is a test and we're okay with copying locks here. nextAccVal := s.groupKeeper.GetGroupPolicySeq(s.sdkCtx) + 1 derivationKey := make([]byte, 8) binary.BigEndian.PutUint64(derivationKey, nextAccVal) @@ -1405,12 +1405,12 @@ func (s *TestSuite) TestUpdateGroupPolicyDecisionPolicy() { err := spec.expGroupPolicy.SetDecisionPolicy(spec.policy) s.Require().NoError(err) if spec.preRun != nil { - policyAddr1, groupId := spec.preRun(admin) + policyAddr1, groupID := spec.preRun(admin) policyAddr = policyAddr1 // update the expected info with new group policy details spec.expGroupPolicy.Address = policyAddr1 - spec.expGroupPolicy.GroupId = groupId + spec.expGroupPolicy.GroupId = groupID // update req with new group policy addr spec.req.GroupPolicyAddress = policyAddr1 @@ -1815,7 +1815,7 @@ func (s *TestSuite) TestWithdrawProposal() { specs := map[string]struct { preRun func(sdkCtx sdk.Context) uint64 - proposalId uint64 + proposalID uint64 admin string expErrMsg string }{ @@ -1837,20 +1837,20 @@ func (s *TestSuite) TestWithdrawProposal() { preRun: func(sdkCtx sdk.Context) uint64 { return submitProposal(s.ctx, s, []sdk.Msg{msgSend}, proposers) }, - proposalId: proposalID, + proposalID: proposalID, admin: proposers[0], }, "already closed proposal": { preRun: func(sdkCtx sdk.Context) uint64 { - pId := submitProposal(s.ctx, s, []sdk.Msg{msgSend}, proposers) + pID := submitProposal(s.ctx, s, []sdk.Msg{msgSend}, proposers) _, err := s.groupKeeper.WithdrawProposal(s.ctx, &group.MsgWithdrawProposal{ - ProposalId: pId, + ProposalId: pID, Address: proposers[0], }) s.Require().NoError(err) - return pId + return pID }, - proposalId: proposalID, + proposalID: proposalID, admin: proposers[0], expErrMsg: "cannot withdraw a proposal with the status of PROPOSAL_STATUS_WITHDRAWN", }, @@ -1858,17 +1858,17 @@ func (s *TestSuite) TestWithdrawProposal() { preRun: func(sdkCtx sdk.Context) uint64 { return submitProposal(s.ctx, s, []sdk.Msg{msgSend}, proposers) }, - proposalId: proposalID, + proposalID: proposalID, admin: proposers[0], }, } for msg, spec := range specs { spec := spec s.Run(msg, func() { - pId := spec.preRun(s.sdkCtx) + pID := spec.preRun(s.sdkCtx) _, err := s.groupKeeper.WithdrawProposal(s.ctx, &group.MsgWithdrawProposal{ - ProposalId: pId, + ProposalId: pID, Address: spec.admin, }) @@ -1879,7 +1879,7 @@ func (s *TestSuite) TestWithdrawProposal() { } s.Require().NoError(err) - resp, err := s.groupKeeper.Proposal(s.ctx, &group.QueryProposalRequest{ProposalId: pId}) + resp, err := s.groupKeeper.Proposal(s.ctx, &group.QueryProposalRequest{ProposalId: pID}) s.Require().NoError(err) s.Require().Equal(resp.GetProposal().Status, group.PROPOSAL_STATUS_WITHDRAWN) }) @@ -2795,7 +2795,7 @@ func (s *TestSuite) TestProposalsByVPEnd() { specs := map[string]struct { preRun func(sdkCtx sdk.Context) uint64 - proposalId uint64 + proposalID uint64 admin string expErrMsg string newCtx sdk.Context @@ -2860,14 +2860,14 @@ func (s *TestSuite) TestProposalsByVPEnd() { }, "tally of withdrawn proposal": { preRun: func(sdkCtx sdk.Context) uint64 { - pId := submitProposal(s.ctx, s, []sdk.Msg{msgSend}, proposers) + pID := submitProposal(s.ctx, s, []sdk.Msg{msgSend}, proposers) _, err := s.groupKeeper.WithdrawProposal(s.ctx, &group.MsgWithdrawProposal{ - ProposalId: pId, + ProposalId: pID, Address: proposers[0], }) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx, @@ -2876,14 +2876,14 @@ func (s *TestSuite) TestProposalsByVPEnd() { }, "tally of withdrawn proposal (with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { - pId := submitProposalAndVote(s.ctx, s, []sdk.Msg{msgSend}, proposers, group.VOTE_OPTION_YES) + pID := submitProposalAndVote(s.ctx, s, []sdk.Msg{msgSend}, proposers, group.VOTE_OPTION_YES) _, err := s.groupKeeper.WithdrawProposal(s.ctx, &group.MsgWithdrawProposal{ - ProposalId: pId, + ProposalId: pID, Address: proposers[0], }) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx, @@ -2895,11 +2895,11 @@ func (s *TestSuite) TestProposalsByVPEnd() { for msg, spec := range specs { spec := spec s.Run(msg, func() { - pId := spec.preRun(s.sdkCtx) + pID := spec.preRun(s.sdkCtx) module.EndBlocker(spec.newCtx, s.groupKeeper) resp, err := s.groupKeeper.Proposal(spec.newCtx, &group.QueryProposalRequest{ - ProposalId: pId, + ProposalId: pID, }) if spec.expErrMsg != "" { @@ -3212,7 +3212,7 @@ func (s *TestSuite) TestTallyProposalsAtVPEnd() { addrs := s.addrs addr1 := addrs[0] addr2 := addrs[1] - votingPeriod := time.Duration(4 * time.Minute) + votingPeriod := 4 * time.Minute minExecutionPeriod := votingPeriod + group.DefaultConfig().MaxExecutionPeriod groupMsg := &group.MsgCreateGroupWithPolicy{ @@ -3271,7 +3271,7 @@ func (s *TestSuite) TestTallyProposalsAtVPEnd_GroupMemberLeaving() { addr1 := addrs[0] addr2 := addrs[1] addr3 := addrs[2] - votingPeriod := time.Duration(4 * time.Minute) + votingPeriod := 4 * time.Minute minExecutionPeriod := votingPeriod + group.DefaultConfig().MaxExecutionPeriod groupMsg := &group.MsgCreateGroupWithPolicy{ diff --git a/x/group/keeper/proposal_executor.go b/x/group/keeper/proposal_executor.go index fa2ff398d1..4ae0b30517 100644 --- a/x/group/keeper/proposal_executor.go +++ b/x/group/keeper/proposal_executor.go @@ -3,7 +3,6 @@ package keeper import ( "fmt" - errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -42,11 +41,11 @@ func (s Keeper) doExecuteMsgs(ctx sdk.Context, router *baseapp.MsgServiceRouter, for i, msg := range msgs { handler := s.router.Handler(msg) if handler == nil { - return nil, errorsmod.Wrapf(errors.ErrInvalid, "no message handler found for %q", sdk.MsgTypeURL(msg)) + return nil, sdkerrors.Wrapf(errors.ErrInvalid, "no message handler found for %q", sdk.MsgTypeURL(msg)) } r, err := handler(ctx, msg) if err != nil { - return nil, errorsmod.Wrapf(err, "message %s at position %d", sdk.MsgTypeURL(msg), i) + return nil, sdkerrors.Wrapf(err, "message %s at position %d", sdk.MsgTypeURL(msg), i) } // Handler should always return non-nil sdk.Result. if r == nil { @@ -68,7 +67,7 @@ func ensureMsgAuthZ(msgs []sdk.Msg, groupPolicyAcc sdk.AccAddress) error { // but we prefer to loop through all GetSigners just to be sure. for _, acct := range msgs[i].GetSigners() { if !groupPolicyAcc.Equals(acct) { - return errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "msg does not have group policy authorization; expected %s, got %s", groupPolicyAcc.String(), acct.String()) + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "msg does not have group policy authorization; expected %s, got %s", groupPolicyAcc.String(), acct.String()) } } } diff --git a/x/group/keeper/tally_test.go b/x/group/keeper/tally_test.go index 8b9b7940f4..3ca56dedc1 100644 --- a/x/group/keeper/tally_test.go +++ b/x/group/keeper/tally_test.go @@ -42,14 +42,14 @@ func (s *TestSuite) TestTally() { "withdrawn proposal": { setupProposal: func(ctx context.Context) uint64 { msgs := []sdk.Msg{msgSend1} - proposalId := submitProposal(ctx, s, msgs, proposers) + proposalID := submitProposal(ctx, s, msgs, proposers) _, err := s.groupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ - ProposalId: proposalId, + ProposalId: proposalID, Address: proposers[0], }) s.Require().NoError(err) - return proposalId + return proposalID }, expErr: true, }, @@ -71,9 +71,9 @@ func (s *TestSuite) TestTally() { spec := spec s.Run(msg, func() { sdkCtx, _ := s.sdkCtx.CacheContext() - pId := spec.setupProposal(sdkCtx) + pID := spec.setupProposal(sdkCtx) req := &group.QueryTallyResultRequest{ - ProposalId: pId, + ProposalId: pID, } res, err := s.groupKeeper.TallyResult(sdkCtx, req) diff --git a/x/group/module/abci_test.go b/x/group/module/abci_test.go index 43f0436be3..6dac8362cd 100644 --- a/x/group/module/abci_test.go +++ b/x/group/module/abci_test.go @@ -5,10 +5,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -21,6 +17,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/group/module" grouptestutil "github.com/cosmos/cosmos-sdk/x/group/testutil" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmtime "github.com/tendermint/tendermint/types/time" ) type IntegrationTestSuite struct { @@ -243,14 +242,14 @@ func (s *IntegrationTestSuite) TestEndBlockerPruning() { }, "proposal with status withdrawn is pruned after voting period end": { setupProposal: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposal(s, s.app, sdkCtx, []sdk.Msg{msgSend1}, proposers, groupPolicyAddr) + pID, err := submitProposal(s, s.app, sdkCtx, []sdk.Msg{msgSend1}, proposers, groupPolicyAddr) s.Require().NoError(err) _, err = s.groupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ - ProposalId: pId, + ProposalId: pID, Address: proposers[0], }) s.Require().NoError(err) - return pId + return pID }, newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), expErrMsg: "load proposal: not found", @@ -258,14 +257,14 @@ func (s *IntegrationTestSuite) TestEndBlockerPruning() { }, "proposal with status withdrawn is not pruned (before voting period)": { setupProposal: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposal(s, s.app, sdkCtx, []sdk.Msg{msgSend1}, proposers, groupPolicyAddr) + pID, err := submitProposal(s, s.app, sdkCtx, []sdk.Msg{msgSend1}, proposers, groupPolicyAddr) s.Require().NoError(err) _, err = s.groupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ - ProposalId: pId, + ProposalId: pID, Address: proposers[0], }) s.Require().NoError(err) - return pId + return pID }, newCtx: ctx, expErrMsg: "", @@ -274,7 +273,7 @@ func (s *IntegrationTestSuite) TestEndBlockerPruning() { }, "proposal with status aborted is pruned after voting period end (due to updated group policy decision policy)": { setupProposal: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposal(s, s.app, sdkCtx, []sdk.Msg{msgSend2}, proposers, groupPolicyAddr2) + pID, err := submitProposal(s, s.app, sdkCtx, []sdk.Msg{msgSend2}, proposers, groupPolicyAddr2) s.Require().NoError(err) policy := group.NewThresholdDecisionPolicy("3", time.Second, 0) @@ -287,7 +286,7 @@ func (s *IntegrationTestSuite) TestEndBlockerPruning() { _, err = s.groupKeeper.UpdateGroupPolicyDecisionPolicy(ctx, msg) s.Require().NoError(err) - return pId + return pID }, newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), expErrMsg: "load proposal: not found", @@ -296,7 +295,7 @@ func (s *IntegrationTestSuite) TestEndBlockerPruning() { }, "proposal with status aborted is not pruned before voting period end (due to updated group policy)": { setupProposal: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposal(s, s.app, sdkCtx, []sdk.Msg{msgSend2}, proposers, groupPolicyAddr2) + pID, err := submitProposal(s, s.app, sdkCtx, []sdk.Msg{msgSend2}, proposers, groupPolicyAddr2) s.Require().NoError(err) policy := group.NewThresholdDecisionPolicy("3", time.Second, 0) @@ -309,7 +308,7 @@ func (s *IntegrationTestSuite) TestEndBlockerPruning() { _, err = s.groupKeeper.UpdateGroupPolicyDecisionPolicy(ctx, msg) s.Require().NoError(err) - return pId + return pID }, newCtx: ctx, expErrMsg: "", @@ -413,9 +412,9 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { }{ "tally updated after voting period end": { preRun: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposal(s, app, sdkCtx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr) + pID, err := submitProposal(s, app, sdkCtx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), @@ -424,10 +423,10 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { }, "tally within voting period": { preRun: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposal(s, app, sdkCtx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr) + pID, err := submitProposal(s, app, sdkCtx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx, @@ -436,10 +435,10 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { }, "tally within voting period(with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposalAndVote(s, app, ctx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) + pID, err := submitProposalAndVote(s, app, ctx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx, @@ -449,10 +448,10 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { "tally after voting period (not passing)": { preRun: func(sdkCtx sdk.Context) uint64 { // `addrs[1]` has weight 1 - pId, err := submitProposalAndVote(s, app, ctx, []sdk.Msg{msgSend}, []string{addrs[1].String()}, groupPolicyAddr, group.VOTE_OPTION_YES) + pID, err := submitProposalAndVote(s, app, ctx, []sdk.Msg{msgSend}, []string{addrs[1].String()}, groupPolicyAddr, group.VOTE_OPTION_YES) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), @@ -466,10 +465,10 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { }, "tally after voting period(with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposalAndVote(s, app, ctx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) + pID, err := submitProposalAndVote(s, app, ctx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), @@ -483,16 +482,16 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { }, "tally of withdrawn proposal": { preRun: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposal(s, app, sdkCtx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr) + pID, err := submitProposal(s, app, sdkCtx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr) s.Require().NoError(err) _, err = s.groupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ - ProposalId: pId, + ProposalId: pID, Address: proposers[0], }) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx, @@ -501,16 +500,16 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { }, "tally of withdrawn proposal (with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { - pId, err := submitProposalAndVote(s, app, ctx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) + pID, err := submitProposalAndVote(s, app, ctx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) s.Require().NoError(err) _, err = s.groupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ - ProposalId: pId, + ProposalId: pID, Address: proposers[0], }) s.Require().NoError(err) - return pId + return pID }, admin: proposers[0], newCtx: ctx, @@ -522,11 +521,11 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { for msg, spec := range specs { s.Run(msg, func() { spec := spec - pId := spec.preRun(ctx) + pID := spec.preRun(ctx) module.EndBlocker(spec.newCtx, s.groupKeeper) resp, err := s.groupKeeper.Proposal(spec.newCtx, &group.QueryProposalRequest{ - ProposalId: pId, + ProposalId: pID, }) if spec.expErrMsg != "" { @@ -542,7 +541,7 @@ func (s *IntegrationTestSuite) TestEndBlockerTallying() { } } -func submitProposal(s *IntegrationTestSuite, app *runtime.App, ctx context.Context, msgs []sdk.Msg, proposers []string, groupPolicyAddr sdk.AccAddress) (uint64, error) { +func submitProposal(s *IntegrationTestSuite, app *runtime.App, ctx context.Context, msgs []sdk.Msg, proposers []string, groupPolicyAddr sdk.AccAddress) (uint64, error) { //nolint:revive // context-as-argument: context.Context should be the first parameter of a function proposalReq := &group.MsgSubmitProposal{ GroupPolicyAddress: groupPolicyAddr.String(), Proposers: proposers, @@ -561,7 +560,7 @@ func submitProposal(s *IntegrationTestSuite, app *runtime.App, ctx context.Conte } func submitProposalAndVote( - s *IntegrationTestSuite, app *runtime.App, ctx context.Context, msgs []sdk.Msg, + s *IntegrationTestSuite, app *runtime.App, ctx context.Context, msgs []sdk.Msg, //nolint:revive // context-as-argument: context.Context should be the first parameter of a function proposers []string, groupPolicyAddr sdk.AccAddress, voteOption group.VoteOption, ) (uint64, error) { myProposalID, err := submitProposal(s, app, ctx, msgs, proposers, groupPolicyAddr) diff --git a/x/group/msgs.go b/x/group/msgs.go index f0fe8a9b53..700d33975a 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -8,7 +8,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/x/group/codec" - "github.com/cosmos/cosmos-sdk/x/group/errors" + errors "github.com/cosmos/cosmos-sdk/x/group/errors" "github.com/cosmos/cosmos-sdk/x/group/internal/math" ) diff --git a/x/group/testutil/app_config.go b/x/group/testutil/app_config.go index 98827c3b70..10772a709c 100644 --- a/x/group/testutil/app_config.go +++ b/x/group/testutil/app_config.go @@ -5,16 +5,16 @@ import ( "google.golang.org/protobuf/types/known/durationpb" - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/authz" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/group/module" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/authz" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/group/module" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/mint" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // blank import for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // blank import for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/group/testutil/expected_keepers.go b/x/group/testutil/expected_keepers.go index aff1803e79..728f66a278 100644 --- a/x/group/testutil/expected_keepers.go +++ b/x/group/testutil/expected_keepers.go @@ -13,8 +13,7 @@ type AccountKeeper interface { group.AccountKeeper } -// BankKeeper extends `BankKeeper` from expected_keepers and bank `MsgServer` to mock `Send` and -// to register handlers in MsgServiceRouter +// BankKeeper extends bank `MsgServer` to mock `Send` and to register handlers in MsgServiceRouter type BankKeeper interface { group.BankKeeper bank.MsgServer diff --git a/x/group/types_test.go b/x/group/types_test.go index ff117940dc..afad812a39 100644 --- a/x/group/types_test.go +++ b/x/group/types_test.go @@ -122,7 +122,7 @@ func TestPercentageDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: true, Final: true, @@ -144,7 +144,7 @@ func TestPercentageDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "4", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: true, Final: true, @@ -166,7 +166,7 @@ func TestPercentageDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: false, Final: false, @@ -188,7 +188,7 @@ func TestPercentageDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: false, Final: true, @@ -210,7 +210,7 @@ func TestPercentageDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "4", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: false, Final: false, @@ -232,7 +232,7 @@ func TestPercentageDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: false, Final: false, @@ -278,7 +278,7 @@ func TestThresholdDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: true, Final: true, @@ -300,7 +300,7 @@ func TestThresholdDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: false, Final: false, @@ -322,7 +322,7 @@ func TestThresholdDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: true, Final: true, @@ -344,7 +344,7 @@ func TestThresholdDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: false, Final: true, @@ -366,7 +366,7 @@ func TestThresholdDecisionPolicyAllow(t *testing.T) { NoWithVetoCount: "0", }, "3", - time.Duration(time.Second * 50), + time.Second * 50, group.DecisionPolicyResult{ Allow: false, Final: false, diff --git a/x/mint/module.go b/x/mint/module.go index d477637085..74ce26995a 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -215,6 +215,7 @@ func init() { ) } +//nolint:revive type MintInputs struct { depinject.In @@ -232,6 +233,7 @@ type MintInputs struct { StakingKeeper types.StakingKeeper } +//nolint:revive type MintOutputs struct { depinject.Out diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index 6c590d6c8e..8f1d270c4f 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/math" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -32,7 +31,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: sdkmath.NewInt(1000), + InitialStake: math.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/mint/testutil/app_config.go b/x/mint/testutil/app_config.go index 813253cb1c..3599ba80b2 100644 --- a/x/mint/testutil/app_config.go +++ b/x/mint/testutil/app_config.go @@ -2,14 +2,14 @@ package testutil import ( "cosmossdk.io/core/appconfig" - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/mint" // import mint as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/x/nft/client/cli/tx_test.go b/x/nft/client/cli/tx_test.go index dfa63233cf..8f9b55e67e 100644 --- a/x/nft/client/cli/tx_test.go +++ b/x/nft/client/cli/tx_test.go @@ -189,7 +189,7 @@ func (s *CLITestSuite) TestCLITxSend() { for _, tc := range testCases { tc := tc s.Run(tc.name, func() { - args := append(tc.args, extraArgs...) + args := append(tc.args, extraArgs...) //nolint:gocritic // false positive cmd := cli.NewCmdSend() cmd.SetContext(s.ctx) cmd.SetArgs(args) diff --git a/x/nft/keeper/nft_batch_test.go b/x/nft/keeper/nft_batch_test.go index 69529a86c7..00b726c242 100644 --- a/x/nft/keeper/nft_batch_test.go +++ b/x/nft/keeper/nft_batch_test.go @@ -4,7 +4,6 @@ import ( "fmt" "math/rand" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/nft" ) @@ -351,10 +350,3 @@ func (s *TestSuite) saveClass(tokens []nft.NFT) { s.Require().NoError(err) } } - -func (s *TestSuite) mintNFT(tokens []nft.NFT, receiver sdk.AccAddress) { - for _, token := range tokens { - err := s.nftKeeper.Mint(s.ctx, token, receiver) - s.Require().NoError(err) - } -} diff --git a/x/nft/simulation/decoder_test.go b/x/nft/simulation/decoder_test.go index c195eec311..452e4b7c11 100644 --- a/x/nft/simulation/decoder_test.go +++ b/x/nft/simulation/decoder_test.go @@ -50,11 +50,11 @@ func TestDecodeStore(t *testing.T) { kvPairs := kv.Pairs{ Pairs: []kv.Pair{ - {Key: []byte(keeper.ClassKey), Value: classBz}, - {Key: []byte(keeper.NFTKey), Value: nftBz}, - {Key: []byte(keeper.NFTOfClassByOwnerKey), Value: nftOfClassByOwnerValue}, - {Key: []byte(keeper.OwnerKey), Value: ownerAddr1}, - {Key: []byte(keeper.ClassTotalSupply), Value: totalSupplyBz}, + {Key: keeper.ClassKey, Value: classBz}, + {Key: keeper.NFTKey, Value: nftBz}, + {Key: keeper.NFTOfClassByOwnerKey, Value: nftOfClassByOwnerValue}, + {Key: keeper.OwnerKey, Value: ownerAddr1}, + {Key: keeper.ClassTotalSupply, Value: totalSupplyBz}, {Key: []byte{0x99}, Value: []byte{0x99}}, }, } diff --git a/x/nft/testutil/app_config.go b/x/nft/testutil/app_config.go index 7b916e1f9b..cfc5c52a43 100644 --- a/x/nft/testutil/app_config.go +++ b/x/nft/testutil/app_config.go @@ -2,15 +2,15 @@ package testutil import ( "cosmossdk.io/core/appconfig" - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/nft/module" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/mint" // import mint as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/nft/module" // import nft as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index 3ac9122c95..367123d6dd 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -151,7 +151,7 @@ func indirect(ptr interface{}) interface{} { } func TestGetSubspaces(t *testing.T) { - _, _, _, _, keeper := testComponents() + _, _, _, _, keeper := testComponents() //nolint:dogsled table := types.NewKeyTable( types.NewParamSetPair([]byte("string"), "", validateNoOp), @@ -190,9 +190,9 @@ func TestSubspace(t *testing.T) { {"uint16", uint16(1), uint16(0), new(uint16)}, {"uint32", uint32(1), uint32(0), new(uint32)}, {"uint64", uint64(1), uint64(0), new(uint64)}, - {"int", sdk.NewInt(1), *new(math.Int), new(math.Int)}, - {"uint", sdk.NewUint(1), *new(sdk.Uint), new(sdk.Uint)}, - {"dec", math.LegacyNewDec(1), *new(sdk.Dec), new(sdk.Dec)}, + {"int", sdk.NewInt(1), math.Int{}, new(math.Int)}, + {"uint", sdk.NewUint(1), sdk.Uint{}, new(sdk.Uint)}, + {"dec", math.LegacyNewDec(1), sdk.Dec{}, new(sdk.Dec)}, {"struct", s{1}, s{0}, new(s)}, } diff --git a/x/params/module.go b/x/params/module.go index 90e7976ae6..4e4f095898 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -147,6 +147,7 @@ func init() { )) } +//nolint:revive type ParamsInputs struct { depinject.In @@ -156,6 +157,7 @@ type ParamsInputs struct { LegacyAmino *codec.LegacyAmino } +//nolint:revive type ParamsOutputs struct { depinject.Out @@ -186,7 +188,6 @@ func ProvideSubspace(in SubspaceInputs) types.Subspace { kt, exists := in.KeyTables[moduleName] if !exists { return in.Keeper.Subspace(moduleName) - } else { - return in.Keeper.Subspace(moduleName).WithKeyTable(kt) } + return in.Keeper.Subspace(moduleName).WithKeyTable(kt) } diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index c4f60970f0..63a2a5c2be 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -95,7 +95,7 @@ func (suite *HandlerTestSuite) TestProposalHandler() { // }, depositParams) // }, // false, - //}, + // }, } for _, tc := range testCases { diff --git a/x/params/testutil/app_config.go b/x/params/testutil/app_config.go index a549c0028a..f141a6072a 100644 --- a/x/params/testutil/app_config.go +++ b/x/params/testutil/app_config.go @@ -1,13 +1,13 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/params/types/subspace_test.go b/x/params/types/subspace_test.go index 1c4ac855c6..d594011f53 100644 --- a/x/params/types/subspace_test.go +++ b/x/params/types/subspace_test.go @@ -55,7 +55,7 @@ func (suite *SubspaceTestSuite) TestKeyTable() { }) suite.Require().NotPanics(func() { ss := types.NewSubspace(suite.cdc, suite.amino, key, tkey, "testsubspace2") - ss = ss.WithKeyTable(paramKeyTable()) + _ = ss.WithKeyTable(paramKeyTable()) }) } @@ -154,7 +154,7 @@ func (suite *SubspaceTestSuite) TestModified() { func (suite *SubspaceTestSuite) TestUpdate() { suite.Require().Panics(func() { - suite.ss.Update(suite.ctx, []byte("invalid_key"), nil) // nolint:errcheck + suite.ss.Update(suite.ctx, []byte("invalid_key"), nil) //nolint:errcheck }) t := time.Hour * 48 diff --git a/x/slashing/module.go b/x/slashing/module.go index a18a2c8ea0..49cb4233c6 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -210,6 +210,7 @@ func init() { ) } +//nolint:revive type SlashingInputs struct { depinject.In @@ -226,6 +227,7 @@ type SlashingInputs struct { LegacySubspace exported.Subspace } +//nolint:revive type SlashingOutputs struct { depinject.Out diff --git a/x/slashing/simulation/decoder_test.go b/x/slashing/simulation/decoder_test.go index 1758b1f20b..4d99fa16af 100644 --- a/x/slashing/simulation/decoder_test.go +++ b/x/slashing/simulation/decoder_test.go @@ -18,7 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/slashing/types" ) -// nolint:deadcode,varcheck +//nolint:deadcode,varcheck var ( delPk1 = ed25519.GenPrivKey().PubKey() delAddr1 = sdk.AccAddress(delPk1.Address()) diff --git a/x/slashing/testutil/app_config.go b/x/slashing/testutil/app_config.go index 9f16aedd7e..5e08778308 100644 --- a/x/slashing/testutil/app_config.go +++ b/x/slashing/testutil/app_config.go @@ -1,16 +1,16 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/distribution" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/slashing" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/distribution" // import distribution as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/mint" // import mint as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/slashing" // import slashing as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/staking/keeper/historical_info_test.go b/x/staking/keeper/historical_info_test.go index aa9efd5497..bd746fa784 100644 --- a/x/staking/keeper/historical_info_test.go +++ b/x/staking/keeper/historical_info_test.go @@ -147,7 +147,7 @@ func (s *KeeperTestSuite) TestGetAllHistoricalInfo() { expHistInfos := []stakingtypes.HistoricalInfo{hist1, hist2, hist3} for i, hi := range expHistInfos { - keeper.SetHistoricalInfo(ctx, int64(10+i), &hi) + keeper.SetHistoricalInfo(ctx, int64(10+i), &hi) //nolint:gosec // G601: Implicit memory aliasing in for loop. } infos := keeper.GetAllHistoricalInfo(ctx) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 5d38a6045f..57eb8ef365 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -475,15 +475,15 @@ func (k msgServer) CancelUnbondingDelegation(goCtx context.Context, msg *types.M return &types.MsgCancelUnbondingDelegationResponse{}, nil } -func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if ms.authority != msg.Authority { - return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, msg.Authority) + if k.authority != msg.Authority { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) } // store params - if err := ms.SetParams(ctx, msg.Params); err != nil { + if err := k.SetParams(ctx, msg.Params); err != nil { return nil, err } diff --git a/x/staking/migrations/v2/store_test.go b/x/staking/migrations/v2/store_test.go index 9aabb1e041..8039ed477a 100644 --- a/x/staking/migrations/v2/store_test.go +++ b/x/staking/migrations/v2/store_test.go @@ -25,7 +25,7 @@ func TestStoreMigration(t *testing.T) { _, pk1, addr1 := testdata.KeyTestPubAddr() valAddr1 := sdk.ValAddress(addr1) val := testutil.NewValidator(t, valAddr1, pk1) - _, pk1, addr2 := testdata.KeyTestPubAddr() + _, _, addr2 := testdata.KeyTestPubAddr() valAddr2 := sdk.ValAddress(addr2) _, _, addr3 := testdata.KeyTestPubAddr() consAddr := sdk.ConsAddress(addr3.String()) diff --git a/x/staking/module.go b/x/staking/module.go index d693d47eb3..68ce56c305 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -200,6 +200,7 @@ func init() { ) } +//nolint:revive type StakingInputs struct { depinject.In @@ -214,6 +215,8 @@ type StakingInputs struct { } // Dependency Injection Outputs +// +//nolint:revive type StakingOutputs struct { depinject.Out diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index 67fbd65760..a38663f228 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -8,8 +8,6 @@ import ( "cosmossdk.io/math" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/codec" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" @@ -24,14 +22,6 @@ var ( valAddr1 = sdk.ValAddress(delPk1.Address()) ) -func makeTestCodec() (cdc *codec.LegacyAmino) { - cdc = codec.NewLegacyAmino() - sdk.RegisterLegacyAminoCodec(cdc) - cryptocodec.RegisterCrypto(cdc) - types.RegisterLegacyAminoCodec(cdc) - return -} - func TestDecodeStore(t *testing.T) { cdc := testutil.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) diff --git a/x/staking/testutil/app_config.go b/x/staking/testutil/app_config.go index e1a244e12f..9f589bda02 100644 --- a/x/staking/testutil/app_config.go +++ b/x/staking/testutil/app_config.go @@ -1,16 +1,16 @@ package testutil import ( - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/consensus" - _ "github.com/cosmos/cosmos-sdk/x/distribution" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/slashing" - _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/distribution" // import distribution as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/genutil" // import genutil as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/mint" // import mint as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/slashing" // import slashing as a blank for app wiring + _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank for app wiring "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/staking/types/data_test.go b/x/staking/types/data_test.go index ed9c64c57a..d875b088fd 100644 --- a/x/staking/types/data_test.go +++ b/x/staking/types/data_test.go @@ -14,9 +14,6 @@ var ( pk1Any *codectypes.Any pk2 = ed25519.GenPrivKey().PubKey() pk3 = ed25519.GenPrivKey().PubKey() - addr1, _ = sdk.Bech32ifyAddressBytes(sdk.Bech32PrefixAccAddr, pk1.Address().Bytes()) - addr2, _ = sdk.Bech32ifyAddressBytes(sdk.Bech32PrefixAccAddr, pk2.Address().Bytes()) - addr3, _ = sdk.Bech32ifyAddressBytes(sdk.Bech32PrefixAccAddr, pk3.Address().Bytes()) valAddr1 = sdk.ValAddress(pk1.Address()) valAddr2 = sdk.ValAddress(pk2.Address()) valAddr3 = sdk.ValAddress(pk3.Address()) diff --git a/x/staking/types/historical_info_test.go b/x/staking/types/historical_info_test.go index da47623ac0..405fb4d129 100644 --- a/x/staking/types/historical_info_test.go +++ b/x/staking/types/historical_info_test.go @@ -59,7 +59,7 @@ func TestValidateBasic(t *testing.T) { // Ensure validators are not sorted for sort.IsSorted(types.Validators(validators)) { rand.Shuffle(len(validators), func(i, j int) { - it := validators[i] + it := validators[i] //nolint:gocritic validators[i] = validators[j] validators[j] = it }) diff --git a/x/staking/types/keys.go b/x/staking/types/keys.go index 6fede0ef1a..f8f642af5c 100644 --- a/x/staking/types/keys.go +++ b/x/staking/types/keys.go @@ -59,6 +59,7 @@ var ( // UnbondingType defines the type of unbonding operation type UnbondingType int +//nolint:revive // we want these underscores, they make life easier const ( UnbondingType_Undefined UnbondingType = iota UnbondingType_UnbondingDelegation diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index dfe1eddb1f..463861713c 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -261,7 +261,7 @@ func TestValidatorsSortDeterminism(t *testing.T) { // Randomly shuffle validators, sort, and check it is equal to original sort for i := 0; i < 10; i++ { rand.Shuffle(10, func(i, j int) { - it := vals[i] + it := vals[i] //nolint:gocritic vals[i] = vals[j] vals[j] = it }) diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go index 2e40db1e54..6810725961 100644 --- a/x/upgrade/abci_test.go +++ b/x/upgrade/abci_test.go @@ -2,7 +2,6 @@ package upgrade_test import ( "errors" - "fmt" "os" "testing" "time" @@ -60,20 +59,20 @@ func setupTest(t *testing.T, height int64, skip map[int64]bool) TestSuite { s.module = upgrade.NewAppModule(s.keeper) s.handler = upgrade.NewSoftwareUpgradeProposalHandler(s.keeper) - return s + return s //nolint:govet // this is a test, we can copy locks } func TestRequireName(t *testing.T) { s := setupTest(t, 10, map[int64]bool{}) - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{}}) //nolint:staticcheck // we're testing deprecated code require.Error(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } func TestRequireFutureBlock(t *testing.T) { s := setupTest(t, 10, map[int64]bool{}) - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() - 1}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() - 1}}) //nolint:staticcheck // we're testing deprecated code require.Error(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } @@ -81,7 +80,7 @@ func TestRequireFutureBlock(t *testing.T) { func TestDoHeightUpgrade(t *testing.T) { s := setupTest(t, 10, map[int64]bool{}) t.Log("Verify can schedule an upgrade") - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) VerifyDoUpgrade(t) @@ -90,9 +89,9 @@ func TestDoHeightUpgrade(t *testing.T) { func TestCanOverwriteScheduleUpgrade(t *testing.T) { s := setupTest(t, 10, map[int64]bool{}) t.Log("Can overwrite plan") - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "bad_test", Height: s.ctx.BlockHeight() + 10}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "bad_test", Height: s.ctx.BlockHeight() + 10}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) - err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) + err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) VerifyDoUpgrade(t) @@ -153,7 +152,7 @@ func TestHaltIfTooNew(t *testing.T) { require.Equal(t, 0, called) t.Log("Verify we panic if we have a registered handler ahead of time") - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "future", Height: s.ctx.BlockHeight() + 3}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "future", Height: s.ctx.BlockHeight() + 3}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) require.Panics(t, func() { s.module.BeginBlock(newCtx, req) @@ -182,10 +181,10 @@ func VerifyCleared(t *testing.T, newCtx sdk.Context) { func TestCanClear(t *testing.T) { s := setupTest(t, 10, map[int64]bool{}) t.Log("Verify upgrade is scheduled") - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 100}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 100}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) - err = s.handler(s.ctx, &types.CancelSoftwareUpgradeProposal{Title: "cancel"}) + err = s.handler(s.ctx, &types.CancelSoftwareUpgradeProposal{Title: "cancel"}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) VerifyCleared(t, s.ctx) @@ -194,11 +193,11 @@ func TestCanClear(t *testing.T) { func TestCantApplySameUpgradeTwice(t *testing.T) { s := setupTest(t, 10, map[int64]bool{}) height := s.ctx.BlockHeader().Height + 1 - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: height}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: height}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) VerifyDoUpgrade(t) t.Log("Verify an executed upgrade \"test\" can't be rescheduled") - err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: height}}) + err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: height}}) //nolint:staticcheck // we're testing deprecated code require.Error(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } @@ -214,7 +213,7 @@ func TestNoSpuriousUpgrades(t *testing.T) { func TestPlanStringer(t *testing.T) { require.Equal(t, "name:\"test\" time: height:100 ", (&types.Plan{Name: "test", Height: 100, Info: ""}).String()) - require.Equal(t, fmt.Sprintf(`name:"test" time: height:100 `), (&types.Plan{Name: "test", Height: 100, Info: ""}).String()) + require.Equal(t, `name:"test" time: height:100 `, (&types.Plan{Name: "test", Height: 100, Info: ""}).String()) } func VerifyNotDone(t *testing.T, newCtx sdk.Context, name string) { @@ -259,7 +258,7 @@ func TestSkipUpgradeSkippingAll(t *testing.T) { newCtx := s.ctx req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: skipOne}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: skipOne}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) t.Log("Verify if skip upgrade flag clears upgrade plan in both cases") @@ -271,7 +270,7 @@ func TestSkipUpgradeSkippingAll(t *testing.T) { }) t.Log("Verify a second proposal also is being cleared") - err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop2", Plan: types.Plan{Name: "test2", Height: skipTwo}}) + err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop2", Plan: types.Plan{Name: "test2", Height: skipTwo}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) newCtx = newCtx.WithBlockHeight(skipTwo) @@ -296,7 +295,7 @@ func TestUpgradeSkippingOne(t *testing.T) { newCtx := s.ctx req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: skipOne}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: skipOne}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) t.Log("Verify if skip upgrade flag clears upgrade plan in one case and does upgrade on another") @@ -309,7 +308,7 @@ func TestUpgradeSkippingOne(t *testing.T) { }) t.Log("Verify the second proposal is not skipped") - err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop2", Plan: types.Plan{Name: "test2", Height: skipTwo}}) + err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop2", Plan: types.Plan{Name: "test2", Height: skipTwo}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) // Setting block height of proposal test2 newCtx = newCtx.WithBlockHeight(skipTwo) @@ -331,7 +330,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { newCtx := s.ctx req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: skipOne}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: skipOne}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) t.Log("Verify if skip upgrade flag clears upgrade plan in both cases and does third upgrade") @@ -344,7 +343,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { }) // A new proposal with height in skipUpgradeHeights - err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop2", Plan: types.Plan{Name: "test2", Height: skipTwo}}) + err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop2", Plan: types.Plan{Name: "test2", Height: skipTwo}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) // Setting block height of proposal test2 newCtx = newCtx.WithBlockHeight(skipTwo) @@ -353,7 +352,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { }) t.Log("Verify a new proposal is not skipped") - err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop3", Plan: types.Plan{Name: "test3", Height: skipThree}}) + err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop3", Plan: types.Plan{Name: "test3", Height: skipThree}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) newCtx = newCtx.WithBlockHeight(skipThree) VerifyDoUpgradeWithCtx(t, newCtx, "test3") @@ -368,7 +367,7 @@ func TestUpgradeWithoutSkip(t *testing.T) { s := setupTest(t, 10, map[int64]bool{}) newCtx := s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1).WithBlockTime(time.Now()) req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) t.Log("Verify if upgrade happens without skip upgrade") require.Panics(t, func() { @@ -435,7 +434,7 @@ func TestBinaryVersion(t *testing.T) { return vm, nil }) - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "Upgrade test", Plan: types.Plan{Name: "test0", Height: s.ctx.BlockHeight() + 2}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "Upgrade test", Plan: types.Plan{Name: "test0", Height: s.ctx.BlockHeight() + 2}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) newCtx := s.ctx.WithBlockHeight(12) @@ -452,7 +451,7 @@ func TestBinaryVersion(t *testing.T) { { "test panic: upgrade needed", func() (sdk.Context, abci.RequestBeginBlock) { - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "Upgrade test", Plan: types.Plan{Name: "test2", Height: 13}}) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "Upgrade test", Plan: types.Plan{Name: "test2", Height: 13}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) newCtx := s.ctx.WithBlockHeight(13) @@ -493,7 +492,7 @@ func TestDowngradeVerification(t *testing.T) { // submit a plan. planName := "downgrade" - err := handler(ctx, &types.SoftwareUpgradeProposal{Title: "test", Plan: types.Plan{Name: planName, Height: ctx.BlockHeight() + 1}}) + err := handler(ctx, &types.SoftwareUpgradeProposal{Title: "test", Plan: types.Plan{Name: planName, Height: ctx.BlockHeight() + 1}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err) ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) @@ -523,7 +522,7 @@ func TestDowngradeVerification(t *testing.T) { "downgrade with an active plan": { preRun: func(k *keeper.Keeper, ctx sdk.Context, name string) { handler := upgrade.NewSoftwareUpgradeProposalHandler(k) - err := handler(ctx, &types.SoftwareUpgradeProposal{Title: "test", Plan: types.Plan{Name: "another" + planName, Height: ctx.BlockHeight() + 1}}) + err := handler(ctx, &types.SoftwareUpgradeProposal{Title: "test", Plan: types.Plan{Name: "another" + planName, Height: ctx.BlockHeight() + 1}}) //nolint:staticcheck // we're testing deprecated code require.NoError(t, err, name) }, expectPanic: true, diff --git a/x/upgrade/client/cli/parse_test.go b/x/upgrade/client/cli/parse_test.go index b5ce54e4b1..e18dd35e17 100644 --- a/x/upgrade/client/cli/parse_test.go +++ b/x/upgrade/client/cli/parse_test.go @@ -12,7 +12,7 @@ import ( func TestParseArgsToContent(t *testing.T) { fs := NewCmdSubmitLegacyUpgradeProposal().Flags() - proposal := types.SoftwareUpgradeProposal{ + proposal := types.SoftwareUpgradeProposal{ //nolint:staticcheck // SA1019: types.SoftwareUpgradeProposal is deprecated: use types.Content instead Title: "proposal title", Description: "proposal description", Plan: types.Plan{ @@ -22,15 +22,15 @@ func TestParseArgsToContent(t *testing.T) { }, } - fs.Set(cli.FlagTitle, proposal.Title) - fs.Set(cli.FlagDescription, proposal.Description) + fs.Set(cli.FlagTitle, proposal.Title) //nolint:staticcheck // SA1019: cli.FlagTitle is deprecated: use cli.FlagProposalTitle instead + fs.Set(cli.FlagDescription, proposal.Description) //nolint:staticcheck // SA1019: cli.FlagDescription is deprecated: use cli.FlagProposalDescription instead fs.Set(FlagUpgradeHeight, strconv.FormatInt(proposal.Plan.Height, 10)) fs.Set(FlagUpgradeInfo, proposal.Plan.Info) content, err := parseArgsToContent(fs, proposal.Plan.Name) require.NoError(t, err) - p, ok := content.(*types.SoftwareUpgradeProposal) + p, ok := content.(*types.SoftwareUpgradeProposal) //nolint:staticcheck // SA1019: types.SoftwareUpgradeProposal is deprecated: use types.Content instead require.Equal(t, ok, true) require.Equal(t, p.Title, proposal.Title) require.Equal(t, p.Description, proposal.Description) diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index e36cca81ab..a7002f6edd 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -227,7 +227,7 @@ func (s *KeeperTestSuite) TestIsSkipHeight() { ok := s.upgradeKeeper.IsSkipHeight(11) s.Require().False(ok) skip := map[int64]bool{skipOne: true} - upgradeKeeper := keeper.NewKeeper(skip, s.key, s.encCfg.Codec, s.T().TempDir(), nil, string(authtypes.NewModuleAddress(govtypes.ModuleName).String())) + upgradeKeeper := keeper.NewKeeper(skip, s.key, s.encCfg.Codec, s.T().TempDir(), nil, authtypes.NewModuleAddress(govtypes.ModuleName).String()) upgradeKeeper.SetVersionSetter(s.baseApp) s.Require().True(upgradeKeeper.IsSkipHeight(9)) s.Require().False(upgradeKeeper.IsSkipHeight(10)) @@ -279,7 +279,7 @@ func (s *KeeperTestSuite) TestMigrations() { vmBefore := s.upgradeKeeper.GetModuleVersionMap(s.ctx) s.upgradeKeeper.SetUpgradeHandler("dummy", func(_ sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) { // simulate upgrading the bank module - vm["bank"] = vm["bank"] + 1 + vm["bank"] = vm["bank"] + 1 //nolint:gocritic return vm, nil }) dummyPlan := types.Plan{ diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 79fb663365..7542502aca 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -172,6 +172,7 @@ func init() { ) } +//nolint:revive type UpgradeInputs struct { depinject.In @@ -182,6 +183,7 @@ type UpgradeInputs struct { AppOpts servertypes.AppOptions `optional:"true"` } +//nolint:revive type UpgradeOutputs struct { depinject.Out diff --git a/x/upgrade/plan/downloader_test.go b/x/upgrade/plan/downloader_test.go index 3d50e9f13a..b9c6f8740c 100644 --- a/x/upgrade/plan/downloader_test.go +++ b/x/upgrade/plan/downloader_test.go @@ -65,7 +65,7 @@ type TestZip []*TestFile func NewTestZip(testFiles ...*TestFile) TestZip { tz := make([]*TestFile, len(testFiles)) - for i, tf := range testFiles { + for i, tf := range testFiles { //nolint:gosimple tz[i] = tf } return tz @@ -94,7 +94,7 @@ func (z TestZip) SaveAs(path string) error { // saveTestZip saves a TestZip in this test's Home/src directory with the given name. // The full path to the saved archive is returned. -func (s DownloaderTestSuite) saveSrcTestZip(name string, z TestZip) string { +func (s DownloaderTestSuite) saveSrcTestZip(name string, z TestZip) string { //nolint:govet // this is a test, we can copy locks fullName := filepath.Join(s.Home, "src", name) s.Require().NoError(z.SaveAs(fullName), "saving test zip %s", name) return fullName @@ -102,7 +102,7 @@ func (s DownloaderTestSuite) saveSrcTestZip(name string, z TestZip) string { // saveSrcTestFile saves a TestFile in this test's Home/src directory. // The full path to the saved file is returned. -func (s DownloaderTestSuite) saveSrcTestFile(f *TestFile) string { +func (s DownloaderTestSuite) saveSrcTestFile(f *TestFile) string { //nolint:govet // this is a test, we can copy locks path := filepath.Join(s.Home, "src") fullName, err := f.SaveIn(path) s.Require().NoError(err, "saving test file %s", f.Name) diff --git a/x/upgrade/plan/info_test.go b/x/upgrade/plan/info_test.go index 65736a5e67..b6fa03bce7 100644 --- a/x/upgrade/plan/info_test.go +++ b/x/upgrade/plan/info_test.go @@ -26,13 +26,13 @@ func TestInfoTestSuite(t *testing.T) { // saveSrcTestFile saves a TestFile in this test's Home/src directory. // The full path to the saved file is returned. -func (s InfoTestSuite) saveTestFile(f *TestFile) string { +func (s InfoTestSuite) saveTestFile(f *TestFile) string { //nolint:govet // false positive fullName, err := f.SaveIn(s.Home) s.Require().NoError(err, "saving test file %s", f.Name) return fullName } -func (s InfoTestSuite) TestParseInfo() { +func (s InfoTestSuite) TestParseInfo() { //nolint:govet // false positive goodJSON := `{"binaries":{"os1/arch1":"url1","os2/arch2":"url2"}}` binariesWrongJSON := `{"binaries":["foo","bar"]}` binariesWrongValueJSON := `{"binaries":{"os1/arch1":1,"os2/arch2":2}}` @@ -129,7 +129,7 @@ func (s InfoTestSuite) TestParseInfo() { } } -func (s InfoTestSuite) TestInfoValidateFull() { +func (s InfoTestSuite) TestInfoValidateFull() { //nolint:govet // this is a test, we can copy locks darwinAMD64File := NewTestFile("darwin_amd64", "#!/usr/bin\necho 'darwin/amd64'\n") linux386File := NewTestFile("linux_386", "#!/usr/bin\necho 'darwin/amd64'\n") darwinAMD64Path := s.saveTestFile(darwinAMD64File) @@ -186,7 +186,7 @@ func (s InfoTestSuite) TestInfoValidateFull() { } } -func (s InfoTestSuite) TestBinaryDownloadURLMapValidateBasic() { +func (s InfoTestSuite) TestBinaryDownloadURLMapValidateBasic() { //nolint:govet // this is a test, we can copy locks addDummyChecksum := func(url string) string { return url + "?checksum=sha256:b5a2c96250612366ea272ffac6d9744aaf4b45aacd96aa7cfcb931ee3b558259" } @@ -282,7 +282,7 @@ func (s InfoTestSuite) TestBinaryDownloadURLMapValidateBasic() { } } -func (s InfoTestSuite) TestBinaryDownloadURLMapCheckURLs() { +func (s InfoTestSuite) TestBinaryDownloadURLMapCheckURLs() { //nolint:govet // this is a test, we can copy locks darwinAMD64File := NewTestFile("darwin_amd64", "#!/usr/bin\necho 'darwin/amd64'\n") linux386File := NewTestFile("linux_386", "#!/usr/bin\necho 'darwin/amd64'\n") darwinAMD64Path := s.saveTestFile(darwinAMD64File) diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index d0659635ef..66fd64f32b 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" - tmlog "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" @@ -27,7 +26,7 @@ func useUpgradeLoader(height int64, upgrades *storetypes.StoreUpgrades) func(*ba } func defaultLogger() log.Logger { - return tmlog.NewTMLogger(tmlog.NewSyncWriter(os.Stdout)) + return log.NewTMLogger(log.NewSyncWriter(os.Stdout)) } func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) { @@ -78,7 +77,7 @@ func TestSetLoader(t *testing.T) { data, err := json.Marshal(upgradeInfo) require.NoError(t, err) - err = os.WriteFile(upgradeInfoFilePath, data, 0o644) + err = os.WriteFile(upgradeInfoFilePath, data, 0o644) //nolint:gosec require.NoError(t, err) // make sure it exists before running everything