package keeper_test import ( "testing" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( PKs = simapp.CreateTestPubKeys(500) ) // createTestInput Returns a simapp with custom StakingKeeper // to avoid messing with the hooks. func createTestInput() (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.StakingKeeper = keeper.NewKeeper( app.AppCodec(), app.GetKey(types.StoreKey), app.AccountKeeper, app.BankKeeper, app.GetSubspace(types.ModuleName), ) return app.LegacyAmino(), app, ctx } // intended to be used with require/assert: require.True(ValEq(...)) func ValEq(t *testing.T, exp, got types.Validator) (*testing.T, bool, string, types.Validator, types.Validator) { return t, exp.MinEqual(&got), "expected:\n%v\ngot:\n%v", exp, got } // generateAddresses generates numAddrs of normal AccAddrs and ValAddrs func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int) ([]sdk.AccAddress, []sdk.ValAddress) { addrDels := simapp.AddTestAddrsIncremental(app, ctx, numAddrs, sdk.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) return addrDels, addrVals }