refactor!: make simapp.MakeTestEncodingConfig private (#12747)
* feat: make `simapp.MakeTestEncodingConfig` private * fix legacy build * update changelog and upgrading.md * updates docs
This commit is contained in:
@@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* (simapp) [#12747](https://github.com/cosmos/cosmos-sdk/pull/12747) Remove `simapp.MakeTestEncodingConfig`. Please use `moduletestutil.MakeTestEncodingConfig` (`types/module/testutil`) in tests instead.
|
||||
* (x/bank) [#12648](https://github.com/cosmos/cosmos-sdk/pull/12648) `NewSendAuthorization` takes a new argument of an optional list of addresses allowed to receive bank assests via authz MsgSend grant. You can pass `nil` for the same behavior as before, i.e. any recipient is allowed.
|
||||
* (x/bank) [\#12593](https://github.com/cosmos/cosmos-sdk/pull/12593) Add `SpendableCoin` method to `BaseViewKeeper`
|
||||
* (x/slashing) [#12581](https://github.com/cosmos/cosmos-sdk/pull/12581) Remove `x/slashing` legacy querier.
|
||||
|
||||
+8
-2
@@ -11,8 +11,14 @@ This means that modules are injected directly into SimApp thanks to a [configura
|
||||
The old behavior is preserved and still can be used, without the dependency injection framework, as shows [`app_legacy.go`](https://github.com/cosmos/cosmos-sdk/blob/main/simapp/app_legacy.go).
|
||||
|
||||
The constructor, `NewSimApp` has been simplified:
|
||||
- `NewSimApp` does not take encoding parameters (`encodingConfig`) as input, instead the encoding parameters are injected (when using app wiring), or directly created in the constructor. Instead, we can instantiate `SimApp` for getting the encoding configuration.
|
||||
- `NewSimApp` now uses `AppOptions` for getting the home path (`homePath`) and the invariant checks period (`invCheckPeriod`). These were unnecessary given as arguments as they were already present in the `AppOptions`.
|
||||
|
||||
* `NewSimApp` does not take encoding parameters (`encodingConfig`) as input, instead the encoding parameters are injected (when using app wiring), or directly created in the constructor. Instead, we can instantiate `SimApp` for getting the encoding configuration.
|
||||
* `NewSimApp` now uses `AppOptions` for getting the home path (`homePath`) and the invariant checks period (`invCheckPeriod`). These were unnecessary given as arguments as they were already present in the `AppOptions`.
|
||||
|
||||
### Encoding
|
||||
|
||||
`simapp.MakeTestEncodingConfig()` was deprecated and has been removed. Instead you can use the `TestEncodingConfig` from the `types/module/testutil` package.
|
||||
This means you can replace your usage of `simapp.MakeTestEncodingConfig` in tests to `moduletestutil.MakeTestEncodingConfig`, which takes a series of relevant `AppModuleBasic` as input (the module being tested and any potential dependencies).
|
||||
|
||||
## [v0.46.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0)
|
||||
|
||||
|
||||
@@ -121,12 +121,11 @@ import (
|
||||
)
|
||||
|
||||
func sendTx() error {
|
||||
// Choose your codec: Amino or Protobuf. Here, we use Protobuf, given by the
|
||||
// following function.
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
// Choose your codec: Amino or Protobuf. Here, we use Protobuf, given by the following function.
|
||||
app := simapp.NewSimApp(...)
|
||||
|
||||
// Create a new TxBuilder.
|
||||
txBuilder := encCfg.TxConfig.NewTxBuilder()
|
||||
txBuilder := app.TxConfig().NewTxBuilder()
|
||||
|
||||
// --snip--
|
||||
}
|
||||
|
||||
+12
-1
@@ -27,6 +27,8 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server/api"
|
||||
"github.com/cosmos/cosmos-sdk/server/config"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
"github.com/cosmos/cosmos-sdk/store/streaming"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar"
|
||||
@@ -211,7 +213,7 @@ func NewSimApp(
|
||||
appOpts servertypes.AppOptions,
|
||||
baseAppOptions ...func(*baseapp.BaseApp),
|
||||
) *SimApp {
|
||||
encodingConfig := MakeTestEncodingConfig()
|
||||
encodingConfig := makeEncodingConfig()
|
||||
|
||||
appCodec := encodingConfig.Codec
|
||||
legacyAmino := encodingConfig.Amino
|
||||
@@ -684,3 +686,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
|
||||
|
||||
return paramsKeeper
|
||||
}
|
||||
|
||||
func makeEncodingConfig() simappparams.EncodingConfig {
|
||||
encodingConfig := simappparams.MakeTestEncodingConfig()
|
||||
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
|
||||
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
|
||||
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
|
||||
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
|
||||
return encodingConfig
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package simapp
|
||||
|
||||
import (
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
)
|
||||
|
||||
// MakeTestEncodingConfig creates an EncodingConfig for testing. This function
|
||||
// should be used only in tests or when creating a new app instance (NewApp*()).
|
||||
// App user shouldn't create new codecs - use the app.AppCodec instead.
|
||||
// [DEPRECATED]
|
||||
func MakeTestEncodingConfig() simappparams.EncodingConfig {
|
||||
encodingConfig := simappparams.MakeTestEncodingConfig()
|
||||
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
|
||||
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
|
||||
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
|
||||
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
|
||||
return encodingConfig
|
||||
}
|
||||
@@ -16,10 +16,11 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simcmd "github.com/cosmos/cosmos-sdk/simapp/simd/cmd"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
|
||||
)
|
||||
@@ -73,7 +74,7 @@ func TestAddGenesisAccountCmd(t *testing.T) {
|
||||
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
|
||||
require.NoError(t, err)
|
||||
|
||||
appCodec := simapp.MakeTestEncodingConfig().Codec
|
||||
appCodec := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}).Codec
|
||||
err = genutiltest.ExecInitCmd(testMbm, home, appCodec)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -13,14 +13,17 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
)
|
||||
|
||||
func Test_TestnetCmd(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
encodingConfig := simapp.MakeTestEncodingConfig()
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, auth.AppModuleBasic{})
|
||||
logger := log.NewNopLogger()
|
||||
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
|
||||
require.NoError(t, err)
|
||||
|
||||
+9
-8
@@ -10,6 +10,7 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
@@ -96,8 +97,8 @@ func TestSendNotEnoughBalance(t *testing.T) {
|
||||
|
||||
sendMsg := types.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)})
|
||||
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
txGen := simapp.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1)
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1)
|
||||
require.Error(t, err)
|
||||
|
||||
simapp.CheckBalance(t, app, addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 67)})
|
||||
@@ -171,8 +172,8 @@ func TestMsgMultiSendWithAccounts(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
txGen := simapp.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err)
|
||||
} else {
|
||||
@@ -221,8 +222,8 @@ func TestMsgMultiSendMultipleOut(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
txGen := simapp.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, eb := range tc.expectedBalances {
|
||||
@@ -273,8 +274,8 @@ func TestMsgMultiSendDependent(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
txGen := simapp.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, eb := range tc.expectedBalances {
|
||||
|
||||
@@ -18,10 +18,13 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
@@ -83,7 +86,7 @@ type IntegrationTestSuite struct {
|
||||
func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[string]bool) (authkeeper.AccountKeeper, keeper.BaseKeeper) {
|
||||
app := suite.app
|
||||
maccPerms := simapp.GetMaccPerms()
|
||||
appCodec := simapp.MakeTestEncodingConfig().Codec
|
||||
appCodec := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}, bank.AppModuleBasic{}).Codec
|
||||
|
||||
maccPerms[holder] = nil
|
||||
maccPerms[authtypes.Burner] = []string{authtypes.Burner}
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
func TestMigrateJSON(t *testing.T) {
|
||||
encodingConfig := simapp.MakeTestEncodingConfig()
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig()
|
||||
clientCtx := client.Context{}.
|
||||
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
||||
WithTxConfig(encodingConfig.TxConfig).
|
||||
|
||||
@@ -6,18 +6,18 @@ import (
|
||||
"cosmossdk.io/math"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
"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"
|
||||
v1bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v1"
|
||||
v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
func TestSupplyMigration(t *testing.T) {
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig()
|
||||
bankKey := sdk.NewKVStoreKey("bank")
|
||||
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
|
||||
store := ctx.KVStore(bankKey)
|
||||
@@ -68,7 +68,7 @@ func TestSupplyMigration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBalanceKeysMigration(t *testing.T) {
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig()
|
||||
bankKey := sdk.NewKVStoreKey("bank")
|
||||
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
|
||||
store := ctx.KVStore(bankKey)
|
||||
|
||||
@@ -6,18 +6,18 @@ import (
|
||||
"cosmossdk.io/math"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2"
|
||||
v3 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v3"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
func TestMigrateStore(t *testing.T) {
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig()
|
||||
bankKey := sdk.NewKVStoreKey("bank")
|
||||
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
|
||||
store := ctx.KVStore(bankKey)
|
||||
@@ -55,7 +55,7 @@ func TestMigrateStore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMigrateDenomMetaData(t *testing.T) {
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig()
|
||||
bankKey := sdk.NewKVStoreKey("bank")
|
||||
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
|
||||
store := ctx.KVStore(bankKey)
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
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/bank/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
@@ -40,9 +40,8 @@ type GenTxTestSuite struct {
|
||||
|
||||
ctx sdk.Context
|
||||
app *simapp.SimApp
|
||||
encodingConfig simappparams.EncodingConfig
|
||||
|
||||
msg1, msg2 *stakingtypes.MsgCreateValidator
|
||||
encodingConfig moduletestutil.TestEncodingConfig
|
||||
msg1, msg2 *stakingtypes.MsgCreateValidator
|
||||
}
|
||||
|
||||
func (suite *GenTxTestSuite) SetupTest() {
|
||||
@@ -50,7 +49,12 @@ func (suite *GenTxTestSuite) SetupTest() {
|
||||
app := simapp.Setup(suite.T(), checkTx)
|
||||
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{})
|
||||
suite.app = app
|
||||
suite.encodingConfig = simapp.MakeTestEncodingConfig()
|
||||
suite.encodingConfig = moduletestutil.TestEncodingConfig{
|
||||
InterfaceRegistry: app.InterfaceRegistry(),
|
||||
Codec: app.AppCodec(),
|
||||
TxConfig: app.TxConfig(),
|
||||
Amino: app.LegacyAmino(),
|
||||
}
|
||||
|
||||
var err error
|
||||
amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)
|
||||
|
||||
@@ -10,10 +10,12 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
@@ -46,14 +48,14 @@ func TestValidateGenesisMultipleMessages(t *testing.T) {
|
||||
sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, math.OneInt())
|
||||
require.NoError(t, err)
|
||||
|
||||
txGen := simapp.MakeTestEncodingConfig().TxConfig
|
||||
txBuilder := txGen.NewTxBuilder()
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, genutil.AppModuleBasic{}).TxConfig
|
||||
txBuilder := txConfig.NewTxBuilder()
|
||||
require.NoError(t, txBuilder.SetMsgs(msg1, msg2))
|
||||
|
||||
tx := txBuilder.GetTx()
|
||||
genesisState := types.NewGenesisStateFromTx(txGen.TxJSONEncoder(), []sdk.Tx{tx})
|
||||
genesisState := types.NewGenesisStateFromTx(txConfig.TxJSONEncoder(), []sdk.Tx{tx})
|
||||
|
||||
err = types.ValidateGenesis(genesisState, simapp.MakeTestEncodingConfig().TxConfig.TxJSONDecoder())
|
||||
err = types.ValidateGenesis(genesisState, txConfig.TxJSONDecoder())
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -62,15 +64,15 @@ func TestValidateGenesisBadMessage(t *testing.T) {
|
||||
|
||||
msg1 := stakingtypes.NewMsgEditValidator(sdk.ValAddress(pk1.Address()), desc, nil, nil)
|
||||
|
||||
txGen := simapp.MakeTestEncodingConfig().TxConfig
|
||||
txBuilder := txGen.NewTxBuilder()
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, genutil.AppModuleBasic{}).TxConfig
|
||||
txBuilder := txConfig.NewTxBuilder()
|
||||
err := txBuilder.SetMsgs(msg1)
|
||||
require.NoError(t, err)
|
||||
|
||||
tx := txBuilder.GetTx()
|
||||
genesisState := types.NewGenesisStateFromTx(txGen.TxJSONEncoder(), []sdk.Tx{tx})
|
||||
genesisState := types.NewGenesisStateFromTx(txConfig.TxJSONEncoder(), []sdk.Tx{tx})
|
||||
|
||||
err = types.ValidateGenesis(genesisState, simapp.MakeTestEncodingConfig().TxConfig.TxJSONDecoder())
|
||||
err = types.ValidateGenesis(genesisState, txConfig.TxJSONDecoder())
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@ import (
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/client/utils"
|
||||
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
)
|
||||
@@ -75,7 +76,7 @@ func (mock TxSearchMock) Block(ctx context.Context, height *int64) (*coretypes.R
|
||||
}
|
||||
|
||||
func TestGetPaginatedVotes(t *testing.T) {
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig(gov.AppModuleBasic{})
|
||||
|
||||
type testCase struct {
|
||||
description string
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@@ -41,7 +42,7 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
|
||||
addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000))
|
||||
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
|
||||
pks := simtestutil.CreateTestPubKeys(5)
|
||||
cdc := simapp.MakeTestEncodingConfig().Codec
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
|
||||
app.StakingKeeper = stakingkeeper.NewKeeper(
|
||||
cdc,
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
|
||||
func TestMigrateJSON(t *testing.T) {
|
||||
encodingConfig := simapp.MakeTestEncodingConfig()
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig()
|
||||
clientCtx := client.Context{}.
|
||||
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
||||
WithTxConfig(encodingConfig.TxConfig).
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"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"
|
||||
v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042"
|
||||
v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMigrateStore(t *testing.T) {
|
||||
cdc := simapp.MakeTestEncodingConfig().Codec
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
govKey := sdk.NewKVStoreKey("gov")
|
||||
ctx := testutil.DefaultContext(govKey, sdk.NewTransientStoreKey("transient_test"))
|
||||
store := ctx.KVStore(govKey)
|
||||
|
||||
@@ -10,9 +10,10 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
v046 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
@@ -20,7 +21,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMigrateJSON(t *testing.T) {
|
||||
encodingConfig := simapp.MakeTestEncodingConfig()
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(gov.AppModuleBasic{})
|
||||
clientCtx := client.Context{}.
|
||||
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
||||
WithTxConfig(encodingConfig.TxConfig).
|
||||
|
||||
@@ -6,18 +6,20 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"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/gov"
|
||||
v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042"
|
||||
v046gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046"
|
||||
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
"github.com/cosmos/cosmos-sdk/x/upgrade"
|
||||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||
)
|
||||
|
||||
func TestMigrateStore(t *testing.T) {
|
||||
cdc := simapp.MakeTestEncodingConfig().Codec
|
||||
cdc := moduletestutil.MakeTestEncodingConfig(upgrade.AppModuleBasic{}, gov.AppModuleBasic{}).Codec
|
||||
govKey := sdk.NewKVStoreKey("gov")
|
||||
ctx := testutil.DefaultContext(govKey, sdk.NewTransientStoreKey("transient_test"))
|
||||
store := ctx.KVStore(govKey)
|
||||
|
||||
@@ -10,9 +10,10 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
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/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
@@ -24,7 +25,7 @@ var (
|
||||
)
|
||||
|
||||
func TestDecodeStore(t *testing.T) {
|
||||
cdc := simapp.MakeTestEncodingConfig().Codec
|
||||
cdc := moduletestutil.MakeTestEncodingConfig(gov.AppModuleBasic{}).Codec
|
||||
dec := simulation.NewDecodeStore(cdc)
|
||||
|
||||
endTime := time.Now().UTC()
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
@@ -70,8 +71,8 @@ func TestSlashingMsgs(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
txGen := simapp.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1)
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1)
|
||||
require.NoError(t, err)
|
||||
simapp.CheckBalance(t, app, addr1, sdk.Coins{genCoin.Sub(bondCoin)})
|
||||
|
||||
@@ -88,7 +89,7 @@ func TestSlashingMsgs(t *testing.T) {
|
||||
|
||||
// unjail should fail with unknown validator
|
||||
header = tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
_, res, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1)
|
||||
_, res, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1)
|
||||
require.Error(t, err)
|
||||
require.Nil(t, res)
|
||||
require.True(t, errors.Is(types.ErrValidatorNotJailed, err))
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@@ -71,8 +72,8 @@ func TestStakingMsgs(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
txGen := simapp.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1)
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
_, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1)
|
||||
require.NoError(t, err)
|
||||
simapp.CheckBalance(t, app, addr1, sdk.Coins{genCoin.Sub(bondCoin)})
|
||||
|
||||
@@ -92,7 +93,7 @@ func TestStakingMsgs(t *testing.T) {
|
||||
editValidatorMsg := types.NewMsgEditValidator(sdk.ValAddress(addr1), description, nil, nil)
|
||||
|
||||
header = tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
_, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{editValidatorMsg}, "", []uint64{0}, []uint64{1}, true, true, priv1)
|
||||
_, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{editValidatorMsg}, "", []uint64{0}, []uint64{1}, true, true, priv1)
|
||||
require.NoError(t, err)
|
||||
|
||||
validator = checkValidator(t, app, sdk.ValAddress(addr1), true)
|
||||
@@ -103,7 +104,7 @@ func TestStakingMsgs(t *testing.T) {
|
||||
delegateMsg := types.NewMsgDelegate(addr2, sdk.ValAddress(addr1), bondCoin)
|
||||
|
||||
header = tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
_, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2)
|
||||
_, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2)
|
||||
require.NoError(t, err)
|
||||
|
||||
simapp.CheckBalance(t, app, addr2, sdk.Coins{genCoin.Sub(bondCoin)})
|
||||
@@ -112,7 +113,7 @@ func TestStakingMsgs(t *testing.T) {
|
||||
// begin unbonding
|
||||
beginUnbondingMsg := types.NewMsgUndelegate(addr2, sdk.ValAddress(addr1), bondCoin)
|
||||
header = tmproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
_, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{beginUnbondingMsg}, "", []uint64{1}, []uint64{1}, true, true, priv2)
|
||||
_, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{beginUnbondingMsg}, "", []uint64{1}, []uint64{1}, true, true, priv2)
|
||||
require.NoError(t, err)
|
||||
|
||||
// delegation should exist anymore
|
||||
|
||||
@@ -4,16 +4,18 @@ import (
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
@@ -51,3 +53,38 @@ func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int) ([]sdk
|
||||
|
||||
return addrDels, addrVals
|
||||
}
|
||||
|
||||
func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []types.Validator) {
|
||||
addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, app.StakingKeeper.TokensFromConsensusPower(ctx, 300))
|
||||
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
|
||||
pks := simtestutil.CreateTestPubKeys(5)
|
||||
cdc := moduletestutil.MakeTestEncodingConfig().Codec
|
||||
app.StakingKeeper = keeper.NewKeeper(
|
||||
cdc,
|
||||
app.GetKey(types.StoreKey),
|
||||
app.AccountKeeper,
|
||||
app.BankKeeper,
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
)
|
||||
|
||||
val1 := teststaking.NewValidator(t, valAddrs[0], pks[0])
|
||||
val2 := teststaking.NewValidator(t, valAddrs[1], pks[1])
|
||||
vals := []types.Validator{val1, val2}
|
||||
|
||||
app.StakingKeeper.SetValidator(ctx, val1)
|
||||
app.StakingKeeper.SetValidator(ctx, val2)
|
||||
app.StakingKeeper.SetValidatorByConsAddr(ctx, val1)
|
||||
app.StakingKeeper.SetValidatorByConsAddr(ctx, val2)
|
||||
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val1)
|
||||
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val2)
|
||||
|
||||
_, err := app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[0]), types.Unbonded, val1, true)
|
||||
require.NoError(t, err)
|
||||
_, err = app.StakingKeeper.Delegate(ctx, addrs[1], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[1]), types.Unbonded, val2, true)
|
||||
require.NoError(t, err)
|
||||
_, err = app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[2]), types.Unbonded, val2, true)
|
||||
require.NoError(t, err)
|
||||
applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1)
|
||||
|
||||
return addrs, valAddrs, vals
|
||||
}
|
||||
|
||||
@@ -3,19 +3,10 @@ package keeper_test
|
||||
import (
|
||||
gocontext "context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
@@ -788,38 +779,3 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidatorUnbondingDelegations() {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []types.Validator) {
|
||||
addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, app.StakingKeeper.TokensFromConsensusPower(ctx, 300))
|
||||
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
|
||||
pks := simtestutil.CreateTestPubKeys(5)
|
||||
cdc := simapp.MakeTestEncodingConfig().Codec
|
||||
app.StakingKeeper = keeper.NewKeeper(
|
||||
cdc,
|
||||
app.GetKey(types.StoreKey),
|
||||
app.AccountKeeper,
|
||||
app.BankKeeper,
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
)
|
||||
|
||||
val1 := teststaking.NewValidator(t, valAddrs[0], pks[0])
|
||||
val2 := teststaking.NewValidator(t, valAddrs[1], pks[1])
|
||||
vals := []types.Validator{val1, val2}
|
||||
|
||||
app.StakingKeeper.SetValidator(ctx, val1)
|
||||
app.StakingKeeper.SetValidator(ctx, val2)
|
||||
app.StakingKeeper.SetValidatorByConsAddr(ctx, val1)
|
||||
app.StakingKeeper.SetValidatorByConsAddr(ctx, val2)
|
||||
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val1)
|
||||
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val2)
|
||||
|
||||
_, err := app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[0]), types.Unbonded, val1, true)
|
||||
require.NoError(t, err)
|
||||
_, err = app.StakingKeeper.Delegate(ctx, addrs[1], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[1]), types.Unbonded, val2, true)
|
||||
require.NoError(t, err)
|
||||
_, err = app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[2]), types.Unbonded, val2, true)
|
||||
require.NoError(t, err)
|
||||
applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1)
|
||||
|
||||
return addrs, valAddrs, vals
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
v3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
func TestMigrateJSON(t *testing.T) {
|
||||
encodingConfig := simapp.MakeTestEncodingConfig()
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig()
|
||||
clientCtx := client.Context{}.
|
||||
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
||||
WithTxConfig(encodingConfig.TxConfig).
|
||||
|
||||
@@ -5,16 +5,16 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
|
||||
v3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
func TestStoreMigration(t *testing.T) {
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig()
|
||||
stakingKey := sdk.NewKVStoreKey("staking")
|
||||
tStakingKey := sdk.NewTransientStoreKey("transient_test")
|
||||
ctx := testutil.DefaultContext(stakingKey, tStakingKey)
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
"github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
@@ -33,7 +33,7 @@ func makeTestCodec() (cdc *codec.LegacyAmino) {
|
||||
}
|
||||
|
||||
func TestDecodeStore(t *testing.T) {
|
||||
cdc := simapp.MakeTestEncodingConfig().Codec
|
||||
cdc := testutil.MakeTestEncodingConfig().Codec
|
||||
dec := simulation.NewDecodeStore(cdc)
|
||||
bondTime := time.Now().UTC()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user