refactor: move x/{moduleName}/test{ModuleName} to x/{moduleName}/testutil (#13427)

* refactor: move `x/{moduleName}/test{ModuleName}` to `x/{moduleName}/testutil`

* updates

* updates
This commit is contained in:
Julien Robert 2022-10-02 16:42:52 +02:00 committed by GitHub
parent c221d7f1de
commit 80ce491734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 175 additions and 183 deletions

View File

@ -108,6 +108,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
### API Breaking Changes
* (x/slashing) [#13427](https://github.com/cosmos/cosmos-sdk/pull/13427) Move `x/slashing/testslashing` to `x/slashing/testutil` for consistency with other modules.
* (x/staking) [#13427](https://github.com/cosmos/cosmos-sdk/pull/13427) Move `x/staking/teststaking` to `x/staking/testutil` for consistency with other modules.
* (simapp) [#13402](https://github.com/cosmos/cosmos-sdk/pull/13402) Move simulation flags to `x/simulation/client/cli`.
* (simapp) [#13402](https://github.com/cosmos/cosmos-sdk/pull/13402) Move simulation helpers functions (`SetupSimulation`, `SimulationOperations`, `CheckExportSimulation`, `PrintStats`, `GetSimulationLog`) to `testutil/sims`.
* (simapp) [#13402](https://github.com/cosmos/cosmos-sdk/pull/13402) Move `testutil/rest` package to `testutil`.

View File

@ -138,9 +138,6 @@ func (suite *IntegrationTestSuite) SetupTest() {
suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
suite.fetchStoreKey = app.UnsafeFindStoreKey
// suite.Require().NoError(suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams()))
suite.Require().NoError(suite.bankKeeper.SetParams(suite.ctx, types.DefaultParams()))
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, interfaceRegistry)
types.RegisterQueryServer(queryHelper, suite.bankKeeper)
queryClient := types.NewQueryClient(queryHelper)

View File

@ -18,7 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution/testutil"
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -40,7 +40,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
addrs := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 3, sdk.NewInt(1234))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
@ -86,7 +86,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
addrs := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1234))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
@ -179,7 +179,7 @@ func TestAllocateTokensTruncation(t *testing.T) {
addrs := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 3, sdk.NewInt(1234))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
// create validator with 10% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), math.LegacyNewDec(0))

View File

@ -16,7 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution/testutil"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -38,7 +38,7 @@ func TestCalculateRewardsBasic(t *testing.T) {
distrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
@ -107,7 +107,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(100000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
@ -180,7 +180,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(100000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
@ -267,7 +267,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(100000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
@ -350,7 +350,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
balanceTokens := stakingKeeper.TokensFromConsensusPower(ctx, balancePower)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 1, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
// set module account coins
distrAcc := distrKeeper.GetDistributionAccount(ctx)
@ -431,7 +431,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 1, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
// create validator with 50% commission
valPower := int64(100)
@ -509,7 +509,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
@ -599,7 +599,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
distrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
initial := int64(20)
@ -758,7 +758,7 @@ func Test100PercentCommissionReward(t *testing.T) {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
initial := int64(20)

View File

@ -21,7 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -60,8 +60,6 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.addrs = simtestutil.AddTestAddrs(suite.bankKeeper, suite.stakingKeeper, ctx, 2, sdk.NewInt(1000000000))
suite.valAddrs = simtestutil.ConvertAddrsToValAddrs(suite.addrs)
suite.NoError(suite.distrKeeper.SetParams(suite.ctx, types.DefaultParams()))
suite.msgServer = keeper.NewMsgServerImpl(suite.distrKeeper)
}
@ -362,7 +360,7 @@ func (suite *KeeperTestSuite) TestGRPCValidatorSlashes() {
func (suite *KeeperTestSuite) TestGRPCDelegationRewards() {
ctx, addrs, valAddrs := suite.ctx, suite.addrs, suite.valAddrs
tstaking := teststaking.NewHelper(suite.T(), ctx, suite.stakingKeeper)
tstaking := stakingtestutil.NewHelper(suite.T(), ctx, suite.stakingKeeper)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk0, sdk.NewInt(100), true)

View File

@ -10,19 +10,16 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/slashing/testslashing"
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -57,10 +54,8 @@ func (s *KeeperTestSuite) SetupTest() {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
s.accountKeeper.SetParams(ctx, authtypes.DefaultParams())
s.bankKeeper.SetParams(ctx, banktypes.DefaultParams())
s.slashingKeeper.SetParams(ctx, testslashing.TestParams())
// TestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500
s.slashingKeeper.SetParams(ctx, testutil.TestParams())
addrDels := simtestutil.AddTestAddrsIncremental(s.bankKeeper, s.stakingKeeper, ctx, 5, s.stakingKeeper.TokensFromConsensusPower(ctx, 200))
info1 := slashingtypes.NewValidatorSigningInfo(sdk.ConsAddress(addrDels[0]), int64(4), int64(3),
@ -91,7 +86,7 @@ func (s *KeeperTestSuite) TestUnJailNotBonded() {
addrDels := simtestutil.AddTestAddrsIncremental(s.bankKeeper, s.stakingKeeper, ctx, 6, s.stakingKeeper.TokensFromConsensusPower(ctx, 200))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrDels)
pks := simtestutil.CreateTestPubKeys(6)
tstaking := teststaking.NewHelper(s.T(), ctx, s.stakingKeeper)
tstaking := stakingtestutil.NewHelper(s.T(), ctx, s.stakingKeeper)
// create max (5) validators all with the same power
for i := uint32(0); i < p.MaxValidators; i++ {
@ -153,7 +148,7 @@ func (s *KeeperTestSuite) TestHandleNewValidator() {
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrDels)
pks := simtestutil.CreateTestPubKeys(1)
addr, val := valAddrs[0], pks[0]
tstaking := teststaking.NewHelper(s.T(), ctx, s.stakingKeeper)
tstaking := stakingtestutil.NewHelper(s.T(), ctx, s.stakingKeeper)
ctx = ctx.WithBlockHeight(s.slashingKeeper.SignedBlocksWindow(ctx) + 1)
// Validator created
@ -192,7 +187,6 @@ func (s *KeeperTestSuite) TestHandleNewValidator() {
// Ensure that they're only slashed once
func (s *KeeperTestSuite) TestHandleAlreadyJailed() {
// initial setup
ctx := s.ctx
addrDels := simtestutil.AddTestAddrsIncremental(s.bankKeeper, s.stakingKeeper, ctx, 1, s.stakingKeeper.TokensFromConsensusPower(ctx, 200))
@ -200,7 +194,7 @@ func (s *KeeperTestSuite) TestHandleAlreadyJailed() {
pks := simtestutil.CreateTestPubKeys(1)
addr, val := valAddrs[0], pks[0]
power := int64(100)
tstaking := teststaking.NewHelper(s.T(), ctx, s.stakingKeeper)
tstaking := stakingtestutil.NewHelper(s.T(), ctx, s.stakingKeeper)
amt := tstaking.CreateValidatorWithValPower(addr, val, power, true)
@ -244,11 +238,7 @@ func (s *KeeperTestSuite) TestHandleAlreadyJailed() {
// the start height of the signing info is reset correctly
func (s *KeeperTestSuite) TestValidatorDippingInAndOut() {
// initial setup
// TestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500
ctx := s.ctx
s.slashingKeeper.SetParams(ctx, testslashing.TestParams())
params := s.stakingKeeper.GetParams(ctx)
params.MaxValidators = 1
s.stakingKeeper.SetParams(ctx, params)
@ -259,7 +249,7 @@ func (s *KeeperTestSuite) TestValidatorDippingInAndOut() {
addr, val := pks[0].Address(), pks[0]
consAddr := sdk.ConsAddress(addr)
tstaking := teststaking.NewHelper(s.T(), ctx, s.stakingKeeper)
tstaking := stakingtestutil.NewHelper(s.T(), ctx, s.stakingKeeper)
valAddr := sdk.ValAddress(addr)
tstaking.CreateValidatorWithValPower(valAddr, val, power, true)

View File

@ -15,7 +15,7 @@ import (
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/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -67,8 +67,8 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
val1 := teststaking.NewValidator(t, valAddrs[0], pks[0])
val2 := teststaking.NewValidator(t, valAddrs[1], pks[1])
val1 := testutil.NewValidator(t, valAddrs[0], pks[0])
val2 := testutil.NewValidator(t, valAddrs[1], pks[1])
vals := []types.Validator{val1, val2}
app.StakingKeeper.SetValidator(ctx, val1)

View File

@ -10,9 +10,9 @@ import (
"cosmossdk.io/simapp"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -27,11 +27,11 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) {
bondDenom := app.StakingKeeper.BondDenom(ctx)
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(bondDenom, startTokens))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(bondDenom, startTokens))))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
// create a validator and a delegator to that validator
validator := teststaking.NewValidator(t, addrVals[0], PKs[0])
validator := testutil.NewValidator(t, addrVals[0], PKs[0])
validator, issuedShares := validator.AddTokensFromDel(startTokens)
require.Equal(t, startTokens, issuedShares.RoundInt())

View File

@ -3,7 +3,6 @@ package keeper_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
@ -54,23 +53,6 @@ func (suite *IntegrationTestSuite) SetupTest() {
suite.app, suite.ctx, suite.queryClient, suite.addrs, suite.vals = app, ctx, queryClient, addrs, validators
}
func TestParams(t *testing.T) {
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
expParams := types.DefaultParams()
// check that the empty keeper loads the default
resParams := app.StakingKeeper.GetParams(ctx)
require.True(t, expParams.Equal(resParams))
// modify a params, save, and retrieve
expParams.MaxValidators = 777
app.StakingKeeper.SetParams(ctx, expParams)
resParams = app.StakingKeeper.GetParams(ctx)
require.True(t, expParams.Equal(resParams))
}
func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}

View File

@ -0,0 +1,27 @@
package keeper
import (
"testing"
"cosmossdk.io/simapp"
"github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
func TestParams(t *testing.T) {
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
expParams := types.DefaultParams()
// check that the empty keeper loads the default
resParams := app.StakingKeeper.GetParams(ctx)
require.True(t, expParams.Equal(resParams))
// modify a params, save, and retrieve
expParams.MaxValidators = 777
app.StakingKeeper.SetParams(ctx, expParams)
resParams = app.StakingKeeper.GetParams(ctx)
require.True(t, expParams.Equal(resParams))
}

View File

@ -11,9 +11,9 @@ import (
"cosmossdk.io/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -27,7 +27,7 @@ func bootstrapSlashTest(t *testing.T, power int64) (*simapp.SimApp, sdk.Context,
totalSupply := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), amt.MulRaw(int64(len(addrDels)))))
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
@ -37,10 +37,10 @@ func bootstrapSlashTest(t *testing.T, power int64) (*simapp.SimApp, sdk.Context,
// set bonded pool balance
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), bondedCoins))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), bondedCoins))
for i := int64(0); i < numVals; i++ {
validator := teststaking.NewValidator(t, addrVals[i], PKs[i])
validator := testutil.NewValidator(t, addrVals[i], PKs[i])
validator, _ = validator.AddTokensFromDel(amt)
validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true)
app.StakingKeeper.SetValidatorByConsAddr(ctx, validator)
@ -103,7 +103,7 @@ func TestSlashRedelegation(t *testing.T) {
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
balances := app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress())
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), startCoins))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), startCoins))
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
// set a redelegation with an expiration timestamp beyond which the
@ -370,7 +370,7 @@ func TestSlashWithRedelegation(t *testing.T) {
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
rdCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, rdTokens.MulRaw(2)))
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), rdCoins))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), rdCoins))
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
@ -531,8 +531,8 @@ func TestSlashBoth(t *testing.T) {
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), bondedCoins))
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), notBondedCoins))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), bondedCoins))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), notBondedCoins))
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)

