use on-chain params on tests + fix tests + add new tests for power reduction change

This commit is contained in:
psaradev
2021-01-28 23:54:39 +10:00
parent 4f476d6890
commit cb17feddc0
38 changed files with 322 additions and 268 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ func TestRandomizedGenState(t *testing.T) {
require.Equal(t, uint32(8687), stakingGenesis.Params.HistoricalEntries)
require.Equal(t, "stake", stakingGenesis.Params.BondDenom)
require.Equal(t, float64(238280), stakingGenesis.Params.UnbondingTime.Seconds())
require.Equal(t, sdk.NewInt(1000000), stakingGenesis.Params.PowerReduction)
require.Equal(t, sdk.DefaultPowerReduction, stakingGenesis.Params.PowerReduction)
// check numbers of Delegations and Validators
require.Len(t, stakingGenesis.Delegations, 3)
require.Len(t, stakingGenesis.Validators, 3)
+4 -4
View File
@@ -181,7 +181,7 @@ func TestSimulateMsgUndelegate(t *testing.T) {
validator0 := getTestingValidator0(t, app, ctx, accounts)
// setup delegation
delTokens := sdk.TokensFromConsensusPower(2, sdk.DefaultPowerReduction)
delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 2)
validator0, issuedShares := validator0.AddTokensFromDel(delTokens)
delegator := accounts[1]
delegation := types.NewDelegation(delegator.Address, validator0.GetOperator(), issuedShares)
@@ -227,7 +227,7 @@ func TestSimulateMsgBeginRedelegate(t *testing.T) {
validator0 := getTestingValidator0(t, app, ctx, accounts)
validator1 := getTestingValidator1(t, app, ctx, accounts)
delTokens := sdk.TokensFromConsensusPower(2, sdk.DefaultPowerReduction)
delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 2)
validator0, issuedShares := validator0.AddTokensFromDel(delTokens)
// setup accounts[2] as delegator
@@ -276,7 +276,7 @@ func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) {
func getTestingAccounts(t *testing.T, r *rand.Rand, app *simapp.SimApp, ctx sdk.Context, n int) []simtypes.Account {
accounts := simtypes.RandomAccounts(r, n)
initAmt := sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction)
initAmt := app.StakingKeeper.TokensFromConsensusPower(ctx, 200)
initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))
// add coins to the accounts
@@ -309,7 +309,7 @@ func getTestingValidator(t *testing.T, app *simapp.SimApp, ctx sdk.Context, acco
require.NoError(t, err)
validator.DelegatorShares = sdk.NewDec(100)
validator.Tokens = sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction)
validator.Tokens = app.StakingKeeper.TokensFromConsensusPower(ctx, 100)
app.StakingKeeper.SetValidator(ctx, validator)