Misc, environment variables

This commit is contained in:
Christopher Goes
2018-07-18 07:37:38 +02:00
parent c61b1aa591
commit 6c61577b0b
6 changed files with 54 additions and 13 deletions
+7 -1
View File
@@ -1,6 +1,7 @@
package simulation
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
@@ -30,12 +31,17 @@ func SupplyInvariants(ck bank.Keeper, k stake.Keeper, am auth.AccountMapper) sim
ctx := app.NewContext(false, abci.Header{})
pool := k.GetPool(ctx)
// Loose tokens should equal coin supply
// Loose tokens should equal coin supply plus unbonding delegations
loose := sdk.ZeroInt()
am.IterateAccounts(ctx, func(acc auth.Account) bool {
loose = loose.Add(acc.GetCoins().AmountOf("steak"))
return false
})
k.IterateUnbondingDelegations(ctx, func(_ int64, ubd stake.UnbondingDelegation) bool {
fmt.Printf("found ubd with balance: %v\n", ubd.Balance)
loose = loose.Add(ubd.Balance.Amount)
return false
})
require.True(t, pool.LooseTokens.RoundInt64() == loose.Int64(), "expected loose tokens to equal total steak held by accounts - pool.LooseTokens: %v, sum of account tokens: %v\nlog: %s",
pool.LooseTokens, loose, log)
// stats["stake/invariant/looseTokens"] += 1
+2 -3
View File
@@ -46,8 +46,7 @@ func TestStakeWithRandomMessages(t *testing.T) {
SimulateMsgCreateValidator(mapper, stakeKeeper),
SimulateMsgEditValidator(stakeKeeper),
SimulateMsgDelegate(mapper, stakeKeeper),
// XXX TODO
// SimulateMsgBeginUnbonding(mapper, stakeKeeper),
SimulateMsgBeginUnbonding(mapper, stakeKeeper),
SimulateMsgCompleteUnbonding(stakeKeeper),
SimulateMsgBeginRedelegate(mapper, stakeKeeper),
SimulateMsgCompleteRedelegate(stakeKeeper),
@@ -55,6 +54,6 @@ func TestStakeWithRandomMessages(t *testing.T) {
SimulationSetup(mapp, stakeKeeper),
}, []simulation.Invariant{
AllInvariants(coinKeeper, stakeKeeper, mapp.AccountMapper),
}, 10, 100, 500,
}, 10, 100, 100,
)
}