View File

@ -13,10 +13,10 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -38,7 +38,7 @@ func bootstrapValidatorTest(t testing.TB, power int64, numAddrs int) (*simapp.Si
// set bonded pool supply
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
// unbond genesis validator delegations
delegations := app.StakingKeeper.GetAllDelegations(ctx)
@ -60,7 +60,7 @@ func initValidators(t testing.TB, power int64, numAddrs int, powers []int64) (*s
vs := make([]types.Validator, len(powers))
for i, power := range powers {
vs[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), pks[i])
vs[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), pks[i])
tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power)
vs[i], _ = vs[i].AddTokensFromDel(tokens)
}
@ -83,8 +83,8 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) {
app.StakingKeeper.SetParams(ctx, params)
// create a random pool
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 1234)))))
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 1234)))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)))))
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
@ -133,12 +133,12 @@ func TestSlashToZeroPowerRemoved(t *testing.T) {
app, ctx, _, addrVals := bootstrapValidatorTest(t, 100, 20)
// add a validator
validator := teststaking.NewValidator(t, addrVals[0], PKs[0])
validator := testutil.NewValidator(t, addrVals[0], PKs[0])
valTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 100)
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), valTokens))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), valTokens))))
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
@ -173,7 +173,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) {
n := len(amts)
var validators [5]types.Validator
for i, amt := range amts {
validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
validators[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
validators[i].Status = types.Bonded
validators[i].Tokens = amt
validators[i].DelegatorShares = sdk.NewDecFromInt(amt)
@ -245,8 +245,8 @@ func TestGetValidatorSortingMixed(t *testing.T) {
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 501)))))
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 0)))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 501)))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 0)))))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
@ -267,7 +267,7 @@ func TestGetValidatorSortingMixed(t *testing.T) {
var validators [5]types.Validator
for i, amt := range amts {
validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
validators[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
validators[i].DelegatorShares = sdk.NewDecFromInt(amt)
validators[i].Status = types.Bonded
validators[i].Tokens = amt
@ -321,7 +321,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
validators[i], _ = validators[i].AddTokensFromDel(tokens)
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, tokens))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, tokens))))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
validators[i] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[i], true)
}
@ -340,7 +340,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
newTokens := sdk.NewCoins()
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), newTokens))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), newTokens))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
// test that the two largest validators are
@ -372,7 +372,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx)
newTokens = sdk.NewCoins(sdk.NewCoin(params.BondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 1)))
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), newTokens))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), newTokens))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
validators[3] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true)
@ -387,7 +387,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
validators[3], _ = validators[3].RemoveDelShares(math.LegacyNewDec(201))
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, rmTokens))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, rmTokens))))
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
validators[3] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true)
@ -401,7 +401,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
validators[3], _ = validators[3].AddTokensFromDel(sdk.NewInt(200))
notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx)
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdk.NewInt(200)))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdk.NewInt(200)))))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
validators[3] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true)
@ -423,9 +423,9 @@ func TestValidatorBondHeight(t *testing.T) {
// initialize some validators into the state
var validators [3]types.Validator
validators[0] = teststaking.NewValidator(t, sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0])
validators[1] = teststaking.NewValidator(t, sdk.ValAddress(addrs[1]), PKs[1])
validators[2] = teststaking.NewValidator(t, sdk.ValAddress(addrs[2]), PKs[2])
validators[0] = testutil.NewValidator(t, sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0])
validators[1] = testutil.NewValidator(t, sdk.ValAddress(addrs[1]), PKs[1])
validators[2] = testutil.NewValidator(t, sdk.ValAddress(addrs[2]), PKs[2])
tokens0 := app.StakingKeeper.TokensFromConsensusPower(ctx, 200)
tokens1 := app.StakingKeeper.TokensFromConsensusPower(ctx, 100)
@ -471,7 +471,7 @@ func TestFullValidatorSetPowerChange(t *testing.T) {
powers := []int64{0, 100, 400, 400, 200}
var validators [5]types.Validator
for i, power := range powers {
validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
validators[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power)
validators[i], _ = validators[i].AddTokensFromDel(tokens)
keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[i], true)
@ -511,7 +511,7 @@ func TestApplyAndReturnValidatorSetUpdatesAllNone(t *testing.T) {
valPubKey := PKs[i+1]
valAddr := sdk.ValAddress(valPubKey.Address().Bytes())
validators[i] = teststaking.NewValidator(t, valAddr, valPubKey)
validators[i] = testutil.NewValidator(t, valAddr, valPubKey)
tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power)
validators[i], _ = validators[i].AddTokensFromDel(tokens)
}
@ -537,7 +537,7 @@ func TestApplyAndReturnValidatorSetUpdatesIdentical(t *testing.T) {
powers := []int64{10, 20}
var validators [2]types.Validator
for i, power := range powers {
validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
validators[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power)
validators[i], _ = validators[i].AddTokensFromDel(tokens)
@ -560,7 +560,7 @@ func TestApplyAndReturnValidatorSetUpdatesSingleValueChange(t *testing.T) {
powers := []int64{10, 20}
var validators [2]types.Validator
for i, power := range powers {
validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
validators[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power)
validators[i], _ = validators[i].AddTokensFromDel(tokens)
@ -645,7 +645,7 @@ func TestApplyAndReturnValidatorSetUpdatesWithCliffValidator(t *testing.T) {
powers := []int64{10, 20, 5}
var validators [5]types.Validator
for i, power := range powers {
validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
validators[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power)
validators[i], _ = validators[i].AddTokensFromDel(tokens)
}
@ -687,7 +687,7 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) {
valPubKey := PKs[i+1]
valAddr := sdk.ValAddress(valPubKey.Address().Bytes())
validators[i] = teststaking.NewValidator(t, valAddr, valPubKey)
validators[i] = testutil.NewValidator(t, valAddr, valPubKey)
tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power)
validators[i], _ = validators[i].AddTokensFromDel(tokens)
@ -721,7 +721,7 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) {
valAddr := sdk.ValAddress(valPubKey.Address().Bytes())
amt := sdk.NewInt(100)
validator := teststaking.NewValidator(t, valAddr, valPubKey)
validator := testutil.NewValidator(t, valAddr, valPubKey)
validator, _ = validator.AddTokensFromDel(amt)
app.StakingKeeper.SetValidator(ctx, validator)
@ -734,7 +734,7 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) {
valPubKey = PKs[len(validators)+2]
valAddr = sdk.ValAddress(valPubKey.Address().Bytes())
validator = teststaking.NewValidator(t, valAddr, valPubKey)
validator = testutil.NewValidator(t, valAddr, valPubKey)
tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 500)
validator, _ = validator.AddTokensFromDel(tokens)
app.StakingKeeper.SetValidator(ctx, validator)

View File

@ -80,7 +80,6 @@ func (s *IntegrationTestSuite) SetupSuite() {
multi := kmultisig.NewLegacyAminoPubKey(2, []cryptotypes.PubKey{pub1, pub2})
_, err = kb.SaveMultisig("multi", multi)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
@ -830,6 +829,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
res, err = TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
s.Require().NoError(err)
s.Require().True(strings.Contains(res.String(), "[OK]"))
s.Require().NoError(s.network.WaitForNextBlock())
// Ensure foo has right amount of funds
resp, err = clitestutil.QueryBalancesExec(val1.ClientCtx, val1.Address)
@ -844,14 +844,12 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
// Does not work in offline mode
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name(), "--offline")
s.Require().EqualError(err, "cannot broadcast tx during offline mode")
s.Require().NoError(s.network.WaitForNextBlock())
// Broadcast correct transaction.
val1.ClientCtx.BroadcastMode = flags.BroadcastSync
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
// Ensure destiny account state
@ -891,7 +889,6 @@ func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() {
),
)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
// Generate multisig transaction.
@ -998,7 +995,6 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
sdk.NewCoins(sendTokens),
)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
resp, err = clitestutil.QueryBalancesExec(val1.ClientCtx, addr)
@ -1131,7 +1127,6 @@ func (s *IntegrationTestSuite) TestCLIMultisign() {
val1, addr,
sdk.NewCoins(sendTokens),
)
s.Require().NoError(s.network.WaitForNextBlock())
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
@ -1884,6 +1879,8 @@ func (s *IntegrationTestSuite) TestAuxToFeeWithTips() {
genTxFile.Name(),
tc.feePayerArgs...,
)
s.Require().NoError(s.network.WaitForNextBlock())
switch {
case tc.expectErrBroadCast:
require.Error(err)

View File

@ -16,7 +16,7 @@ import (
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
@ -68,7 +68,7 @@ func (suite *InfractionTestSuite) TestHandleDoubleSign() {
power := int64(100)
stakingParams := suite.stakingKeeper.GetParams(ctx)
operatorAddr, val := valAddresses[0], pubkeys[0]
tstaking := teststaking.NewHelper(suite.T(), ctx, suite.stakingKeeper)
tstaking := stakingtestutil.NewHelper(suite.T(), ctx, suite.stakingKeeper)
selfDelegation := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, true)
@ -134,7 +134,7 @@ func (suite *InfractionTestSuite) TestHandleDoubleSign_TooOld() {
power := int64(100)
stakingParams := suite.stakingKeeper.GetParams(ctx)
operatorAddr, val := valAddresses[0], pubkeys[0]
tstaking := teststaking.NewHelper(suite.T(), ctx, suite.stakingKeeper)
tstaking := stakingtestutil.NewHelper(suite.T(), ctx, suite.stakingKeeper)
amt := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, true)

View File

@ -17,7 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -41,7 +41,7 @@ func TestBeginBlocker(t *testing.T) {
pks := simtestutil.CreateTestPubKeys(1)
simtestutil.AddTestAddrsFromPubKeys(bankKeeper, stakingKeeper, ctx, pks, stakingKeeper.TokensFromConsensusPower(ctx, 200))
addr, pk := sdk.ValAddress(pks[0].Address()), pks[0]
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
// bond the validator
power := int64(100)

View File

@ -6,7 +6,7 @@ import (
"github.com/golang/mock/gomock"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/slashing/testslashing"
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
"github.com/cosmos/cosmos-sdk/x/slashing/types"
)
@ -14,7 +14,7 @@ func (s *KeeperTestSuite) TestExportAndInitGenesis() {
ctx, keeper := s.ctx, s.slashingKeeper
require := s.Require()
keeper.SetParams(ctx, testslashing.TestParams())
keeper.SetParams(ctx, testutil.TestParams())
consAddr1 := sdk.ConsAddress(sdk.AccAddress([]byte("addr1_______________")))
consAddr2 := sdk.ConsAddress(sdk.AccAddress([]byte("addr2_______________")))
@ -28,7 +28,7 @@ func (s *KeeperTestSuite) TestExportAndInitGenesis() {
keeper.SetValidatorSigningInfo(ctx, consAddr2, info2)
genesisState := keeper.ExportGenesis(ctx)
require.Equal(genesisState.Params, testslashing.TestParams())
require.Equal(genesisState.Params, testutil.TestParams())
require.Len(genesisState.SigningInfos, 2)
require.Equal(genesisState.SigningInfos[0].ValidatorSigningInfo, info1)

View File

@ -6,7 +6,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/slashing/testslashing"
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
)
@ -17,7 +17,7 @@ func (s *KeeperTestSuite) TestGRPCQueryParams() {
paramsResp, err := queryClient.Params(gocontext.Background(), &slashingtypes.QueryParamsRequest{})
require.NoError(err)
require.Equal(testslashing.TestParams(), paramsResp.Params)
require.Equal(testutil.TestParams(), paramsResp.Params)
}
func (s *KeeperTestSuite) TestGRPCSigningInfo() {

View File

@ -11,11 +11,11 @@ import (
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/testutil"
sdktestutil "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/cosmos-sdk/x/slashing/testslashing"
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
slashingtestutil "github.com/cosmos/cosmos-sdk/x/slashing/testutil"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
@ -38,7 +38,7 @@ type KeeperTestSuite struct {
func (s *KeeperTestSuite) SetupTest() {
key := sdk.NewKVStoreKey(slashingtypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
testCtx := sdktestutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: tmtime.Now()})
encCfg := moduletestutil.MakeTestEncodingConfig()
@ -55,7 +55,7 @@ func (s *KeeperTestSuite) SetupTest() {
sdk.AccAddress(crypto.AddressHash([]byte(govtypes.ModuleName))).String(),
)
// set test params
s.slashingKeeper.SetParams(ctx, testslashing.TestParams())
s.slashingKeeper.SetParams(ctx, testutil.TestParams())
slashingtypes.RegisterInterfaces(encCfg.InterfaceRegistry)
queryHelper := baseapp.NewQueryServerTestHelper(ctx, encCfg.InterfaceRegistry)

View File

@ -5,7 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/slashing/testslashing"
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
)
@ -57,7 +57,7 @@ func (s *KeeperTestSuite) TestValidatorMissedBlockBitArray() {
ctx, keeper := s.ctx, s.slashingKeeper
require := s.Require()
params := testslashing.TestParams()
params := testutil.TestParams()
params.SignedBlocksWindow = 100
require.NoError(keeper.SetParams(ctx, params))

View File

@ -1,4 +1,4 @@
package testslashing
package testutil
import (
"github.com/cosmos/cosmos-sdk/x/slashing/types"

View File

@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -30,7 +30,7 @@ func benchmarkValidateGenesis(b *testing.B, n int) {
addressL, pubKeyL := makeRandomAddressesAndPublicKeys(n)
for i := 0; i < n; i++ {
addr, pubKey := addressL[i], pubKeyL[i]
validator := teststaking.NewValidator(b, addr, pubKey)
validator := testutil.NewValidator(b, addr, pubKey)
ni := int64(i + 1)
validator.Tokens = sdk.NewInt(ni)
validator.DelegatorShares = math.LegacyNewDec(ni)

View File

@ -9,14 +9,14 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
func TestValidateGenesis(t *testing.T) {
genValidators1 := make([]types.Validator, 1, 5)
pk := ed25519.GenPrivKey().PubKey()
genValidators1[0] = teststaking.NewValidator(t, sdk.ValAddress(pk.Address()), pk)
genValidators1[0] = testutil.NewValidator(t, sdk.ValAddress(pk.Address()), pk)
genValidators1[0].Tokens = math.OneInt()
genValidators1[0].DelegatorShares = math.LegacyOneDec()

View File

@ -9,7 +9,7 @@ import (
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -31,7 +31,7 @@ func (s *KeeperTestSuite) TestDelegation() {
amts := []math.Int{sdk.NewInt(9), sdk.NewInt(8), sdk.NewInt(7)}
var validators [3]stakingtypes.Validator
for i, amt := range amts {
validators[i] = teststaking.NewValidator(s.T(), valAddrs[i], PKs[i])
validators[i] = testutil.NewValidator(s.T(), valAddrs[i], PKs[i])
validators[i], _ = validators[i].AddTokensFromDel(amt)
validators[i] = stakingkeeper.TestingUpdateValidator(keeper, ctx, validators[i], true)
@ -196,7 +196,7 @@ func (s *KeeperTestSuite) TestUnbondDelegation() {
delAddrs, valAddrs := createValAddrs(1)
startTokens := keeper.TokensFromConsensusPower(ctx, 10)
validator := teststaking.NewValidator(s.T(), valAddrs[0], PKs[0])
validator := testutil.NewValidator(s.T(), valAddrs[0], PKs[0])
validator, issuedShares := validator.AddTokensFromDel(startTokens)
require.Equal(startTokens, issuedShares.RoundInt())
@ -233,7 +233,7 @@ func (s *KeeperTestSuite) TestUndelegateSelfDelegationBelowMinSelfDelegation() {
delTokens := keeper.TokensFromConsensusPower(ctx, 10)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
validator.MinSelfDelegation = delTokens
validator, issuedShares := validator.AddTokensFromDel(delTokens)
@ -281,7 +281,7 @@ func (s *KeeperTestSuite) TestUndelegateFromUnbondingValidator() {
addrDels, addrVals := createValAddrs(2)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
keeper.SetValidatorByConsAddr(ctx, validator)
validator, issuedShares := validator.AddTokensFromDel(delTokens)
@ -353,7 +353,7 @@ func (s *KeeperTestSuite) TestUndelegateFromUnbondedValidator() {
addrDels, addrVals := createValAddrs(2)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
keeper.SetValidatorByConsAddr(ctx, validator)
valTokens := keeper.TokensFromConsensusPower(ctx, 10)
@ -426,7 +426,7 @@ func (s *KeeperTestSuite) TestUnbondingAllDelegationFromValidator() {
addrDels, addrVals := createValAddrs(2)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
keeper.SetValidatorByConsAddr(ctx, validator)
valTokens := keeper.TokensFromConsensusPower(ctx, 10)
@ -581,7 +581,7 @@ func (s *KeeperTestSuite) TestRedelegateToSameValidator() {
valTokens := keeper.TokensFromConsensusPower(ctx, 10)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
validator, issuedShares := validator.AddTokensFromDel(valTokens)
require.Equal(valTokens, issuedShares.RoundInt())
@ -604,7 +604,7 @@ func (s *KeeperTestSuite) TestRedelegationMaxEntries() {
_, addrVals := createValAddrs(2)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
valTokens := keeper.TokensFromConsensusPower(ctx, 10)
validator, issuedShares := validator.AddTokensFromDel(valTokens)
require.Equal(valTokens, issuedShares.RoundInt())
@ -616,7 +616,7 @@ func (s *KeeperTestSuite) TestRedelegationMaxEntries() {
keeper.SetDelegation(ctx, selfDelegation)
// create a second validator
validator2 := teststaking.NewValidator(s.T(), addrVals[1], PKs[1])
validator2 := testutil.NewValidator(s.T(), addrVals[1], PKs[1])
validator2, issuedShares = validator2.AddTokensFromDel(valTokens)
require.Equal(valTokens, issuedShares.RoundInt())
@ -655,7 +655,7 @@ func (s *KeeperTestSuite) TestRedelegateSelfDelegation() {
addrDels, addrVals := createValAddrs(2)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
keeper.SetValidatorByConsAddr(ctx, validator)
valTokens := keeper.TokensFromConsensusPower(ctx, 10)
@ -670,7 +670,7 @@ func (s *KeeperTestSuite) TestRedelegateSelfDelegation() {
keeper.SetDelegation(ctx, selfDelegation)
// create a second validator
validator2 := teststaking.NewValidator(s.T(), addrVals[1], PKs[1])
validator2 := testutil.NewValidator(s.T(), addrVals[1], PKs[1])
validator2, issuedShares = validator2.AddTokensFromDel(valTokens)
require.Equal(valTokens, issuedShares.RoundInt())
s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), stakingtypes.NotBondedPoolName, stakingtypes.BondedPoolName, gomock.Any())
@ -706,7 +706,7 @@ func (s *KeeperTestSuite) TestRedelegateFromUnbondingValidator() {
addrDels, addrVals := createValAddrs(2)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
keeper.SetValidatorByConsAddr(ctx, validator)
valTokens := keeper.TokensFromConsensusPower(ctx, 10)
@ -728,7 +728,7 @@ func (s *KeeperTestSuite) TestRedelegateFromUnbondingValidator() {
keeper.SetDelegation(ctx, delegation)
// create a second validator
validator2 := teststaking.NewValidator(s.T(), addrVals[1], PKs[1])
validator2 := testutil.NewValidator(s.T(), addrVals[1], PKs[1])
validator2, issuedShares = validator2.AddTokensFromDel(valTokens)
require.Equal(valTokens, issuedShares.RoundInt())
s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), stakingtypes.NotBondedPoolName, stakingtypes.BondedPoolName, gomock.Any())
@ -785,7 +785,7 @@ func (s *KeeperTestSuite) TestRedelegateFromUnbondedValidator() {
addrDels, addrVals := createValAddrs(2)
// create a validator with a self-delegation
validator := teststaking.NewValidator(s.T(), addrVals[0], PKs[0])
validator := testutil.NewValidator(s.T(), addrVals[0], PKs[0])
keeper.SetValidatorByConsAddr(ctx, validator)
valTokens := keeper.TokensFromConsensusPower(ctx, 10)
@ -807,7 +807,7 @@ func (s *KeeperTestSuite) TestRedelegateFromUnbondedValidator() {
keeper.SetDelegation(ctx, delegation)
// create a second validator
validator2 := teststaking.NewValidator(s.T(), addrVals[1], PKs[1])
validator2 := testutil.NewValidator(s.T(), addrVals[1], PKs[1])
validator2, issuedShares = validator2.AddTokensFromDel(valTokens)
require.Equal(valTokens, issuedShares.RoundInt())
s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), stakingtypes.NotBondedPoolName, stakingtypes.BondedPoolName, gomock.Any())

View File

@ -5,7 +5,7 @@ import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -13,7 +13,7 @@ func (s *KeeperTestSuite) TestGRPCQueryValidator() {
ctx, keeper, queryClient := s.ctx, s.stakingKeeper, s.queryClient
require := s.Require()
validator := teststaking.NewValidator(s.T(), sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0])
validator := testutil.NewValidator(s.T(), sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0])
keeper.SetValidator(ctx, validator)
var req *types.QueryValidatorRequest
testCases := []struct {

View File

@ -4,7 +4,7 @@ import (
"cosmossdk.io/math"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -28,7 +28,7 @@ func (s *KeeperTestSuite) TestHistoricalInfo() {
validators := make([]stakingtypes.Validator, len(addrVals))
for i, valAddr := range addrVals {
validators[i] = teststaking.NewValidator(s.T(), valAddr, PKs[i])
validators[i] = testutil.NewValidator(s.T(), valAddr, PKs[i])
}
hi := stakingtypes.NewHistoricalInfo(ctx.BlockHeader(), validators, keeper.PowerReduction(ctx))
@ -68,8 +68,8 @@ func (s *KeeperTestSuite) TestTrackHistoricalInfo() {
Height: 5,
}
valSet := []stakingtypes.Validator{
teststaking.NewValidator(s.T(), addrVals[0], PKs[0]),
teststaking.NewValidator(s.T(), addrVals[1], PKs[1]),
testutil.NewValidator(s.T(), addrVals[0], PKs[0]),
testutil.NewValidator(s.T(), addrVals[1], PKs[1]),
}
hi4 := stakingtypes.NewHistoricalInfo(h4, valSet, keeper.PowerReduction(ctx))
hi5 := stakingtypes.NewHistoricalInfo(h5, valSet, keeper.PowerReduction(ctx))
@ -83,12 +83,12 @@ func (s *KeeperTestSuite) TestTrackHistoricalInfo() {
require.Equal(hi5, recv)
// Set bonded validators in keeper
val1 := teststaking.NewValidator(s.T(), addrVals[2], PKs[2])
val1 := testutil.NewValidator(s.T(), addrVals[2], PKs[2])
val1.Status = stakingtypes.Bonded // when not bonded, consensus power is Zero
val1.Tokens = keeper.TokensFromConsensusPower(ctx, 10)
keeper.SetValidator(ctx, val1)
keeper.SetLastValidatorPower(ctx, val1.GetOperator(), 10)
val2 := teststaking.NewValidator(s.T(), addrVals[3], PKs[3])
val2 := testutil.NewValidator(s.T(), addrVals[3], PKs[3])
val1.Status = stakingtypes.Bonded
val2.Tokens = keeper.TokensFromConsensusPower(ctx, 80)
keeper.SetValidator(ctx, val2)
@ -131,8 +131,8 @@ func (s *KeeperTestSuite) TestGetAllHistoricalInfo() {
_, addrVals := createValAddrs(50)
valSet := []stakingtypes.Validator{
teststaking.NewValidator(s.T(), addrVals[0], PKs[0]),
teststaking.NewValidator(s.T(), addrVals[1], PKs[1]),
testutil.NewValidator(s.T(), addrVals[0], PKs[0]),
testutil.NewValidator(s.T(), addrVals[1], PKs[1]),
}
header1 := tmproto.Header{ChainID: "HelloChain", Height: 10}

View File

@ -2,7 +2,7 @@ package keeper_test
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
)
// tests Jail, Unjail
@ -12,7 +12,7 @@ func (s *KeeperTestSuite) TestRevocation() {
valAddr := sdk.ValAddress(PKs[0].Address().Bytes())
consAddr := sdk.ConsAddress(PKs[0].Address())
validator := teststaking.NewValidator(s.T(), valAddr, PKs[0])
validator := testutil.NewValidator(s.T(), valAddr, PKs[0])
// initial state
keeper.SetValidator(ctx, validator)
@ -40,7 +40,7 @@ func (s *KeeperTestSuite) TestSlashAtFutureHeight() {
require := s.Require()
consAddr := sdk.ConsAddress(PKs[0].Address())
validator := teststaking.NewValidator(s.T(), sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0])
validator := testutil.NewValidator(s.T(), sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0])
keeper.SetValidator(ctx, validator)
err := keeper.SetValidatorByConsAddr(ctx, validator)
require.NoError(err)

View File

@ -9,7 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
abci "github.com/tendermint/tendermint/abci/types"
)
@ -32,7 +32,7 @@ func (s *KeeperTestSuite) TestValidator() {
valTokens := keeper.TokensFromConsensusPower(ctx, 10)
// test how the validator is set from a purely unbonbed pool
validator := teststaking.NewValidator(s.T(), valAddr, valPubKey)
validator := testutil.NewValidator(s.T(), valAddr, valPubKey)
validator, _ = validator.AddTokensFromDel(valTokens)
require.Equal(stakingtypes.Unbonded, validator.Status)
require.Equal(valTokens, validator.Tokens)
@ -90,7 +90,7 @@ func (s *KeeperTestSuite) TestValidatorBasics() {
var validators [3]stakingtypes.Validator
powers := []int64{9, 8, 7}
for i, power := range powers {
validators[i] = teststaking.NewValidator(s.T(), sdk.ValAddress(PKs[i].Address().Bytes()), PKs[i])
validators[i] = testutil.NewValidator(s.T(), sdk.ValAddress(PKs[i].Address().Bytes()), PKs[i])
validators[i].Status = stakingtypes.Unbonded
validators[i].Tokens = math.ZeroInt()
tokens := keeper.TokensFromConsensusPower(ctx, power)
@ -189,7 +189,7 @@ func (s *KeeperTestSuite) TestUpdateValidatorByPowerIndex() {
valTokens := keeper.TokensFromConsensusPower(ctx, 100)
// add a validator
validator := teststaking.NewValidator(s.T(), valAddr, PKs[0])
validator := testutil.NewValidator(s.T(), valAddr, PKs[0])
validator, delSharesCreated := validator.AddTokensFromDel(valTokens)
require.Equal(stakingtypes.Unbonded, validator.Status)
require.Equal(valTokens, validator.Tokens)
@ -231,7 +231,7 @@ func (s *KeeperTestSuite) TestApplyAndReturnValidatorSetUpdatesPowerDecrease() {
var validators [2]stakingtypes.Validator
for i, power := range powers {
validators[i] = teststaking.NewValidator(s.T(), sdk.ValAddress(PKs[i].Address().Bytes()), PKs[i])
validators[i] = testutil.NewValidator(s.T(), sdk.ValAddress(PKs[i].Address().Bytes()), PKs[i])
tokens := keeper.TokensFromConsensusPower(ctx, power)
validators[i], _ = validators[i].AddTokensFromDel(tokens)
@ -282,8 +282,8 @@ func (s *KeeperTestSuite) TestUpdateValidatorCommission() {
)
commission2 := stakingtypes.NewCommission(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(3, 1), sdk.NewDecWithPrec(1, 1))
val1 := teststaking.NewValidator(s.T(), sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0])
val2 := teststaking.NewValidator(s.T(), sdk.ValAddress(PKs[1].Address().Bytes()), PKs[1])
val1 := testutil.NewValidator(s.T(), sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0])
val2 := testutil.NewValidator(s.T(), sdk.ValAddress(PKs[1].Address().Bytes()), PKs[1])
val1, _ = val1.SetInitialCommission(commission1)
val2, _ = val2.SetInitialCommission(commission2)
@ -339,7 +339,7 @@ func (s *KeeperTestSuite) TestValidatorToken() {
addTokens := keeper.TokensFromConsensusPower(ctx, 10)
delTokens := keeper.TokensFromConsensusPower(ctx, 5)
validator := teststaking.NewValidator(s.T(), valAddr, valPubKey)
validator := testutil.NewValidator(s.T(), valAddr, valPubKey)
validator, _ = keeper.AddValidatorTokensAndShares(ctx, validator, addTokens)
require.Equal(addTokens, validator.Tokens)
validator, _ = keeper.GetValidator(ctx, valAddr)
@ -361,7 +361,7 @@ func (s *KeeperTestSuite) TestUnbondingValidator() {
valPubKey := PKs[0]
valAddr := sdk.ValAddress(valPubKey.Address().Bytes())
validator := teststaking.NewValidator(s.T(), valAddr, valPubKey)
validator := testutil.NewValidator(s.T(), valAddr, valPubKey)
addTokens := keeper.TokensFromConsensusPower(ctx, 10)
// set unbonding validator
@ -375,7 +375,7 @@ func (s *KeeperTestSuite) TestUnbondingValidator() {
// add another unbonding validator
valAddr1 := sdk.ValAddress(PKs[1].Address().Bytes())
validator1 := teststaking.NewValidator(s.T(), valAddr1, PKs[1])
validator1 := testutil.NewValidator(s.T(), valAddr1, PKs[1])
validator1.UnbondingHeight = endHeight
validator1.UnbondingTime = endTime
keeper.InsertUnbondingValidatorQueue(ctx, validator1)
@ -408,7 +408,7 @@ func (s *KeeperTestSuite) TestUnbondingValidator() {
require.False(found)
keeper.SetUnbondingValidatorsQueue(ctx, endTime, endHeight, []string{valAddr.String()})
validator = teststaking.NewValidator(s.T(), valAddr, valPubKey)
validator = testutil.NewValidator(s.T(), valAddr, valPubKey)
validator, _ = validator.AddTokensFromDel(addTokens)
validator.Status = stakingtypes.Unbonding
keeper.SetValidator(ctx, validator)

View File

@ -7,24 +7,24 @@ import (
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
sdktestuil "github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v1"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v2"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
v1 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v1"
v2 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v2"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
func TestStoreMigration(t *testing.T) {
stakingKey := sdk.NewKVStoreKey("staking")
tStakingKey := sdk.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(stakingKey, tStakingKey)
ctx := sdktestuil.DefaultContext(stakingKey, tStakingKey)
store := ctx.KVStore(stakingKey)
_, pk1, addr1 := testdata.KeyTestPubAddr()
valAddr1 := sdk.ValAddress(addr1)
val := teststaking.NewValidator(t, valAddr1, pk1)
val := testutil.NewValidator(t, valAddr1, pk1)
_, pk1, addr2 := testdata.KeyTestPubAddr()
valAddr2 := sdk.ValAddress(addr2)
_, _, addr3 := testdata.KeyTestPubAddr()

View File

@ -19,12 +19,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/simulation"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@ -367,7 +366,7 @@ func (s *SimTestSuite) getTestingValidator(ctx sdk.Context, commission types.Com
account := s.accounts[n]
valPubKey := account.PubKey
valAddr := sdk.ValAddress(account.PubKey.Address().Bytes())
validator := teststaking.NewValidator(s.T(), valAddr, valPubKey)
validator := testutil.NewValidator(s.T(), valAddr, valPubKey)
validator, err := validator.SetInitialCommission(commission)
s.Require().NoError(err)

View File

@ -1,4 +1,4 @@
package teststaking
package testutil
import (
"context"

View File

@ -1,4 +1,4 @@
package teststaking
package testutil
import (
"cosmossdk.io/math"

View File

@ -1,4 +1,4 @@
package teststaking
package testutil
import (
"testing"

View File

@ -15,7 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -290,7 +290,7 @@ func TestValidatorsSortTendermint(t *testing.T) {
valz := types.Validators(vals)
// create expected tendermint validators by converting to tendermint then sorting
expectedVals, err := teststaking.ToTmValidators(valz, sdk.DefaultPowerReduction)
expectedVals, err := testutil.ToTmValidators(valz, sdk.DefaultPowerReduction)
require.NoError(t, err)
sort.Sort(tmtypes.ValidatorsByVotingPower(expectedVals))
@ -298,7 +298,7 @@ func TestValidatorsSortTendermint(t *testing.T) {
sort.SliceStable(valz, func(i, j int) bool {
return types.ValidatorsByVotingPower(valz).Less(i, j, sdk.DefaultPowerReduction)
})
actualVals, err := teststaking.ToTmValidators(valz, sdk.DefaultPowerReduction)
actualVals, err := testutil.ToTmValidators(valz, sdk.DefaultPowerReduction)
require.NoError(t, err)
require.Equal(t, expectedVals, actualVals, "sorting in SDK is not the same as sorting in Tendermint")
@ -318,7 +318,7 @@ func TestValidatorToTm(t *testing.T) {
require.NoError(t, err)
expected[i] = tmtypes.NewValidator(tmPk, val.ConsensusPower(sdk.DefaultPowerReduction))
}
vs, err := teststaking.ToTmValidators(vals, sdk.DefaultPowerReduction)
vs, err := testutil.ToTmValidators(vals, sdk.DefaultPowerReduction)
require.NoError(t, err)
require.Equal(t, expected, vs)
}