chore: lint tests (#14268)
This commit is contained in:
+8
-1
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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"})
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+5
-6
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// nolint
|
||||
package types
|
||||
|
||||
import (
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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))
|
||||
|
||||
+10
-10
@@ -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)
|
||||
//
|
||||
|
||||
@@ -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)
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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 |
|
||||
// | ---- | ---- | ------ | ----- | ------ |
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
+10
-10
@@ -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)
|
||||
}
|
||||
|
||||
+25
-25
@@ -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 '='")
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+12
-12
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//nolint:revive
|
||||
package testdata_pulsar
|
||||
|
||||
import (
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
+13
-13
@@ -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))
|
||||
|
||||
+2
-2
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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() }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"},
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
@@ -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},
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
//}
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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{}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
+3
-3
@@ -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",
|
||||
)
|
||||
|
||||
@@ -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{})
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user