From 05ceff521283705be9d95b29849f0e32e7719014 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Wed, 18 Jul 2018 09:37:14 +0200 Subject: [PATCH] Deterministic 'make test_sim' on CircleCI; bank test fix --- .circleci/config.yml | 1 + x/bank/app_test.go | 2 -- x/stake/simulation/invariants.go | 5 +---- x/stake/simulation/msgs.go | 12 ++++++------ 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bba1031fd7..ff9395c526 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,6 +99,7 @@ jobs: name: Test simulation command: | export PATH="$GOBIN:$PATH" + export GAIA_SIMULATION_SEED=1531897442166404087 make test_sim test_cover: diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 8c82cd4752..2deb5de38f 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -5,8 +5,6 @@ import ( "github.com/stretchr/testify/require" - "math/rand" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/mock" diff --git a/x/stake/simulation/invariants.go b/x/stake/simulation/invariants.go index 776c8d1e7d..92dd317d02 100644 --- a/x/stake/simulation/invariants.go +++ b/x/stake/simulation/invariants.go @@ -41,8 +41,7 @@ func SupplyInvariants(ck bank.Keeper, k stake.Keeper, am auth.AccountMapper) sim 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 + pool.LooseTokens.RoundInt64(), loose.Int64(), log) // Bonded tokens should equal sum of tokens with bonded validators bonded := sdk.ZeroRat() @@ -54,7 +53,6 @@ func SupplyInvariants(ck bank.Keeper, k stake.Keeper, am auth.AccountMapper) sim return false }) require.True(t, pool.BondedTokens.Equal(bonded), "expected bonded tokens to equal total steak held by bonded validators\nlog: %s", log) - // stats["stake/invariant/bondedTokens"] += 1 // TODO Inflation check on total supply } @@ -68,7 +66,6 @@ func PositivePowerInvariant(k stake.Keeper) simulation.Invariant { require.True(t, validator.GetPower().GT(sdk.ZeroRat()), "validator with non-positive power stored") return false }) - // stats["stake/invariant/positivePower"] += 1 } } diff --git a/x/stake/simulation/msgs.go b/x/stake/simulation/msgs.go index f46881e307..597046107c 100644 --- a/x/stake/simulation/msgs.go +++ b/x/stake/simulation/msgs.go @@ -49,7 +49,7 @@ func SimulateMsgCreateValidator(m auth.AccountMapper, k stake.Keeper) simulation } event(fmt.Sprintf("stake/MsgCreateValidator/%v", result.IsOK())) // require.True(t, result.IsOK(), "expected OK result but instead got %v", result) - action = fmt.Sprintf("TestMsgCreateValidator: %s", msg.GetSignBytes()) + action = fmt.Sprintf("TestMsgCreateValidator: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil } } @@ -77,7 +77,7 @@ func SimulateMsgEditValidator(k stake.Keeper) simulation.TestAndRunTx { write() } event(fmt.Sprintf("stake/MsgEditValidator/%v", result.IsOK())) - action = fmt.Sprintf("TestMsgEditValidator: %s", msg.GetSignBytes()) + action = fmt.Sprintf("TestMsgEditValidator: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil } } @@ -109,7 +109,7 @@ func SimulateMsgDelegate(m auth.AccountMapper, k stake.Keeper) simulation.TestAn write() } event(fmt.Sprintf("stake/MsgDelegate/%v", result.IsOK())) - action = fmt.Sprintf("TestMsgDelegate: %s", msg.GetSignBytes()) + action = fmt.Sprintf("TestMsgDelegate: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil } } @@ -141,7 +141,7 @@ func SimulateMsgBeginUnbonding(m auth.AccountMapper, k stake.Keeper) simulation. write() } event(fmt.Sprintf("stake/MsgBeginUnbonding/%v", result.IsOK())) - action = fmt.Sprintf("TestMsgBeginUnbonding: %s", msg.GetSignBytes()) + action = fmt.Sprintf("TestMsgBeginUnbonding: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil } } @@ -164,7 +164,7 @@ func SimulateMsgCompleteUnbonding(k stake.Keeper) simulation.TestAndRunTx { write() } event(fmt.Sprintf("stake/MsgCompleteUnbonding/%v", result.IsOK())) - action = fmt.Sprintf("TestMsgCompleteUnbonding with %s", msg.GetSignBytes()) + action = fmt.Sprintf("TestMsgCompleteUnbonding: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil } } @@ -226,7 +226,7 @@ func SimulateMsgCompleteRedelegate(k stake.Keeper) simulation.TestAndRunTx { write() } event(fmt.Sprintf("stake/MsgCompleteRedelegate/%v", result.IsOK())) - action = fmt.Sprintf("TestMsgCompleteRedelegate with %s", msg.GetSignBytes()) + action = fmt.Sprintf("TestMsgCompleteRedelegate: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil } }