refactor: remove unnecessary depinject usage (#15529)
This commit is contained in:
@@ -15,11 +15,11 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
func Test_runAddCmdLedgerWithCustomCoinType(t *testing.T) {
|
||||
@@ -44,7 +44,7 @@ func Test_runAddCmdLedgerWithCustomCoinType(t *testing.T) {
|
||||
// Prepare a keybase
|
||||
kbHome := t.TempDir()
|
||||
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
clientCtx := client.Context{}.WithKeyringDir(kbHome).WithCodec(cdc)
|
||||
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)
|
||||
|
||||
@@ -96,7 +96,7 @@ func Test_runAddCmdLedger(t *testing.T) {
|
||||
|
||||
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
|
||||
kbHome := t.TempDir()
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
|
||||
clientCtx := client.Context{}.WithKeyringDir(kbHome).WithCodec(cdc)
|
||||
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)
|
||||
@@ -137,7 +137,7 @@ func Test_runAddCmdLedger(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_runAddCmdLedgerDryRun(t *testing.T) {
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
testData := []struct {
|
||||
name string
|
||||
args []string
|
||||
|
||||
@@ -12,12 +12,12 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/go-bip39"
|
||||
)
|
||||
|
||||
@@ -28,8 +28,7 @@ func Test_runAddCmdBasic(t *testing.T) {
|
||||
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
|
||||
kbHome := t.TempDir()
|
||||
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -124,7 +123,7 @@ func Test_runAddCmdBasic(t *testing.T) {
|
||||
func Test_runAddCmdDryRun(t *testing.T) {
|
||||
pubkey1 := `{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AtObiFVE4s+9+RX5SP8TN9r2mxpoaT4eGj9CJfK7VRzN"}`
|
||||
pubkey2 := `{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/se1vkqgdQ7VJQCM4mxN+L+ciGhnnJ4XYsQCRBMrdRi"}`
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
|
||||
testData := []struct {
|
||||
name string
|
||||
@@ -235,7 +234,7 @@ func Test_runAddCmdDryRun(t *testing.T) {
|
||||
func TestAddRecoverFileBackend(t *testing.T) {
|
||||
cmd := AddKeyCommand()
|
||||
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
|
||||
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
|
||||
kbHome := t.TempDir()
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
func Test_runDeleteCmd(t *testing.T) {
|
||||
@@ -34,7 +34,7 @@ func Test_runDeleteCmd(t *testing.T) {
|
||||
fakeKeyName2 := "runDeleteCmd_Key2"
|
||||
|
||||
path := sdk.GetConfig().GetFullBIP44Path()
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
|
||||
cmd.SetArgs([]string{"blah", fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome)})
|
||||
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_runExportCmd(t *testing.T) {
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
testCases := []struct {
|
||||
name string
|
||||
keyringBackend string
|
||||
|
||||
@@ -11,14 +11,14 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
func Test_runImportCmd(t *testing.T) {
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
testCases := []struct {
|
||||
name string
|
||||
keyringBackend string
|
||||
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
func cleanupKeys(t *testing.T, kb keyring.Keyring, keys ...string) func() {
|
||||
@@ -37,7 +37,7 @@ func Test_runListCmd(t *testing.T) {
|
||||
kbHome2 := t.TempDir()
|
||||
|
||||
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome2, mockIn, cdc)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -85,7 +85,7 @@ func Test_runListCmd(t *testing.T) {
|
||||
func Test_runListKeyTypeCmd(t *testing.T) {
|
||||
cmd := ListKeyTypesCmd()
|
||||
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
kbHome := t.TempDir()
|
||||
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
type setter interface {
|
||||
@@ -36,7 +36,7 @@ type MigrateTestSuite struct {
|
||||
|
||||
func (s *MigrateTestSuite) SetupSuite() {
|
||||
s.dir = s.T().TempDir()
|
||||
s.cdc = clienttestutil.MakeTestCodec(s.T())
|
||||
s.cdc = moduletestutil.MakeTestEncodingConfig().Codec
|
||||
s.appName = "cosmos"
|
||||
s.priv = cryptotypes.PrivKey(secp256k1.GenPrivKey())
|
||||
s.pub = s.priv.PubKey()
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
func Test_runRenameCmd(t *testing.T) {
|
||||
@@ -32,7 +32,7 @@ func Test_runRenameCmd(t *testing.T) {
|
||||
|
||||
path := sdk.GetConfig().GetFullBIP44Path()
|
||||
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
|
||||
@@ -18,6 +17,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
func Test_multiSigKey_Properties(t *testing.T) {
|
||||
@@ -53,7 +53,7 @@ func Test_runShowCmd(t *testing.T) {
|
||||
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
|
||||
|
||||
kbHome := t.TempDir()
|
||||
cdc := clienttestutil.MakeTestCodec(t)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
|
||||
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
|
||||
"cosmossdk.io/core/appconfig"
|
||||
"cosmossdk.io/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
_ "github.com/cosmos/cosmos-sdk/runtime" // Register runtime module
|
||||
)
|
||||
|
||||
var TestConfig = appconfig.Compose(&appv1alpha1.Config{
|
||||
Modules: []*appv1alpha1.ModuleConfig{
|
||||
{
|
||||
Name: "runtime",
|
||||
Config: appconfig.WrapAny(&runtimev1alpha1.Module{
|
||||
AppName: "clientTest",
|
||||
}),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
func MakeTestCodec(t *testing.T) codec.Codec {
|
||||
var cdc codec.Codec
|
||||
err := depinject.Inject(TestConfig, &cdc)
|
||||
require.NoError(t, err)
|
||||
return cdc
|
||||
}
|
||||
@@ -5,29 +5,23 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
_ "cosmossdk.io/api/cosmos/bank/v1beta1"
|
||||
"cosmossdk.io/depinject"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
typestx "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
)
|
||||
|
||||
func TestAuxTxBuilder(t *testing.T) {
|
||||
var (
|
||||
reg codectypes.InterfaceRegistry
|
||||
cdc codec.Codec
|
||||
)
|
||||
err := depinject.Inject(clienttestutil.TestConfig, ®, &cdc)
|
||||
bankModule := bank.AppModuleBasic{}
|
||||
cdc := moduletestutil.MakeTestEncodingConfig(bankModule).Codec
|
||||
reg := codectypes.NewInterfaceRegistry()
|
||||
|
||||
require.NoError(t, err)
|
||||
testdata.RegisterInterfaces(reg)
|
||||
// required for test case: "GetAuxSignerData works for DIRECT_AUX"
|
||||
bankModule.RegisterInterfaces(reg)
|
||||
|
||||
@@ -6,13 +6,11 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@@ -21,6 +19,7 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
@@ -30,13 +29,8 @@ import (
|
||||
)
|
||||
|
||||
func newTestTxConfig(t *testing.T) (client.TxConfig, codec.Codec) {
|
||||
var (
|
||||
pcdc codec.ProtoCodecMarshaler
|
||||
cdc codec.Codec
|
||||
)
|
||||
err := depinject.Inject(clienttestutil.TestConfig, &pcdc, &cdc)
|
||||
require.NoError(t, err)
|
||||
return authtx.NewTxConfig(pcdc, authtx.DefaultSignModes), cdc
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig()
|
||||
return authtx.NewTxConfig(codec.NewProtoCodec(encodingConfig.InterfaceRegistry), authtx.DefaultSignModes), encodingConfig.Codec
|
||||
}
|
||||
|
||||
// mockContext is a mock client.Context to return abitrary simulation response, used to
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/testutil"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
@@ -58,7 +57,7 @@ func (s *E2ETestSuite) SetupSuite() {
|
||||
appBuilder *runtime.AppBuilder
|
||||
paramsKeeper keeper.Keeper
|
||||
)
|
||||
if err := depinject.Inject(testutil.AppConfig, &appBuilder, ¶msKeeper); err != nil {
|
||||
if err := depinject.Inject(AppConfig, &appBuilder, ¶msKeeper); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
simstestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
@@ -61,7 +61,7 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
|
||||
var interfaceRegistry codectypes.InterfaceRegistry
|
||||
|
||||
app, err := sims.Setup(
|
||||
app, err := simstestutil.Setup(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
|
||||
@@ -201,7 +201,7 @@ func TestAllocateTokensTruncation(t *testing.T) {
|
||||
Address: valConsPk1.Address(),
|
||||
Power: 10,
|
||||
}
|
||||
abciValС := abci.Validator{
|
||||
abciValC := abci.Validator{
|
||||
Address: valConsPk2.Address(),
|
||||
Power: 10,
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func TestAllocateTokensTruncation(t *testing.T) {
|
||||
SignedLastBlock: true,
|
||||
},
|
||||
{
|
||||
Validator: abciValС,
|
||||
Validator: abciValC,
|
||||
SignedLastBlock: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type TestEncodingConfig struct {
|
||||
}
|
||||
|
||||
func MakeTestEncodingConfig(modules ...module.AppModuleBasic) TestEncodingConfig {
|
||||
cdc := codec.NewLegacyAmino()
|
||||
aminoCodec := codec.NewLegacyAmino()
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
codec := codec.NewProtoCodec(interfaceRegistry)
|
||||
|
||||
@@ -29,7 +29,7 @@ func MakeTestEncodingConfig(modules ...module.AppModuleBasic) TestEncodingConfig
|
||||
InterfaceRegistry: interfaceRegistry,
|
||||
Codec: codec,
|
||||
TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes),
|
||||
Amino: cdc,
|
||||
Amino: aminoCodec,
|
||||
}
|
||||
|
||||
mb := module.NewBasicManager(modules...)
|
||||
|
||||
@@ -7,39 +7,28 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"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/client/cli"
|
||||
authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil"
|
||||
)
|
||||
|
||||
func TestGetCommandEncode(t *testing.T) {
|
||||
var (
|
||||
txCfg client.TxConfig
|
||||
legacyAmino *codec.LegacyAmino
|
||||
codec codec.Codec
|
||||
)
|
||||
|
||||
err := depinject.Inject(
|
||||
authtestutil.AppConfig,
|
||||
&txCfg,
|
||||
&legacyAmino,
|
||||
&codec,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
|
||||
txConfig := encodingConfig.TxConfig
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
cmd := cli.GetEncodeCommand()
|
||||
_ = testutil.ApplyMockIODiscardOutErr(cmd)
|
||||
|
||||
// Build a test transaction
|
||||
builder := txCfg.NewTxBuilder()
|
||||
builder := txConfig.NewTxBuilder()
|
||||
builder.SetGasLimit(50000)
|
||||
builder.SetFeeAmount(sdk.Coins{sdk.NewInt64Coin("atom", 150)})
|
||||
builder.SetMemo("foomemo")
|
||||
jsonEncoded, err := txCfg.TxJSONEncoder()(builder.GetTx())
|
||||
jsonEncoded, err := txConfig.TxJSONEncoder()(builder.GetTx())
|
||||
require.NoError(t, err)
|
||||
|
||||
txFile := testutil.WriteToNewTempFile(t, string(jsonEncoded))
|
||||
@@ -47,8 +36,8 @@ func TestGetCommandEncode(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
clientCtx := client.Context{}.
|
||||
WithTxConfig(txCfg).
|
||||
WithCodec(codec)
|
||||
WithTxConfig(txConfig).
|
||||
WithCodec(cdc)
|
||||
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
|
||||
|
||||
cmd.SetArgs([]string{txFileName})
|
||||
@@ -57,31 +46,21 @@ func TestGetCommandEncode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCommandDecode(t *testing.T) {
|
||||
var (
|
||||
txCfg client.TxConfig
|
||||
legacyAmino *codec.LegacyAmino
|
||||
codec codec.Codec
|
||||
)
|
||||
|
||||
err := depinject.Inject(
|
||||
authtestutil.AppConfig,
|
||||
&txCfg,
|
||||
&legacyAmino,
|
||||
&codec,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
|
||||
txConfig := encodingConfig.TxConfig
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
clientCtx := client.Context{}.
|
||||
WithTxConfig(txCfg).
|
||||
WithCodec(codec)
|
||||
WithTxConfig(txConfig).
|
||||
WithCodec(cdc)
|
||||
|
||||
cmd := cli.GetDecodeCommand()
|
||||
_ = testutil.ApplyMockIODiscardOutErr(cmd)
|
||||
|
||||
clientCtx = clientCtx.WithTxConfig(txCfg)
|
||||
clientCtx = clientCtx.WithTxConfig(txConfig)
|
||||
|
||||
// Build a test transaction
|
||||
builder := txCfg.NewTxBuilder()
|
||||
builder := txConfig.NewTxBuilder()
|
||||
builder.SetGasLimit(50000)
|
||||
builder.SetFeeAmount(sdk.Coins{sdk.NewInt64Coin("atom", 150)})
|
||||
builder.SetMemo("foomemo")
|
||||
|
||||
+16
-27
@@ -7,15 +7,13 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"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"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil"
|
||||
)
|
||||
|
||||
func TestParseQueryResponse(t *testing.T) {
|
||||
@@ -38,39 +36,33 @@ func TestParseQueryResponse(t *testing.T) {
|
||||
|
||||
func TestReadTxFromFile(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
txCfg client.TxConfig
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
)
|
||||
err := depinject.Inject(
|
||||
authtestutil.AppConfig,
|
||||
&interfaceRegistry,
|
||||
&txCfg,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig()
|
||||
interfaceRegistry := encodingConfig.InterfaceRegistry
|
||||
txConfig := encodingConfig.TxConfig
|
||||
|
||||
clientCtx := client.Context{}
|
||||
clientCtx = clientCtx.WithInterfaceRegistry(interfaceRegistry)
|
||||
clientCtx = clientCtx.WithTxConfig(txCfg)
|
||||
clientCtx = clientCtx.WithTxConfig(txConfig)
|
||||
|
||||
feeAmount := sdk.Coins{sdk.NewInt64Coin("atom", 150)}
|
||||
gasLimit := uint64(50000)
|
||||
memo := "foomemo"
|
||||
|
||||
txBuilder := txCfg.NewTxBuilder()
|
||||
txBuilder := txConfig.NewTxBuilder()
|
||||
txBuilder.SetFeeAmount(feeAmount)
|
||||
txBuilder.SetGasLimit(gasLimit)
|
||||
txBuilder.SetMemo(memo)
|
||||
|
||||
// Write it to the file
|
||||
encodedTx, err := txCfg.TxJSONEncoder()(txBuilder.GetTx())
|
||||
encodedTx, err := txConfig.TxJSONEncoder()(txBuilder.GetTx())
|
||||
require.NoError(t, err)
|
||||
|
||||
jsonTxFile := testutil.WriteToNewTempFile(t, string(encodedTx))
|
||||
// Read it back
|
||||
decodedTx, err := authclient.ReadTxFromFile(clientCtx, jsonTxFile.Name())
|
||||
require.NoError(t, err)
|
||||
txBldr, err := txCfg.WrapTxBuilder(decodedTx)
|
||||
txBldr, err := txConfig.WrapTxBuilder(decodedTx)
|
||||
require.NoError(t, err)
|
||||
t.Log(txBuilder.GetTx())
|
||||
t.Log(txBldr.GetTx())
|
||||
@@ -80,22 +72,19 @@ func TestReadTxFromFile(t *testing.T) {
|
||||
|
||||
func TestBatchScanner_Scan(t *testing.T) {
|
||||
t.Parallel()
|
||||
var txGen client.TxConfig
|
||||
err := depinject.Inject(
|
||||
authtestutil.AppConfig,
|
||||
&txGen,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
|
||||
txConfig := encodingConfig.TxConfig
|
||||
|
||||
clientCtx := client.Context{}
|
||||
clientCtx = clientCtx.WithTxConfig(txGen)
|
||||
clientCtx = clientCtx.WithTxConfig(txConfig)
|
||||
|
||||
// generate some tx JSON
|
||||
bldr := txGen.NewTxBuilder()
|
||||
bldr := txConfig.NewTxBuilder()
|
||||
bldr.SetGasLimit(50000)
|
||||
bldr.SetFeeAmount(sdk.NewCoins(sdk.NewInt64Coin("atom", 150)))
|
||||
bldr.SetMemo("foomemo")
|
||||
txJSON, err := txGen.TxJSONEncoder()(bldr.GetTx())
|
||||
txJSON, err := txConfig.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)
|
||||
|
||||
+4
-13
@@ -5,16 +5,14 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/testutil"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -38,16 +36,9 @@ var (
|
||||
// Then it tests integrating the 2 AuxSignerData into a
|
||||
// client.TxBuilder created by the fee payer.
|
||||
func TestBuilderWithAux(t *testing.T) {
|
||||
var (
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
txConfig client.TxConfig
|
||||
)
|
||||
|
||||
err := depinject.Inject(testutil.AppConfig,
|
||||
&interfaceRegistry,
|
||||
&txConfig,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig()
|
||||
interfaceRegistry := encodingConfig.InterfaceRegistry
|
||||
txConfig := encodingConfig.TxConfig
|
||||
|
||||
testdata.RegisterInterfaces(interfaceRegistry)
|
||||
|
||||
|
||||
@@ -67,9 +67,9 @@ func TestBaseSequence(t *testing.T) {
|
||||
|
||||
func TestBaseAccountMarshal(t *testing.T) {
|
||||
var accountKeeper authkeeper.AccountKeeper
|
||||
|
||||
err := depinject.Inject(testutil.AppConfig, &accountKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, pub, addr := testdata.KeyTestPubAddr()
|
||||
acc := types.NewBaseAccountWithAddress(addr)
|
||||
seq := uint64(7)
|
||||
|
||||
@@ -4,15 +4,14 @@ import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/testutil"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
@@ -54,8 +53,8 @@ func TestValidateGenesisDuplicateAccounts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenesisAccountIterator(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
depinject.Inject(testutil.AppConfig, &cdc)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
acc1 := types.NewBaseAccountWithAddress(sdk.AccAddress(addr1))
|
||||
acc2 := types.NewBaseAccountWithAddress(sdk.AccAddress(addr2))
|
||||
|
||||
@@ -4,25 +4,25 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"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/authz"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/authz/migrations/v2"
|
||||
authztestutil "github.com/cosmos/cosmos-sdk/x/authz/testutil"
|
||||
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
|
||||
func TestMigration(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
depinject.Inject(authztestutil.AppConfig, &cdc)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{}, bank.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
authzKey := storetypes.NewKVStoreKey("authz")
|
||||
ctx := testutil.DefaultContext(authzKey, storetypes.NewTransientStoreKey("transient_test"))
|
||||
|
||||
@@ -6,14 +6,13 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
@@ -25,9 +24,8 @@ var (
|
||||
)
|
||||
|
||||
func TestDecodeDistributionStore(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
err := depinject.Inject(testutil.AppConfig, &cdc)
|
||||
require.NoError(t, err)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
dec := simulation.NewDecodeStore(cdc)
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
@@ -21,6 +20,7 @@ import (
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/simulation"
|
||||
distrtestutil "github.com/cosmos/cosmos-sdk/x/distribution/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@@ -234,15 +234,7 @@ func (suite *SimTestSuite) SetupTest() {
|
||||
appBuilder *runtime.AppBuilder
|
||||
err error
|
||||
)
|
||||
suite.app, err = simtestutil.Setup(configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.DistributionModule(),
|
||||
), &suite.accountKeeper,
|
||||
suite.app, err = simtestutil.Setup(distrtestutil.AppConfig, &suite.accountKeeper,
|
||||
&suite.bankKeeper,
|
||||
&suite.cdc,
|
||||
&appBuilder,
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
|
||||
func TestDecodeStore(t *testing.T) {
|
||||
var evidenceKeeper keeper.Keeper
|
||||
|
||||
err := depinject.Inject(testutil.AppConfig, &evidenceKeeper)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -4,23 +4,21 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/feegrant"
|
||||
v2 "cosmossdk.io/x/feegrant/migrations/v2"
|
||||
feegranttestutil "cosmossdk.io/x/feegrant/testutil"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"cosmossdk.io/x/feegrant/module"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
func TestMigration(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
depinject.Inject(feegranttestutil.AppConfig, &cdc)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
feegrantKey := storetypes.NewKVStoreKey(v2.ModuleName)
|
||||
ctx := testutil.DefaultContext(feegrantKey, storetypes.NewTransientStoreKey("transient_test"))
|
||||
|
||||
@@ -6,14 +6,13 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/x/feegrant"
|
||||
"cosmossdk.io/x/feegrant/module"
|
||||
"cosmossdk.io/x/feegrant/simulation"
|
||||
feegranttestutil "cosmossdk.io/x/feegrant/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -23,8 +22,8 @@ var (
|
||||
)
|
||||
|
||||
func TestDecodeStore(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
depinject.Inject(feegranttestutil.AppConfig, &cdc)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
dec := simulation.NewDecodeStore(cdc)
|
||||
|
||||
grant, err := feegrant.NewGrant(granterAddr, granteeAddr, &feegrant.BasicAllowance{
|
||||
|
||||
@@ -5,15 +5,25 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
_ "cosmossdk.io/x/feegrant/module"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/auth"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/bank"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/consensus"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/mint"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/params"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
||||
"cosmossdk.io/x/feegrant"
|
||||
"cosmossdk.io/x/feegrant/keeper"
|
||||
"cosmossdk.io/x/feegrant/simulation"
|
||||
"cosmossdk.io/x/feegrant/testutil"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
@@ -38,7 +48,16 @@ type SimTestSuite struct {
|
||||
|
||||
func (suite *SimTestSuite) SetupTest() {
|
||||
var err error
|
||||
suite.app, err = simtestutil.Setup(testutil.AppConfig,
|
||||
suite.app, err = simtestutil.Setup(configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.GenutilModule(),
|
||||
configurator.FeegrantModule(),
|
||||
),
|
||||
&suite.feegrantKeeper,
|
||||
&suite.bankKeeper,
|
||||
&suite.accountKeeper,
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
|
||||
_ "cosmossdk.io/x/feegrant/module" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/auth/vesting" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/mint" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
|
||||
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.ConsensusModule(),
|
||||
configurator.ParamsModule(),
|
||||
configurator.GenutilModule(),
|
||||
configurator.FeegrantModule(),
|
||||
configurator.VestingModule(),
|
||||
)
|
||||
@@ -5,10 +5,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/module"
|
||||
)
|
||||
|
||||
// TestGogoUnmarshalProposal tests some weird behavior in gogoproto
|
||||
@@ -16,9 +15,8 @@ import (
|
||||
// This test serves as a showcase that we need to be careful when unmarshalling
|
||||
// multiple times into the same reference.
|
||||
func TestGogoUnmarshalProposal(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
err := depinject.Inject(testutil.AppConfig, &cdc)
|
||||
require.NoError(t, err)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
p1 := group.Proposal{Proposers: []string{"foo"}}
|
||||
p2 := group.Proposal{Proposers: []string{"bar"}}
|
||||
|
||||
@@ -6,21 +6,19 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/internal/orm"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/simulation"
|
||||
grouptestutil "github.com/cosmos/cosmos-sdk/x/group/testutil"
|
||||
)
|
||||
|
||||
func TestDecodeStore(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
err := depinject.Inject(grouptestutil.AppConfig, &cdc)
|
||||
require.NoError(t, err)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
dec := simulation.NewDecodeStore(cdc)
|
||||
|
||||
g := group.GroupInfo{Id: 1}
|
||||
|
||||
@@ -7,20 +7,19 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/testutil"
|
||||
)
|
||||
|
||||
func TestRandomizedGenState(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
err := depinject.Inject(testutil.AppConfig, &cdc)
|
||||
require.NoError(t, err)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(groupmodule.AppModuleBasic{}, bank.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
s := rand.NewSource(1)
|
||||
r := rand.New(s)
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"cosmossdk.io/depinject"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdktestutil "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/params"
|
||||
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/testutil"
|
||||
)
|
||||
|
||||
func testComponents() (*codec.LegacyAmino, sdk.Context, storetypes.StoreKey, storetypes.StoreKey, paramskeeper.Keeper) {
|
||||
var cdc codec.Codec
|
||||
if err := depinject.Inject(testutil.AppConfig, &cdc); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(params.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
|
||||
legacyAmino := createTestCodec()
|
||||
mkey := storetypes.NewKVStoreKey("test")
|
||||
|
||||
@@ -11,14 +11,14 @@ import (
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/store"
|
||||
"cosmossdk.io/store/metrics"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/testutil"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
paramsmodule "github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
@@ -39,11 +39,9 @@ func (suite *SubspaceTestSuite) SetupTest() {
|
||||
ms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db)
|
||||
suite.NoError(ms.LoadLatestVersion())
|
||||
|
||||
err := depinject.Inject(testutil.AppConfig,
|
||||
&suite.cdc,
|
||||
&suite.amino,
|
||||
)
|
||||
suite.NoError(err)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(paramsmodule.AppModuleBasic{})
|
||||
suite.cdc = encodingConfig.Codec
|
||||
suite.amino = encodingConfig.Amino
|
||||
|
||||
ss := types.NewSubspace(suite.cdc, suite.amino, key, tkey, "testsubspace")
|
||||
suite.ctx = sdk.NewContext(ms, cmtproto.Header{}, false, log.NewNopLogger())
|
||||
|
||||
@@ -8,13 +8,12 @@ import (
|
||||
gogotypes "github.com/cosmos/gogoproto/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
)
|
||||
|
||||
@@ -26,8 +25,8 @@ var (
|
||||
)
|
||||
|
||||
func TestDecodeStore(t *testing.T) {
|
||||
var cdc codec.Codec
|
||||
depinject.Inject(testutil.AppConfig, &cdc)
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(slashing.AppModuleBasic{})
|
||||
cdc := encodingConfig.Codec
|
||||
dec := simulation.NewDecodeStore(cdc)
|
||||
|
||||
info := types.NewValidatorSigningInfo(consAddr1, 0, 1, time.Now().UTC(), false, 0)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@@ -16,15 +15,13 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
)
|
||||
|
||||
// TestRandomizedGenState tests the normal scenario of applying RandomizedGenState.
|
||||
// Abonormal scenarios are not tested here.
|
||||
func TestRandomizedGenState(t *testing.T) {
|
||||
var interfaceRegistry codectypes.InterfaceRegistry
|
||||
depinject.Inject(testutil.AppConfig, &interfaceRegistry)
|
||||
interfaceRegistry := codectypes.NewInterfaceRegistry()
|
||||
cdc := codec.NewProtoCodec(interfaceRegistry)
|
||||
|
||||
s := rand.NewSource(1)
|
||||
@@ -60,8 +57,7 @@ func TestRandomizedGenState(t *testing.T) {
|
||||
|
||||
// TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState.
|
||||
func TestRandomizedGenState1(t *testing.T) {
|
||||
var interfaceRegistry codectypes.InterfaceRegistry
|
||||
depinject.Inject(testutil.AppConfig, &interfaceRegistry)
|
||||
interfaceRegistry := codectypes.NewInterfaceRegistry()
|
||||
cdc := codec.NewProtoCodec(interfaceRegistry)
|
||||
|
||||
s := rand.NewSource(1)
|
||||
|
||||
Reference in New Issue
Block a user