diff --git a/x/mock/simulation/random_simulate_blocks.go b/x/mock/simulation/random_simulate_blocks.go index e952ce07f7..5f507b89c1 100644 --- a/x/mock/simulation/random_simulate_blocks.go +++ b/x/mock/simulation/random_simulate_blocks.go @@ -36,7 +36,7 @@ func SimulateFromSeed( // Setup event stats events := make(map[string]uint) event := func(what string) { - events[what] += 1 + events[what]++ } app.InitChain(abci.RequestInitChain{AppStateBytes: appStateFn(r, addrs)}) diff --git a/x/mock/simulation/util.go b/x/mock/simulation/util.go index 35dcc19257..8fdf5021e0 100644 --- a/x/mock/simulation/util.go +++ b/x/mock/simulation/util.go @@ -15,6 +15,7 @@ const ( letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits ) +// Generate a random string of a particular length func RandStringOfLength(r *rand.Rand, n int) string { b := make([]byte, n) // A src.Int63() generates 63 random bits, enough for letterIdxMax characters! @@ -32,6 +33,7 @@ func RandStringOfLength(r *rand.Rand, n int) string { return string(b) } +// Pretty-print events as a table func DisplayEvents(events map[string]uint) { // TODO fmt.Printf("Events: %v\n", events) diff --git a/x/stake/simulation/msgs.go b/x/stake/simulation/msgs.go index c3060190fe..f46881e307 100644 --- a/x/stake/simulation/msgs.go +++ b/x/stake/simulation/msgs.go @@ -231,8 +231,8 @@ func SimulateMsgCompleteRedelegate(k stake.Keeper) simulation.TestAndRunTx { } } -// SimulationSetup -func SimulationSetup(mapp *mock.App, k stake.Keeper) simulation.RandSetup { +// Setup +func Setup(mapp *mock.App, k stake.Keeper) simulation.RandSetup { return func(r *rand.Rand, privKeys []crypto.PrivKey) { ctx := mapp.NewContext(false, abci.Header{}) stake.InitGenesis(ctx, k, stake.DefaultGenesisState()) diff --git a/x/stake/simulation/sim_test.go b/x/stake/simulation/sim_test.go index a2afeb665a..391ca1996e 100644 --- a/x/stake/simulation/sim_test.go +++ b/x/stake/simulation/sim_test.go @@ -51,7 +51,7 @@ func TestStakeWithRandomMessages(t *testing.T) { SimulateMsgBeginRedelegate(mapper, stakeKeeper), SimulateMsgCompleteRedelegate(stakeKeeper), }, []simulation.RandSetup{ - SimulationSetup(mapp, stakeKeeper), + Setup(mapp, stakeKeeper), }, []simulation.Invariant{ AllInvariants(coinKeeper, stakeKeeper, mapp.AccountMapper), }, 10, 100, 100,