Skip to content

Commit

Permalink
Merge PR cosmos#4861: Simulation Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Aug 7, 2019
1 parent 3e3b741 commit 1839851
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ func TestAppSimulationAfterImport(t *testing.T) {

defer func() {
newDB.Close()
os.RemoveAll(newDir)
_ = os.RemoveAll(newDir)
}()

newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, 0, fauxMerkleModeOpt)
Expand All @@ -708,21 +708,29 @@ func TestAppStateDeterminism(t *testing.T) {

for i := 0; i < numSeeds; i++ {
seed := rand.Int63()

for j := 0; j < numTimesToRunPerSeed; j++ {
logger := log.NewNopLogger()
db := dbm.NewMemDB()
app := NewSimApp(logger, db, nil, true, 0)

// Run randomized simulation
simulation.SimulateFromSeed(
t, os.Stdout, app.BaseApp, appStateFn, seed,
testAndRunTxs(app), []sdk.Invariant{},
1, 50, 100, 0, "",
false, true, false, false, false, app.ModuleAccountAddrs(),
fmt.Printf(
"Running non-determinism simulation; seed: %d/%d (%d), attempt: %d/%d\n",
i+1, numSeeds, seed, j+1, numTimesToRunPerSeed,
)

_, _, err := simulation.SimulateFromSeed(
t, os.Stdout, app.BaseApp, appStateFn, seed, testAndRunTxs(app),
[]sdk.Invariant{}, 1, numBlocks, exportParamsHeight,
blockSize, "", false, commit, lean,
false, false, app.ModuleAccountAddrs(),
)
require.NoError(t, err)

appHash := app.LastCommitID().Hash
appHashList[j] = appHash
}

for k := 1; k < numTimesToRunPerSeed; k++ {
require.Equal(t, appHashList[0], appHashList[k], "appHash list: %v", appHashList)
}
Expand Down

0 comments on commit 1839851

Please sign in to comment.