From 1839851975257d76c623dd854a22596f8b0d461c Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Wed, 7 Aug 2019 12:54:13 -0400 Subject: [PATCH] Merge PR #4861: Simulation Fixes --- sim_test.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sim_test.go b/sim_test.go index ee828f3bae75..843496e9d47b 100644 --- a/sim_test.go +++ b/sim_test.go @@ -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) @@ -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) }