diff --git a/x/evidence/genesis_test.go b/x/evidence/genesis_test.go index 6f0ea79411..0e9e7ab2a4 100644 --- a/x/evidence/genesis_test.go +++ b/x/evidence/genesis_test.go @@ -5,15 +5,17 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "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/x/evidence" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/keeper" + "github.com/cosmos/cosmos-sdk/x/evidence/testutil" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) @@ -25,11 +27,13 @@ type GenesisTestSuite struct { } func (suite *GenesisTestSuite) SetupTest() { - checkTx := false - app := simapp.Setup(suite.T(), checkTx) + var evidenceKeeper keeper.Keeper - suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) - suite.keeper = app.EvidenceKeeper + app, err := simtestutil.Setup(testutil.AppConfig, &evidenceKeeper) + require.NoError(suite.T(), err) + + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) + suite.keeper = evidenceKeeper } func (suite *GenesisTestSuite) TestInitGenesis() { diff --git a/x/evidence/keeper/grpc_query_test.go b/x/evidence/keeper/grpc_query_test.go index b6856f19c6..80f2ded86b 100644 --- a/x/evidence/keeper/grpc_query_test.go +++ b/x/evidence/keeper/grpc_query_test.go @@ -49,7 +49,7 @@ func (suite *KeeperTestSuite) TestQueryEvidence() { true, func(res *types.QueryEvidenceResponse) { var evi exported.Evidence - err := suite.app.InterfaceRegistry().UnpackAny(res.Evidence, &evi) + err := suite.interfaceRegistry.UnpackAny(res.Evidence, &evi) suite.Require().NoError(err) suite.Require().NotNil(evi) suite.Require().Equal(evi, evidence[0]) diff --git a/x/evidence/keeper/infraction_test.go b/x/evidence/keeper/infraction_test.go index 4c7368b1df..226e67ba57 100644 --- a/x/evidence/keeper/infraction_test.go +++ b/x/evidence/keeper/infraction_test.go @@ -14,64 +14,64 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign() { suite.populateValidators(ctx) power := int64(100) - stakingParams := suite.app.StakingKeeper.GetParams(ctx) + stakingParams := suite.stakingKeeper.GetParams(ctx) operatorAddr, val := valAddresses[0], pubkeys[0] - tstaking := teststaking.NewHelper(suite.T(), ctx, suite.app.StakingKeeper) + tstaking := teststaking.NewHelper(suite.T(), ctx, suite.stakingKeeper) selfDelegation := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, true) // execute end-blocker and verify validator attributes - staking.EndBlocker(ctx, suite.app.StakingKeeper) + staking.EndBlocker(ctx, suite.stakingKeeper) suite.Equal( - suite.app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(operatorAddr)).String(), + suite.bankKeeper.GetAllBalances(ctx, sdk.AccAddress(operatorAddr)).String(), sdk.NewCoins(sdk.NewCoin(stakingParams.BondDenom, initAmt.Sub(selfDelegation))).String(), ) - suite.Equal(selfDelegation, suite.app.StakingKeeper.Validator(ctx, operatorAddr).GetBondedTokens()) + suite.Equal(selfDelegation, suite.stakingKeeper.Validator(ctx, operatorAddr).GetBondedTokens()) // handle a signature to set signing info - suite.app.SlashingKeeper.HandleValidatorSignature(ctx, val.Address(), selfDelegation.Int64(), true) + suite.slashingKeeper.HandleValidatorSignature(ctx, val.Address(), selfDelegation.Int64(), true) // double sign less than max age - oldTokens := suite.app.StakingKeeper.Validator(ctx, operatorAddr).GetTokens() + oldTokens := suite.stakingKeeper.Validator(ctx, operatorAddr).GetTokens() evidence := &types.Equivocation{ Height: 0, Time: time.Unix(0, 0), Power: power, ConsensusAddress: sdk.ConsAddress(val.Address()).String(), } - suite.app.EvidenceKeeper.HandleEquivocationEvidence(ctx, evidence) + suite.evidenceKeeper.HandleEquivocationEvidence(ctx, evidence) // should be jailed and tombstoned - suite.True(suite.app.StakingKeeper.Validator(ctx, operatorAddr).IsJailed()) - suite.True(suite.app.SlashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(val.Address()))) + suite.True(suite.stakingKeeper.Validator(ctx, operatorAddr).IsJailed()) + suite.True(suite.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(val.Address()))) // tokens should be decreased - newTokens := suite.app.StakingKeeper.Validator(ctx, operatorAddr).GetTokens() + newTokens := suite.stakingKeeper.Validator(ctx, operatorAddr).GetTokens() suite.True(newTokens.LT(oldTokens)) // submit duplicate evidence - suite.app.EvidenceKeeper.HandleEquivocationEvidence(ctx, evidence) + suite.evidenceKeeper.HandleEquivocationEvidence(ctx, evidence) // tokens should be the same (capped slash) - suite.True(suite.app.StakingKeeper.Validator(ctx, operatorAddr).GetTokens().Equal(newTokens)) + suite.True(suite.stakingKeeper.Validator(ctx, operatorAddr).GetTokens().Equal(newTokens)) // jump to past the unbonding period ctx = ctx.WithBlockTime(time.Unix(1, 0).Add(stakingParams.UnbondingTime)) // require we cannot unjail - suite.Error(suite.app.SlashingKeeper.Unjail(ctx, operatorAddr)) + suite.Error(suite.slashingKeeper.Unjail(ctx, operatorAddr)) // require we be able to unbond now ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) - del, _ := suite.app.StakingKeeper.GetDelegation(ctx, sdk.AccAddress(operatorAddr), operatorAddr) - validator, _ := suite.app.StakingKeeper.GetValidator(ctx, operatorAddr) + del, _ := suite.stakingKeeper.GetDelegation(ctx, sdk.AccAddress(operatorAddr), operatorAddr) + validator, _ := suite.stakingKeeper.GetValidator(ctx, operatorAddr) totalBond := validator.TokensFromShares(del.GetShares()).TruncateInt() tstaking.Ctx = ctx tstaking.Denom = stakingParams.BondDenom tstaking.Undelegate(sdk.AccAddress(operatorAddr), operatorAddr, totalBond, true) // query evidence from store - evidences := suite.app.EvidenceKeeper.GetAllEvidence(ctx) + evidences := suite.evidenceKeeper.GetAllEvidence(ctx) suite.Len(evidences, 1) } @@ -80,19 +80,19 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign_TooOld() { suite.populateValidators(ctx) power := int64(100) - stakingParams := suite.app.StakingKeeper.GetParams(ctx) + stakingParams := suite.stakingKeeper.GetParams(ctx) operatorAddr, val := valAddresses[0], pubkeys[0] - tstaking := teststaking.NewHelper(suite.T(), ctx, suite.app.StakingKeeper) + tstaking := teststaking.NewHelper(suite.T(), ctx, suite.stakingKeeper) amt := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, true) // execute end-blocker and verify validator attributes - staking.EndBlocker(ctx, suite.app.StakingKeeper) + staking.EndBlocker(ctx, suite.stakingKeeper) suite.Equal( - suite.app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(operatorAddr)), + suite.bankKeeper.GetAllBalances(ctx, sdk.AccAddress(operatorAddr)), sdk.NewCoins(sdk.NewCoin(stakingParams.BondDenom, initAmt.Sub(amt))), ) - suite.Equal(amt, suite.app.StakingKeeper.Validator(ctx, operatorAddr).GetBondedTokens()) + suite.Equal(amt, suite.stakingKeeper.Validator(ctx, operatorAddr).GetBondedTokens()) evidence := &types.Equivocation{ Height: 0, @@ -106,8 +106,8 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign_TooOld() { ctx = ctx.WithConsensusParams(cp) ctx = ctx.WithBlockTime(ctx.BlockTime().Add(cp.Evidence.MaxAgeDuration + 1)) ctx = ctx.WithBlockHeight(ctx.BlockHeight() + cp.Evidence.MaxAgeNumBlocks + 1) - suite.app.EvidenceKeeper.HandleEquivocationEvidence(ctx, evidence) + suite.evidenceKeeper.HandleEquivocationEvidence(ctx, evidence) - suite.False(suite.app.StakingKeeper.Validator(ctx, operatorAddr).IsJailed()) - suite.False(suite.app.SlashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(val.Address()))) + suite.False(suite.stakingKeeper.Validator(ctx, operatorAddr).IsJailed()) + suite.False(suite.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(val.Address()))) } diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index b0b12176ef..2b80e9869a 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -5,20 +5,29 @@ import ( "fmt" "time" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/runtime" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/keeper" + "github.com/cosmos/cosmos-sdk/x/evidence/testutil" "github.com/cosmos/cosmos-sdk/x/evidence/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( @@ -73,37 +82,56 @@ type KeeperTestSuite struct { ctx sdk.Context querier sdk.Querier - app *simapp.SimApp + app *runtime.App + + evidenceKeeper keeper.Keeper + bankKeeper bankkeeper.Keeper + accountKeeper authkeeper.AccountKeeper + slashingKeeper slashingkeeper.Keeper + stakingKeeper *stakingkeeper.Keeper + interfaceRegistry codectypes.InterfaceRegistry queryClient types.QueryClient } func (suite *KeeperTestSuite) SetupTest() { - checkTx := false - app := simapp.Setup(suite.T(), checkTx) - - // recreate keeper in order to use custom testing types - evidenceKeeper := keeper.NewKeeper( - app.AppCodec(), app.GetKey(types.StoreKey), app.StakingKeeper, app.SlashingKeeper, + var ( + legacyAmino *codec.LegacyAmino + evidenceKeeper keeper.Keeper ) + + app, err := simtestutil.Setup(testutil.AppConfig, + &legacyAmino, + &evidenceKeeper, + &suite.interfaceRegistry, + &suite.accountKeeper, + &suite.bankKeeper, + &suite.slashingKeeper, + &suite.stakingKeeper, + ) + require.NoError(suite.T(), err) + router := types.NewRouter() - router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(*evidenceKeeper)) + router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(evidenceKeeper)) evidenceKeeper.SetRouter(router) - app.EvidenceKeeper = *evidenceKeeper - - suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) - suite.querier = keeper.NewQuerier(*evidenceKeeper, app.LegacyAmino()) + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) + suite.querier = keeper.NewQuerier(evidenceKeeper, legacyAmino) suite.app = app for i, addr := range valAddresses { addr := sdk.AccAddress(addr) - app.AccountKeeper.SetAccount(suite.ctx, authtypes.NewBaseAccount(addr, pubkeys[i], uint64(i), 0)) + suite.accountKeeper.SetAccount(suite.ctx, authtypes.NewBaseAccount(addr, pubkeys[i], uint64(i), 0)) } - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, app.EvidenceKeeper) + suite.stakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks(suite.slashingKeeper.Hooks()), + ) + + queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.interfaceRegistry) + types.RegisterQueryServer(queryHelper, evidenceKeeper) suite.queryClient = types.NewQueryClient(queryHelper) + suite.evidenceKeeper = evidenceKeeper } func (suite *KeeperTestSuite) populateEvidence(ctx sdk.Context, numEvidence int) []exported.Evidence { @@ -119,7 +147,7 @@ func (suite *KeeperTestSuite) populateEvidence(ctx sdk.Context, numEvidence int) ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, evidence[i])) + suite.Nil(suite.evidenceKeeper.SubmitEvidence(ctx, evidence[i])) } return evidence @@ -129,10 +157,10 @@ func (suite *KeeperTestSuite) populateValidators(ctx sdk.Context) { // add accounts and set total supply totalSupplyAmt := initAmt.MulRaw(int64(len(valAddresses))) totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, totalSupplyAmt)) - suite.NoError(suite.app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, totalSupply)) + suite.NoError(suite.bankKeeper.MintCoins(ctx, minttypes.ModuleName, totalSupply)) for _, addr := range valAddresses { - suite.NoError(suite.app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, (sdk.AccAddress)(addr), initCoins)) + suite.NoError(suite.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, (sdk.AccAddress)(addr), initCoins)) } } @@ -147,9 +175,9 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) + suite.Nil(suite.evidenceKeeper.SubmitEvidence(ctx, e)) - res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) + res, ok := suite.evidenceKeeper.GetEvidence(ctx, e.Hash()) suite.True(ok) suite.Equal(e, res) } @@ -165,10 +193,10 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence_Duplicate() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) - suite.Error(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) + suite.Nil(suite.evidenceKeeper.SubmitEvidence(ctx, e)) + suite.Error(suite.evidenceKeeper.SubmitEvidence(ctx, e)) - res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) + res, ok := suite.evidenceKeeper.GetEvidence(ctx, e.Hash()) suite.True(ok) suite.Equal(e, res) } @@ -183,9 +211,9 @@ func (suite *KeeperTestSuite) TestSubmitInvalidEvidence() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Error(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) + suite.Error(suite.evidenceKeeper.SubmitEvidence(ctx, e)) - res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) + res, ok := suite.evidenceKeeper.GetEvidence(ctx, e.Hash()) suite.False(ok) suite.Nil(res) } @@ -195,16 +223,16 @@ func (suite *KeeperTestSuite) TestIterateEvidence() { numEvidence := 100 suite.populateEvidence(ctx, numEvidence) - evidence := suite.app.EvidenceKeeper.GetAllEvidence(ctx) + evidence := suite.evidenceKeeper.GetAllEvidence(ctx) suite.Len(evidence, numEvidence) } func (suite *KeeperTestSuite) TestGetEvidenceHandler() { - handler, err := suite.app.EvidenceKeeper.GetEvidenceHandler((&types.Equivocation{}).Route()) + handler, err := suite.evidenceKeeper.GetEvidenceHandler((&types.Equivocation{}).Route()) suite.NoError(err) suite.NotNil(handler) - handler, err = suite.app.EvidenceKeeper.GetEvidenceHandler("invalidHandler") + handler, err = suite.evidenceKeeper.GetEvidenceHandler("invalidHandler") suite.Error(err) suite.Nil(handler) } diff --git a/x/evidence/keeper/querier_test.go b/x/evidence/keeper/querier_test.go index 709340d241..45989b05f1 100644 --- a/x/evidence/keeper/querier_test.go +++ b/x/evidence/keeper/querier_test.go @@ -3,9 +3,12 @@ package keeper_test import ( "strings" - "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/depinject" + "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/x/evidence/exported" + "github.com/cosmos/cosmos-sdk/x/evidence/testutil" "github.com/cosmos/cosmos-sdk/x/evidence/types" abci "github.com/tendermint/tendermint/abci/types" @@ -18,12 +21,15 @@ const ( func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_Existing() { ctx := suite.ctx.WithIsCheckTx(false) numEvidence := 100 - legacyCdc := simapp.MakeTestEncodingConfig().Amino + + var legacyAmino *codec.LegacyAmino + err := depinject.Inject(testutil.AppConfig, &legacyAmino) + require.NoError(suite.T(), err) evidence := suite.populateEvidence(ctx, numEvidence) query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryEvidence}, "/"), - Data: legacyCdc.MustMarshalJSON(types.NewQueryEvidenceRequest(evidence[0].Hash())), + Data: legacyAmino.MustMarshalJSON(types.NewQueryEvidenceRequest(evidence[0].Hash())), } bz, err := suite.querier(ctx, []string{types.QueryEvidence}, query) @@ -31,15 +37,18 @@ func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_Existing() { suite.NotNil(bz) var e exported.Evidence - suite.Nil(legacyCdc.UnmarshalJSON(bz, &e)) + suite.Nil(legacyAmino.UnmarshalJSON(bz, &e)) suite.Equal(evidence[0], e) } func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_NonExisting() { ctx := suite.ctx.WithIsCheckTx(false) - cdc := simapp.MakeTestEncodingConfig().Codec numEvidence := 100 + var cdc codec.Codec + err := depinject.Inject(testutil.AppConfig, &cdc) + require.NoError(suite.T(), err) + suite.populateEvidence(ctx, numEvidence) query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryEvidence}, "/"), @@ -53,13 +62,16 @@ func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_NonExisting() { func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence() { ctx := suite.ctx.WithIsCheckTx(false) - cdc := simapp.MakeTestEncodingConfig().Amino numEvidence := 100 + var legacyAmino *codec.LegacyAmino + err := depinject.Inject(testutil.AppConfig, &legacyAmino) + require.NoError(suite.T(), err) + suite.populateEvidence(ctx, numEvidence) query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryAllEvidence}, "/"), - Data: cdc.MustMarshalJSON(types.NewQueryAllEvidenceParams(1, numEvidence)), + Data: legacyAmino.MustMarshalJSON(types.NewQueryAllEvidenceParams(1, numEvidence)), } bz, err := suite.querier(ctx, []string{types.QueryAllEvidence}, query) @@ -67,19 +79,22 @@ func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence() { suite.NotNil(bz) var e []exported.Evidence - suite.Nil(cdc.UnmarshalJSON(bz, &e)) + suite.Nil(legacyAmino.UnmarshalJSON(bz, &e)) suite.Len(e, numEvidence) } func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence_InvalidPagination() { ctx := suite.ctx.WithIsCheckTx(false) - cdc := simapp.MakeTestEncodingConfig().Amino numEvidence := 100 + var legacyAmino *codec.LegacyAmino + err := depinject.Inject(testutil.AppConfig, &legacyAmino) + require.NoError(suite.T(), err) + suite.populateEvidence(ctx, numEvidence) query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryAllEvidence}, "/"), - Data: cdc.MustMarshalJSON(types.NewQueryAllEvidenceParams(0, numEvidence)), + Data: legacyAmino.MustMarshalJSON(types.NewQueryAllEvidenceParams(0, numEvidence)), } bz, err := suite.querier(ctx, []string{types.QueryAllEvidence}, query) @@ -87,6 +102,6 @@ func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence_InvalidPagination() { suite.NotNil(bz) var e []exported.Evidence - suite.Nil(cdc.UnmarshalJSON(bz, &e)) + suite.Nil(legacyAmino.UnmarshalJSON(bz, &e)) suite.Len(e, 0) } diff --git a/x/evidence/simulation/decoder_test.go b/x/evidence/simulation/decoder_test.go index d23d796a08..2fa58f43fd 100644 --- a/x/evidence/simulation/decoder_test.go +++ b/x/evidence/simulation/decoder_test.go @@ -8,16 +8,22 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/depinject" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" + "github.com/cosmos/cosmos-sdk/x/evidence/keeper" "github.com/cosmos/cosmos-sdk/x/evidence/simulation" + "github.com/cosmos/cosmos-sdk/x/evidence/testutil" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) func TestDecodeStore(t *testing.T) { - app := simapp.Setup(t, false) - dec := simulation.NewDecodeStore(app.EvidenceKeeper) + var evidenceKeeper keeper.Keeper + + err := depinject.Inject(testutil.AppConfig, &evidenceKeeper) + require.NoError(t, err) + + dec := simulation.NewDecodeStore(evidenceKeeper) delPk1 := ed25519.GenPrivKey().PubKey() @@ -28,7 +34,7 @@ func TestDecodeStore(t *testing.T) { ConsensusAddress: sdk.ConsAddress(delPk1.Address()).String(), } - evBz, err := app.EvidenceKeeper.MarshalEvidence(ev) + evBz, err := evidenceKeeper.MarshalEvidence(ev) require.NoError(t, err) kvPairs := kv.Pairs{ diff --git a/x/evidence/spec/01_concepts.md b/x/evidence/spec/01_concepts.md index 926a573bb1..e18c8c25fc 100644 --- a/x/evidence/spec/01_concepts.md +++ b/x/evidence/spec/01_concepts.md @@ -76,3 +76,9 @@ by the `Handler` should be persisted. // slashing and potential jailing. type Handler func(sdk.Context, Evidence) error ``` + +## App Wiring + +The minimal app-wiring configuration for `x/evidence` is as follows: + ++++ https://github.com/cosmos/cosmos-sdk/blob/main/x/evidence/testutil/app.yaml diff --git a/x/evidence/testutil/app.yaml b/x/evidence/testutil/app.yaml index 444bf72a59..ef2f13a968 100644 --- a/x/evidence/testutil/app.yaml +++ b/x/evidence/testutil/app.yaml @@ -15,6 +15,8 @@ modules: bech32_prefix: cosmos module_account_permissions: - account: fee_collector + - account: mint + permissions: [minter] - account: bonded_tokens_pool permissions: [burner, staking] - account: not_bonded_tokens_pool diff --git a/x/nft/spec/01_concepts.md b/x/nft/spec/01_concepts.md index b69b16710f..d4f72ecdfa 100644 --- a/x/nft/spec/01_concepts.md +++ b/x/nft/spec/01_concepts.md @@ -14,6 +14,6 @@ The full name of NFT is Non-Fungible Tokens. Because of the irreplaceable nature ## App Wiring -The minimal app-wiring configuration for this `x/nft` is as follows: +The minimal app-wiring configuration for `x/nft` is as follows: +++ https://github.com/cosmos/cosmos-sdk/blob/main/x/nft/testutil/app.yaml diff --git a/x/nft/testutil/app.yaml b/x/nft/testutil/app.yaml index 275b268266..1f2706f88f 100644 --- a/x/nft/testutil/app.yaml +++ b/x/nft/testutil/app.yaml @@ -7,7 +7,7 @@ modules: begin_blockers: [mint, staking, auth, bank, mint, genutil, nft, params] end_blockers: [mint, staking, auth, bank, mint, genutil, nft, params] - init_genesis: [auth, bank, mint, staking, mint, genutil, nft, params] + init_genesis: [auth, bank, staking, mint, genutil, nft, params] - name: auth config: