diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b543247a..b261e7d84b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ BREAKING CHANGES to an infraction, slash them proportional to their stake at the time * Add REST endpoint to unrevoke a validator previously revoked for downtime * Add REST endpoint to retrieve liveness signing information for a validator +* [types] renamed rational.Evaluate to rational.Round{Int64, Int} FEATURES * [gaiacli] You can now attach a simple text-only memo to any transaction, with the `--memo` flag diff --git a/types/rational.go b/types/rational.go index f24831f89e..ab400868d4 100644 --- a/types/rational.go +++ b/types/rational.go @@ -174,20 +174,20 @@ func (r Rat) EvaluateBig() *big.Int { return d } -// evaluate the rational using bankers rounding -func (r Rat) Evaluate() int64 { +// RoundInt64 rounds the rational using bankers rounding +func (r Rat) RoundInt64() int64 { return r.EvaluateBig().Int64() } -// EvaulateInt evaludates the rational using EvaluateBig -func (r Rat) EvaluateInt() Int { +// RoundInt round the rational using bankers rounding +func (r Rat) RoundInt() Int { return NewIntFromBigInt(r.EvaluateBig()) } // round Rat with the provided precisionFactor func (r Rat) Round(precisionFactor int64) Rat { rTen := Rat{new(big.Rat).Mul(r.Rat, big.NewRat(precisionFactor, 1))} - return Rat{big.NewRat(rTen.Evaluate(), precisionFactor)} + return Rat{big.NewRat(rTen.RoundInt64(), precisionFactor)} } // TODO panic if negative or if totalDigits < len(initStr)??? diff --git a/types/rational_test.go b/types/rational_test.go index db875c83e8..3215313e09 100644 --- a/types/rational_test.go +++ b/types/rational_test.go @@ -168,8 +168,8 @@ func TestEvaluate(t *testing.T) { } for _, tc := range tests { - require.Equal(t, tc.res, tc.r1.Evaluate(), "%v", tc.r1) - require.Equal(t, tc.res*-1, tc.r1.Mul(NewRat(-1)).Evaluate(), "%v", tc.r1.Mul(NewRat(-1))) + require.Equal(t, tc.res, tc.r1.RoundInt64(), "%v", tc.r1) + require.Equal(t, tc.res*-1, tc.r1.Mul(NewRat(-1)).RoundInt64(), "%v", tc.r1.Mul(NewRat(-1))) } } diff --git a/types/stake.go b/types/stake.go index 8625b617e5..7cb7ccf6d8 100644 --- a/types/stake.go +++ b/types/stake.go @@ -46,7 +46,7 @@ type Validator interface { func ABCIValidator(v Validator) abci.Validator { return abci.Validator{ PubKey: tmtypes.TM2PB.PubKey(v.GetPubKey()), - Power: v.GetPower().Evaluate(), + Power: v.GetPower().RoundInt64(), } } diff --git a/x/stake/genesis.go b/x/stake/genesis.go index 6a15ebeb42..55dd06f76f 100644 --- a/x/stake/genesis.go +++ b/x/stake/genesis.go @@ -49,7 +49,7 @@ func WriteValidators(ctx sdk.Context, keeper Keeper) (vals []tmtypes.GenesisVali keeper.IterateValidatorsBonded(ctx, func(_ int64, validator sdk.Validator) (stop bool) { vals = append(vals, tmtypes.GenesisValidator{ PubKey: validator.GetPubKey(), - Power: validator.GetPower().Evaluate(), + Power: validator.GetPower().RoundInt64(), Name: validator.GetMoniker(), }) return false diff --git a/x/stake/handler_test.go b/x/stake/handler_test.go index e6cd6f4ca7..b18b3c98b2 100644 --- a/x/stake/handler_test.go +++ b/x/stake/handler_test.go @@ -56,7 +56,7 @@ func TestValidatorByPowerIndex(t *testing.T) { // verify the self-delegation exists bond, found := keeper.GetDelegation(ctx, validatorAddr, validatorAddr) require.True(t, found) - gotBond := bond.Shares.Evaluate() + gotBond := bond.Shares.RoundInt64() require.Equal(t, initBond, gotBond, "initBond: %v\ngotBond: %v\nbond: %v\n", initBond, gotBond, bond) @@ -78,8 +78,8 @@ func TestValidatorByPowerIndex(t *testing.T) { keeper.Revoke(ctx, keep.PKs[0]) validator, found = keeper.GetValidator(ctx, validatorAddr) require.True(t, found) - require.Equal(t, sdk.Unbonded, validator.PoolShares.Status) // ensure is unbonded - require.Equal(t, int64(500000), validator.PoolShares.Amount.Evaluate()) // ensure is unbonded + require.Equal(t, sdk.Unbonded, validator.PoolShares.Status) // ensure is unbonded + require.Equal(t, int64(500000), validator.PoolShares.Amount.RoundInt64()) // ensure is unbonded // the old power record should have been deleted as the power changed require.False(t, keep.ValidatorByPowerIndexExists(ctx, keeper, power)) @@ -155,20 +155,20 @@ func TestIncrementsMsgDelegate(t *testing.T) { validator, found := keeper.GetValidator(ctx, validatorAddr) require.True(t, found) require.Equal(t, sdk.Bonded, validator.Status()) - require.Equal(t, bondAmount, validator.DelegatorShares.Evaluate()) - require.Equal(t, bondAmount, validator.PoolShares.Bonded().Evaluate(), "validator: %v", validator) + require.Equal(t, bondAmount, validator.DelegatorShares.RoundInt64()) + require.Equal(t, bondAmount, validator.PoolShares.Bonded().RoundInt64(), "validator: %v", validator) _, found = keeper.GetDelegation(ctx, delegatorAddr, validatorAddr) require.False(t, found) bond, found := keeper.GetDelegation(ctx, validatorAddr, validatorAddr) require.True(t, found) - require.Equal(t, bondAmount, bond.Shares.Evaluate()) + require.Equal(t, bondAmount, bond.Shares.RoundInt64()) pool := keeper.GetPool(ctx) exRate := validator.DelegatorShareExRate(pool) require.True(t, exRate.Equal(sdk.OneRat()), "expected exRate 1 got %v", exRate) - require.Equal(t, bondAmount, pool.BondedShares.Evaluate()) + require.Equal(t, bondAmount, pool.BondedShares.RoundInt64()) require.Equal(t, bondAmount, pool.BondedTokens) // just send the same msgbond multiple times @@ -196,8 +196,8 @@ func TestIncrementsMsgDelegate(t *testing.T) { require.Equal(t, bond.Height, int64(i), "Incorrect bond height") - gotBond := bond.Shares.Evaluate() - gotDelegatorShares := validator.DelegatorShares.Evaluate() + gotBond := bond.Shares.RoundInt64() + gotDelegatorShares := validator.DelegatorShares.RoundInt64() gotDelegatorAcc := accMapper.GetAccount(ctx, delegatorAddr).GetCoins().AmountOf(params.BondDenom) require.Equal(t, expBond, gotBond, @@ -230,8 +230,8 @@ func TestIncrementsMsgUnbond(t *testing.T) { validator, found := keeper.GetValidator(ctx, validatorAddr) require.True(t, found) - require.Equal(t, initBond*2, validator.DelegatorShares.Evaluate()) - require.Equal(t, initBond*2, validator.PoolShares.Bonded().Evaluate()) + require.Equal(t, initBond*2, validator.DelegatorShares.RoundInt64()) + require.Equal(t, initBond*2, validator.PoolShares.Bonded().RoundInt64()) // just send the same msgUnbond multiple times // TODO use decimals here @@ -251,12 +251,12 @@ func TestIncrementsMsgUnbond(t *testing.T) { bond, found := keeper.GetDelegation(ctx, delegatorAddr, validatorAddr) require.True(t, found) - expBond := initBond - int64(i+1)*unbondShares.Evaluate() - expDelegatorShares := 2*initBond - int64(i+1)*unbondShares.Evaluate() + expBond := initBond - int64(i+1)*unbondShares.RoundInt64() + expDelegatorShares := 2*initBond - int64(i+1)*unbondShares.RoundInt64() expDelegatorAcc := sdk.NewInt(initBond - expBond) - gotBond := bond.Shares.Evaluate() - gotDelegatorShares := validator.DelegatorShares.Evaluate() + gotBond := bond.Shares.RoundInt64() + gotDelegatorShares := validator.DelegatorShares.RoundInt64() gotDelegatorAcc := accMapper.GetAccount(ctx, delegatorAddr).GetCoins().AmountOf(params.BondDenom) require.Equal(t, expBond, gotBond, @@ -285,7 +285,7 @@ func TestIncrementsMsgUnbond(t *testing.T) { require.False(t, got.IsOK(), "expected unbond msg to fail") } - leftBonded := initBond - int64(numUnbonds)*unbondShares.Evaluate() + leftBonded := initBond - int64(numUnbonds)*unbondShares.RoundInt64() // should be unable to unbond one more than we have unbondShares = sdk.NewRat(leftBonded + 1) @@ -322,7 +322,7 @@ func TestMultipleMsgCreateValidator(t *testing.T) { balanceExpd := sdk.NewInt(initBond - 10) balanceGot := accMapper.GetAccount(ctx, val.Owner).GetCoins().AmountOf(params.BondDenom) require.Equal(t, i+1, len(validators), "expected %d validators got %d, validators: %v", i+1, len(validators), validators) - require.Equal(t, 10, int(val.DelegatorShares.Evaluate()), "expected %d shares, got %d", 10, val.DelegatorShares) + require.Equal(t, 10, int(val.DelegatorShares.RoundInt64()), "expected %d shares, got %d", 10, val.DelegatorShares) require.Equal(t, balanceExpd, balanceGot, "expected account to have %d, got %d", balanceExpd, balanceGot) } diff --git a/x/stake/keeper/delegation_test.go b/x/stake/keeper/delegation_test.go index f20188ccdc..eb318df4d3 100644 --- a/x/stake/keeper/delegation_test.go +++ b/x/stake/keeper/delegation_test.go @@ -146,13 +146,13 @@ func TestUnbondDelegation(t *testing.T) { //create a validator and a delegator to that validator validator := types.NewValidator(addrVals[0], PKs[0], types.Description{}) validator, pool, issuedShares := validator.AddTokensFromDel(pool, 10) - require.Equal(t, int64(10), issuedShares.Evaluate()) + require.Equal(t, int64(10), issuedShares.RoundInt64()) keeper.SetPool(ctx, pool) validator = keeper.UpdateValidator(ctx, validator) pool = keeper.GetPool(ctx) require.Equal(t, int64(10), pool.BondedTokens) - require.Equal(t, int64(10), validator.PoolShares.Bonded().Evaluate()) + require.Equal(t, int64(10), validator.PoolShares.Bonded().RoundInt64()) delegation := types.Delegation{ DelegatorAddr: addrDels[0], @@ -173,8 +173,8 @@ func TestUnbondDelegation(t *testing.T) { require.True(t, found) pool = keeper.GetPool(ctx) - require.Equal(t, int64(4), delegation.Shares.Evaluate()) - require.Equal(t, int64(4), validator.PoolShares.Bonded().Evaluate()) + require.Equal(t, int64(4), delegation.Shares.RoundInt64()) + require.Equal(t, int64(4), validator.PoolShares.Bonded().RoundInt64()) require.Equal(t, int64(6), pool.LooseTokens, "%v", pool) require.Equal(t, int64(4), pool.BondedTokens) } diff --git a/x/stake/keeper/inflation.go b/x/stake/keeper/inflation.go index 0574b8ecbf..26b5158791 100644 --- a/x/stake/keeper/inflation.go +++ b/x/stake/keeper/inflation.go @@ -18,7 +18,7 @@ func (k Keeper) ProcessProvisions(ctx sdk.Context) types.Pool { pool := k.GetPool(ctx) pool.Inflation = k.NextInflation(ctx) - provisions := pool.Inflation.Mul(sdk.NewRat(pool.TokenSupply())).Quo(hrsPerYrRat).Evaluate() + provisions := pool.Inflation.Mul(sdk.NewRat(pool.TokenSupply())).Quo(hrsPerYrRat).RoundInt64() // TODO add to the fees provisions pool.LooseTokens += provisions diff --git a/x/stake/keeper/inflation_test.go b/x/stake/keeper/inflation_test.go index 944559dfc2..2fee8154a0 100644 --- a/x/stake/keeper/inflation_test.go +++ b/x/stake/keeper/inflation_test.go @@ -167,7 +167,7 @@ func TestLargeUnbond(t *testing.T) { _, expProvisionsAfter, pool := updateProvisions(t, keeper, pool, ctx, 0) bondedShares = bondedShares.Sub(bondSharesVal0) - val0UnbondedTokens = pool.UnbondedShareExRate().Mul(validator.PoolShares.Unbonded()).Evaluate() + val0UnbondedTokens = pool.UnbondedShareExRate().Mul(validator.PoolShares.Unbonded()).RoundInt64() unbondedShares = unbondedShares.Add(sdk.NewRat(val0UnbondedTokens, 1).Mul(pool.UnbondedShareExRate())) // unbonded shares should increase @@ -295,7 +295,7 @@ func checkFinalPoolValues(t *testing.T, pool types.Pool, initialTotalTokens, cum // Returns expected Provisions, expected Inflation, and pool, to help with cumulative calculations back in main Tests func updateProvisions(t *testing.T, keeper Keeper, pool types.Pool, ctx sdk.Context, hr int) (sdk.Rat, int64, types.Pool) { expInflation := keeper.NextInflation(ctx) - expProvisions := (expInflation.Mul(sdk.NewRat(pool.TokenSupply())).Quo(hrsPerYrRat)).Evaluate() + expProvisions := (expInflation.Mul(sdk.NewRat(pool.TokenSupply())).Quo(hrsPerYrRat)).RoundInt64() startTotalSupply := pool.TokenSupply() pool = keeper.ProcessProvisions(ctx) keeper.SetPool(ctx, pool) diff --git a/x/stake/keeper/slash.go b/x/stake/keeper/slash.go index 9d4c9af62e..b12360fc3f 100644 --- a/x/stake/keeper/slash.go +++ b/x/stake/keeper/slash.go @@ -30,7 +30,7 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in } // Amount of slashing = slash slashFactor * power at time of infraction - slashAmount := sdk.NewRat(power).Mul(slashFactor).EvaluateInt() + slashAmount := sdk.NewRat(power).Mul(slashFactor).RoundInt() // ref https://github.com/cosmos/cosmos-sdk/issues/1348 // ref https://github.com/cosmos/cosmos-sdk/issues/1471 @@ -79,8 +79,8 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in // Cannot decrease balance below zero sharesToRemove := remainingSlashAmount - if sharesToRemove.GT(validator.PoolShares.Amount.EvaluateInt()) { - sharesToRemove = validator.PoolShares.Amount.EvaluateInt() + if sharesToRemove.GT(validator.PoolShares.Amount.RoundInt()) { + sharesToRemove = validator.PoolShares.Amount.RoundInt() } // Get the current pool @@ -150,7 +150,7 @@ func (k Keeper) slashUnbondingDelegation(ctx sdk.Context, unbondingDelegation ty } // Calculate slash amount proportional to stake contributing to infraction - slashAmount = sdk.NewRatFromInt(unbondingDelegation.InitialBalance.Amount, sdk.OneInt()).Mul(slashFactor).EvaluateInt() + slashAmount = sdk.NewRatFromInt(unbondingDelegation.InitialBalance.Amount, sdk.OneInt()).Mul(slashFactor).RoundInt() // Don't slash more tokens than held // Possible since the unbonding delegation may already @@ -195,7 +195,7 @@ func (k Keeper) slashRedelegation(ctx sdk.Context, validator types.Validator, re } // Calculate slash amount proportional to stake contributing to infraction - slashAmount = sdk.NewRatFromInt(redelegation.InitialBalance.Amount, sdk.OneInt()).Mul(slashFactor).EvaluateInt() + slashAmount = sdk.NewRatFromInt(redelegation.InitialBalance.Amount, sdk.OneInt()).Mul(slashFactor).RoundInt() // Don't slash more tokens than held // Possible since the redelegation may already diff --git a/x/stake/keeper/slash_test.go b/x/stake/keeper/slash_test.go index 9e53151a18..dcd38e15e2 100644 --- a/x/stake/keeper/slash_test.go +++ b/x/stake/keeper/slash_test.go @@ -160,7 +160,7 @@ func TestSlashRedelegation(t *testing.T) { // shares decreased del, found = keeper.GetDelegation(ctx, addrDels[0], addrVals[1]) require.True(t, found) - require.Equal(t, int64(5), del.Shares.Evaluate()) + require.Equal(t, int64(5), del.Shares.RoundInt64()) // pool bonded tokens decreased newPool := keeper.GetPool(ctx) require.Equal(t, int64(5), oldPool.BondedTokens-newPool.BondedTokens) @@ -193,7 +193,7 @@ func TestSlashAtCurrentHeight(t *testing.T) { // power decreased require.Equal(t, sdk.NewRat(5), validator.GetPower()) // pool bonded shares decreased - require.Equal(t, sdk.NewRat(5).Evaluate(), oldPool.BondedShares.Sub(newPool.BondedShares).Evaluate()) + require.Equal(t, sdk.NewRat(5).RoundInt64(), oldPool.BondedShares.Sub(newPool.BondedShares).RoundInt64()) } // tests Slash at a previous height with an unbonding delegation diff --git a/x/stake/keeper/validator_test.go b/x/stake/keeper/validator_test.go index cf26d055f6..c4d197a36b 100644 --- a/x/stake/keeper/validator_test.go +++ b/x/stake/keeper/validator_test.go @@ -68,12 +68,12 @@ func TestUpdateValidatorByPowerIndex(t *testing.T) { validator := types.NewValidator(addrVals[0], PKs[0], types.Description{}) validator, pool, delSharesCreated := validator.AddTokensFromDel(pool, 100) require.Equal(t, sdk.Unbonded, validator.Status()) - require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).Evaluate()) + require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).RoundInt64()) keeper.SetPool(ctx, pool) keeper.UpdateValidator(ctx, validator) validator, found := keeper.GetValidator(ctx, addrVals[0]) require.True(t, found) - require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).Evaluate(), "\nvalidator %v\npool %v", validator, pool) + require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).RoundInt64(), "\nvalidator %v\npool %v", validator, pool) pool = keeper.GetPool(ctx) power := GetValidatorsByPowerIndexKey(validator, pool) diff --git a/x/stake/types/pool.go b/x/stake/types/pool.go index cb2ad240ae..8ef187f078 100644 --- a/x/stake/types/pool.go +++ b/x/stake/types/pool.go @@ -104,7 +104,7 @@ func (p Pool) addTokensUnbonded(amount int64) (p2 Pool, issuedShares PoolShares) } func (p Pool) removeSharesUnbonded(shares sdk.Rat) (p2 Pool, removedTokens int64) { - removedTokens = p.UnbondedShareExRate().Mul(shares).Evaluate() // (tokens/shares) * shares + removedTokens = p.UnbondedShareExRate().Mul(shares).RoundInt64() // (tokens/shares) * shares p.UnbondedShares = p.UnbondedShares.Sub(shares) p.UnbondedTokens -= removedTokens p.LooseTokens += removedTokens @@ -126,7 +126,7 @@ func (p Pool) addTokensUnbonding(amount int64) (p2 Pool, issuedShares PoolShares } func (p Pool) removeSharesUnbonding(shares sdk.Rat) (p2 Pool, removedTokens int64) { - removedTokens = p.UnbondingShareExRate().Mul(shares).Evaluate() // (tokens/shares) * shares + removedTokens = p.UnbondingShareExRate().Mul(shares).RoundInt64() // (tokens/shares) * shares p.UnbondingShares = p.UnbondingShares.Sub(shares) p.UnbondingTokens -= removedTokens p.LooseTokens += removedTokens @@ -148,7 +148,7 @@ func (p Pool) addTokensBonded(amount int64) (p2 Pool, issuedShares PoolShares) { } func (p Pool) removeSharesBonded(shares sdk.Rat) (p2 Pool, removedTokens int64) { - removedTokens = p.BondedShareExRate().Mul(shares).Evaluate() // (tokens/shares) * shares + removedTokens = p.BondedShareExRate().Mul(shares).RoundInt64() // (tokens/shares) * shares p.BondedShares = p.BondedShares.Sub(shares) p.BondedTokens -= removedTokens p.LooseTokens += removedTokens diff --git a/x/stake/types/test_common.go b/x/stake/types/test_common.go index 5edb5568d8..12f11f864b 100644 --- a/x/stake/types/test_common.go +++ b/x/stake/types/test_common.go @@ -118,12 +118,12 @@ func AssertInvariants(t *testing.T, msg string, // nonnegative bonded ex rate require.False(t, pMod.BondedShareExRate().LT(sdk.ZeroRat()), "Applying operation \"%s\" resulted in negative BondedShareExRate: %d", - msg, pMod.BondedShareExRate().Evaluate()) + msg, pMod.BondedShareExRate().RoundInt64()) // nonnegative unbonded ex rate require.False(t, pMod.UnbondedShareExRate().LT(sdk.ZeroRat()), "Applying operation \"%s\" resulted in negative UnbondedShareExRate: %d", - msg, pMod.UnbondedShareExRate().Evaluate()) + msg, pMod.UnbondedShareExRate().RoundInt64()) for _, vMod := range vMods { @@ -193,10 +193,10 @@ func RandomSetup(r *rand.Rand, numValidators int) (Pool, []Validator) { validator := randomValidator(r, i) if validator.Status() == sdk.Bonded { pool.BondedShares = pool.BondedShares.Add(validator.PoolShares.Bonded()) - pool.BondedTokens += validator.PoolShares.Bonded().Evaluate() + pool.BondedTokens += validator.PoolShares.Bonded().RoundInt64() } else if validator.Status() == sdk.Unbonded { pool.UnbondedShares = pool.UnbondedShares.Add(validator.PoolShares.Unbonded()) - pool.UnbondedTokens += validator.PoolShares.Unbonded().Evaluate() + pool.UnbondedTokens += validator.PoolShares.Unbonded().RoundInt64() } validators[i] = validator } diff --git a/x/stake/types/validator.go b/x/stake/types/validator.go index c98ebce62a..c2c19439be 100644 --- a/x/stake/types/validator.go +++ b/x/stake/types/validator.go @@ -137,7 +137,7 @@ func (d Description) EnsureLength() (Description, sdk.Error) { func (v Validator) ABCIValidator() abci.Validator { return abci.Validator{ PubKey: tmtypes.TM2PB.PubKey(v.PubKey), - Power: v.PoolShares.Bonded().Evaluate(), + Power: v.PoolShares.Bonded().RoundInt64(), } } diff --git a/x/stake/types/validator_test.go b/x/stake/types/validator_test.go index 6a8ff777a6..4fcfa6e17d 100644 --- a/x/stake/types/validator_test.go +++ b/x/stake/types/validator_test.go @@ -69,7 +69,7 @@ func TestRemoveDelShares(t *testing.T) { PoolShares: NewBondedShares(sdk.NewRat(100)), DelegatorShares: sdk.NewRat(100), } - poolA.BondedTokens = valA.PoolShares.Bonded().Evaluate() + poolA.BondedTokens = valA.PoolShares.Bonded().RoundInt64() poolA.BondedShares = valA.PoolShares.Bonded() require.Equal(t, valA.DelegatorShareExRate(poolA), sdk.OneRat()) require.Equal(t, poolA.BondedShareExRate(), sdk.OneRat()) @@ -117,25 +117,25 @@ func TestUpdateStatus(t *testing.T) { val := NewValidator(addr1, pk1, Description{}) val, pool, _ = val.AddTokensFromDel(pool, 100) - require.Equal(t, int64(0), val.PoolShares.Bonded().Evaluate()) - require.Equal(t, int64(0), val.PoolShares.Unbonding().Evaluate()) - require.Equal(t, int64(100), val.PoolShares.Unbonded().Evaluate()) + require.Equal(t, int64(0), val.PoolShares.Bonded().RoundInt64()) + require.Equal(t, int64(0), val.PoolShares.Unbonding().RoundInt64()) + require.Equal(t, int64(100), val.PoolShares.Unbonded().RoundInt64()) require.Equal(t, int64(0), pool.BondedTokens) require.Equal(t, int64(0), pool.UnbondingTokens) require.Equal(t, int64(100), pool.UnbondedTokens) val, pool = val.UpdateStatus(pool, sdk.Unbonding) - require.Equal(t, int64(0), val.PoolShares.Bonded().Evaluate()) - require.Equal(t, int64(100), val.PoolShares.Unbonding().Evaluate()) - require.Equal(t, int64(0), val.PoolShares.Unbonded().Evaluate()) + require.Equal(t, int64(0), val.PoolShares.Bonded().RoundInt64()) + require.Equal(t, int64(100), val.PoolShares.Unbonding().RoundInt64()) + require.Equal(t, int64(0), val.PoolShares.Unbonded().RoundInt64()) require.Equal(t, int64(0), pool.BondedTokens) require.Equal(t, int64(100), pool.UnbondingTokens) require.Equal(t, int64(0), pool.UnbondedTokens) val, pool = val.UpdateStatus(pool, sdk.Bonded) - require.Equal(t, int64(100), val.PoolShares.Bonded().Evaluate()) - require.Equal(t, int64(0), val.PoolShares.Unbonding().Evaluate()) - require.Equal(t, int64(0), val.PoolShares.Unbonded().Evaluate()) + require.Equal(t, int64(100), val.PoolShares.Bonded().RoundInt64()) + require.Equal(t, int64(0), val.PoolShares.Unbonding().RoundInt64()) + require.Equal(t, int64(0), val.PoolShares.Unbonded().RoundInt64()) require.Equal(t, int64(100), pool.BondedTokens) require.Equal(t, int64(0), pool.UnbondingTokens) require.Equal(t, int64(0), pool.UnbondedTokens) @@ -154,7 +154,7 @@ func TestPossibleOverflow(t *testing.T) { LooseTokens: 100, BondedShares: poolShares, UnbondedShares: sdk.ZeroRat(), - BondedTokens: poolShares.Evaluate(), + BondedTokens: poolShares.RoundInt64(), UnbondedTokens: 0, InflationLastTime: 0, Inflation: sdk.NewRat(7, 100),