2019-05-18 01:42:24 -07:00
|
|
|
package simapp
|
2018-07-11 15:14:37 -07:00
|
|
|
|
|
|
|
import (
|
2018-07-17 15:04:10 -07:00
|
|
|
"encoding/json"
|
2018-09-01 19:04:44 -07:00
|
|
|
"fmt"
|
2018-07-17 15:04:10 -07:00
|
|
|
"math/rand"
|
2018-08-30 11:43:56 -07:00
|
|
|
"os"
|
2018-07-11 15:14:37 -07:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2020-02-19 03:52:20 -08:00
|
|
|
|
2018-11-08 16:28:28 -08:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
2018-07-12 13:01:43 -07:00
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
2019-08-02 06:20:39 -07:00
|
|
|
dbm "github.com/tendermint/tm-db"
|
2018-07-12 13:01:43 -07:00
|
|
|
|
2018-11-27 00:14:22 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
2019-10-23 02:14:45 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
2019-09-04 10:33:32 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/store"
|
2018-07-17 15:04:10 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2019-07-31 06:59:16 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
2020-06-14 16:06:16 -07:00
|
|
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
2020-06-14 10:05:45 -07:00
|
|
|
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
2020-06-14 04:01:47 -07:00
|
|
|
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
2020-06-14 02:58:48 -07:00
|
|
|
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
|
2020-06-13 02:07:51 -07:00
|
|
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
2020-06-13 13:20:38 -07:00
|
|
|
ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
2020-06-13 07:29:00 -07:00
|
|
|
ibchost "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
2020-06-12 17:26:19 -07:00
|
|
|
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
2020-02-19 03:52:20 -08:00
|
|
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
2019-03-14 11:13:15 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/simulation"
|
2020-06-12 07:25:12 -07:00
|
|
|
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
|
|
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
2018-07-11 15:14:37 -07:00
|
|
|
)
|
|
|
|
|
2019-08-28 07:58:25 -07:00
|
|
|
// Get flags every time the simulator is run
|
2018-07-18 23:40:46 -07:00
|
|
|
func init() {
|
2019-08-15 08:35:25 -07:00
|
|
|
GetSimulatorFlags()
|
2019-06-08 13:55:47 -07:00
|
|
|
}
|
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
type StoreKeysPrefixes struct {
|
|
|
|
A sdk.StoreKey
|
|
|
|
B sdk.StoreKey
|
|
|
|
Prefixes [][]byte
|
|
|
|
}
|
|
|
|
|
2019-09-04 10:33:32 -07:00
|
|
|
// fauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of
|
|
|
|
// an IAVLStore for faster simulation speed.
|
2018-11-27 00:14:22 -08:00
|
|
|
func fauxMerkleModeOpt(bapp *baseapp.BaseApp) {
|
|
|
|
bapp.SetFauxMerkleMode()
|
|
|
|
}
|
|
|
|
|
2019-09-04 10:33:32 -07:00
|
|
|
// interBlockCacheOpt returns a BaseApp option function that sets the persistent
|
|
|
|
// inter-block write-through cache.
|
|
|
|
func interBlockCacheOpt() func(*baseapp.BaseApp) {
|
|
|
|
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager())
|
|
|
|
}
|
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
func TestFullAppSimulation(t *testing.T) {
|
2019-12-17 10:28:52 -08:00
|
|
|
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation")
|
|
|
|
if skip {
|
2019-08-28 07:58:25 -07:00
|
|
|
t.Skip("skipping application simulation")
|
2018-07-17 15:04:10 -07:00
|
|
|
}
|
2019-12-17 10:28:52 -08:00
|
|
|
require.NoError(t, err, "simulation setup failed")
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2018-10-29 16:10:39 -07:00
|
|
|
defer func() {
|
|
|
|
db.Close()
|
2019-12-17 10:28:52 -08:00
|
|
|
require.NoError(t, os.RemoveAll(dir))
|
2018-10-29 16:10:39 -07:00
|
|
|
}()
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2020-02-27 22:26:04 -08:00
|
|
|
app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, fauxMerkleModeOpt)
|
2019-05-18 01:42:24 -07:00
|
|
|
require.Equal(t, "SimApp", app.Name())
|
2018-07-17 15:04:10 -07:00
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
// run randomized simulation
|
2019-08-28 07:58:25 -07:00
|
|
|
_, simParams, simErr := simulation.SimulateFromSeed(
|
2019-12-17 10:28:52 -08:00
|
|
|
t, os.Stdout, app.BaseApp, AppStateFn(app.Codec(), app.SimulationManager()),
|
2019-12-05 01:29:54 -08:00
|
|
|
SimulationOperations(app, app.Codec(), config),
|
|
|
|
app.ModuleAccountAddrs(), config,
|
2019-08-15 08:35:25 -07:00
|
|
|
)
|
2019-07-19 09:59:04 -07:00
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
// export state and simParams before the simulation error is checked
|
|
|
|
err = CheckExportSimulation(app, config, simParams)
|
|
|
|
require.NoError(t, err)
|
2019-07-19 09:59:04 -07:00
|
|
|
require.NoError(t, simErr)
|
|
|
|
|
2019-08-15 08:35:25 -07:00
|
|
|
if config.Commit {
|
2019-12-17 10:28:52 -08:00
|
|
|
PrintStats(db)
|
2018-09-01 19:04:44 -07:00
|
|
|
}
|
2018-07-11 15:14:37 -07:00
|
|
|
}
|
2018-08-16 08:36:15 -07:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
func TestAppImportExport(t *testing.T) {
|
2019-12-17 10:28:52 -08:00
|
|
|
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation")
|
|
|
|
if skip {
|
2019-08-28 07:58:25 -07:00
|
|
|
t.Skip("skipping application import/export simulation")
|
2018-11-08 16:28:28 -08:00
|
|
|
}
|
2019-12-17 10:28:52 -08:00
|
|
|
require.NoError(t, err, "simulation setup failed")
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2018-11-08 16:28:28 -08:00
|
|
|
defer func() {
|
|
|
|
db.Close()
|
2019-12-17 10:28:52 -08:00
|
|
|
require.NoError(t, os.RemoveAll(dir))
|
2018-11-08 16:28:28 -08:00
|
|
|
}()
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2020-02-27 22:26:04 -08:00
|
|
|
app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, fauxMerkleModeOpt)
|
2019-05-18 01:42:24 -07:00
|
|
|
require.Equal(t, "SimApp", app.Name())
|
2018-11-08 16:28:28 -08:00
|
|
|
|
|
|
|
// Run randomized simulation
|
2019-08-15 08:35:25 -07:00
|
|
|
_, simParams, simErr := simulation.SimulateFromSeed(
|
2019-12-17 10:28:52 -08:00
|
|
|
t, os.Stdout, app.BaseApp, AppStateFn(app.Codec(), app.SimulationManager()),
|
2019-12-05 01:29:54 -08:00
|
|
|
SimulationOperations(app, app.Codec(), config),
|
|
|
|
app.ModuleAccountAddrs(), config,
|
2019-08-15 08:35:25 -07:00
|
|
|
)
|
2019-07-19 09:59:04 -07:00
|
|
|
|
2019-07-31 06:59:16 -07:00
|
|
|
// export state and simParams before the simulation error is checked
|
2019-12-17 10:28:52 -08:00
|
|
|
err = CheckExportSimulation(app, config, simParams)
|
|
|
|
require.NoError(t, err)
|
2019-07-19 09:59:04 -07:00
|
|
|
require.NoError(t, simErr)
|
2019-03-14 11:13:15 -07:00
|
|
|
|
2019-08-15 08:35:25 -07:00
|
|
|
if config.Commit {
|
2019-12-17 10:28:52 -08:00
|
|
|
PrintStats(db)
|
2018-11-08 16:28:28 -08:00
|
|
|
}
|
|
|
|
|
2019-08-28 07:58:25 -07:00
|
|
|
fmt.Printf("exporting genesis...\n")
|
2018-11-08 16:28:28 -08:00
|
|
|
|
2020-04-22 11:24:13 -07:00
|
|
|
appState, _, consensusParams, err := app.ExportAppStateAndValidators(false, []string{})
|
2019-02-08 13:45:41 -08:00
|
|
|
require.NoError(t, err)
|
2019-12-17 10:28:52 -08:00
|
|
|
|
2019-08-28 07:58:25 -07:00
|
|
|
fmt.Printf("importing genesis...\n")
|
2018-11-08 16:28:28 -08:00
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
_, newDB, newDir, _, _, err := SetupSimulation("leveldb-app-sim-2", "Simulation-2")
|
|
|
|
require.NoError(t, err, "simulation setup failed")
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2018-11-08 16:28:28 -08:00
|
|
|
defer func() {
|
|
|
|
newDB.Close()
|
2019-12-17 10:28:52 -08:00
|
|
|
require.NoError(t, os.RemoveAll(newDir))
|
2018-11-08 16:28:28 -08:00
|
|
|
}()
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2020-02-27 22:26:04 -08:00
|
|
|
newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, fauxMerkleModeOpt)
|
2019-05-18 01:42:24 -07:00
|
|
|
require.Equal(t, "SimApp", newApp.Name())
|
|
|
|
|
2018-11-26 04:21:23 -08:00
|
|
|
var genesisState GenesisState
|
2019-12-17 10:28:52 -08:00
|
|
|
err = app.Codec().UnmarshalJSON(appState, &genesisState)
|
2019-08-15 08:35:25 -07:00
|
|
|
require.NoError(t, err)
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
ctxA := app.NewContext(true, abci.Header{Height: app.LastBlockHeight()})
|
2019-08-06 12:11:55 -07:00
|
|
|
ctxB := newApp.NewContext(true, abci.Header{Height: app.LastBlockHeight()})
|
2020-02-18 04:50:13 -08:00
|
|
|
newApp.mm.InitGenesis(ctxB, app.Codec(), genesisState)
|
2020-04-22 11:24:13 -07:00
|
|
|
newApp.StoreConsensusParams(ctxB, consensusParams)
|
2018-11-08 16:28:28 -08:00
|
|
|
|
2019-08-28 07:58:25 -07:00
|
|
|
fmt.Printf("comparing stores...\n")
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2018-11-08 16:28:28 -08:00
|
|
|
storeKeysPrefixes := []StoreKeysPrefixes{
|
2019-07-31 06:59:16 -07:00
|
|
|
{app.keys[auth.StoreKey], newApp.keys[auth.StoreKey], [][]byte{}},
|
2020-06-12 07:25:12 -07:00
|
|
|
{app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey],
|
2019-07-31 06:59:16 -07:00
|
|
|
[][]byte{
|
2020-06-12 07:25:12 -07:00
|
|
|
stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey,
|
|
|
|
stakingtypes.HistoricalInfoKey,
|
2019-07-31 06:59:16 -07:00
|
|
|
}}, // ordering may change but it doesn't matter
|
2020-06-12 07:25:12 -07:00
|
|
|
{app.keys[slashingtypes.StoreKey], newApp.keys[slashingtypes.StoreKey], [][]byte{}},
|
2020-06-12 17:26:19 -07:00
|
|
|
{app.keys[minttypes.StoreKey], newApp.keys[minttypes.StoreKey], [][]byte{}},
|
2020-06-14 04:01:47 -07:00
|
|
|
{app.keys[distrtypes.StoreKey], newApp.keys[distrtypes.StoreKey], [][]byte{}},
|
2020-06-14 16:06:16 -07:00
|
|
|
{app.keys[banktypes.StoreKey], newApp.keys[banktypes.StoreKey], [][]byte{banktypes.BalancesPrefix}},
|
2020-02-19 03:52:20 -08:00
|
|
|
{app.keys[paramtypes.StoreKey], newApp.keys[paramtypes.StoreKey], [][]byte{}},
|
2020-06-13 02:07:51 -07:00
|
|
|
{app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}},
|
2020-06-14 02:58:48 -07:00
|
|
|
{app.keys[evidencetypes.StoreKey], newApp.keys[evidencetypes.StoreKey], [][]byte{}},
|
2020-06-14 10:05:45 -07:00
|
|
|
{app.keys[capabilitytypes.StoreKey], newApp.keys[capabilitytypes.StoreKey], [][]byte{}},
|
2020-06-13 07:29:00 -07:00
|
|
|
{app.keys[ibchost.StoreKey], newApp.keys[ibchost.StoreKey], [][]byte{}},
|
2020-06-13 13:20:38 -07:00
|
|
|
{app.keys[ibctransfertypes.StoreKey], newApp.keys[ibctransfertypes.StoreKey], [][]byte{}},
|
2018-11-08 16:28:28 -08:00
|
|
|
}
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
for _, skp := range storeKeysPrefixes {
|
|
|
|
storeA := ctxA.KVStore(skp.A)
|
|
|
|
storeB := ctxB.KVStore(skp.B)
|
2019-08-13 15:16:03 -07:00
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
failedKVAs, failedKVBs := sdk.DiffKVStores(storeA, storeB, skp.Prefixes)
|
2019-08-13 15:16:03 -07:00
|
|
|
require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare")
|
|
|
|
|
2020-04-20 08:22:12 -07:00
|
|
|
fmt.Printf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B)
|
2020-04-21 14:33:56 -07:00
|
|
|
require.Equal(t, len(failedKVAs), 0, GetSimulationLog(skp.A.Name(), app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs))
|
2018-11-08 16:28:28 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
func TestAppSimulationAfterImport(t *testing.T) {
|
2019-12-17 10:28:52 -08:00
|
|
|
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation")
|
|
|
|
if skip {
|
2019-08-28 07:58:25 -07:00
|
|
|
t.Skip("skipping application simulation after import")
|
2018-11-26 04:21:23 -08:00
|
|
|
}
|
2019-12-17 10:28:52 -08:00
|
|
|
require.NoError(t, err, "simulation setup failed")
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2018-11-26 04:21:23 -08:00
|
|
|
defer func() {
|
|
|
|
db.Close()
|
2019-12-17 10:28:52 -08:00
|
|
|
require.NoError(t, os.RemoveAll(dir))
|
2018-11-26 04:21:23 -08:00
|
|
|
}()
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2020-02-27 22:26:04 -08:00
|
|
|
app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, fauxMerkleModeOpt)
|
2019-05-18 01:42:24 -07:00
|
|
|
require.Equal(t, "SimApp", app.Name())
|
2018-11-26 04:21:23 -08:00
|
|
|
|
|
|
|
// Run randomized simulation
|
2019-08-28 07:58:25 -07:00
|
|
|
stopEarly, simParams, simErr := simulation.SimulateFromSeed(
|
2019-12-17 10:28:52 -08:00
|
|
|
t, os.Stdout, app.BaseApp, AppStateFn(app.Codec(), app.SimulationManager()),
|
2019-12-05 01:29:54 -08:00
|
|
|
SimulationOperations(app, app.Codec(), config),
|
|
|
|
app.ModuleAccountAddrs(), config,
|
2019-08-15 08:35:25 -07:00
|
|
|
)
|
2019-07-19 09:59:04 -07:00
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
// export state and simParams before the simulation error is checked
|
|
|
|
err = CheckExportSimulation(app, config, simParams)
|
|
|
|
require.NoError(t, err)
|
2019-07-19 09:59:04 -07:00
|
|
|
require.NoError(t, simErr)
|
2019-03-14 11:13:15 -07:00
|
|
|
|
2019-08-15 08:35:25 -07:00
|
|
|
if config.Commit {
|
2019-12-17 10:28:52 -08:00
|
|
|
PrintStats(db)
|
2018-11-26 04:21:23 -08:00
|
|
|
}
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2018-11-26 04:21:23 -08:00
|
|
|
if stopEarly {
|
2019-12-17 10:28:52 -08:00
|
|
|
fmt.Println("can't export or import a zero-validator genesis, exiting test...")
|
2018-11-26 04:21:23 -08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-08-28 07:58:25 -07:00
|
|
|
fmt.Printf("exporting genesis...\n")
|
2018-11-26 04:21:23 -08:00
|
|
|
|
2020-04-16 08:10:39 -07:00
|
|
|
appState, _, _, err := app.ExportAppStateAndValidators(true, []string{})
|
2019-08-15 08:35:25 -07:00
|
|
|
require.NoError(t, err)
|
2018-11-26 04:21:23 -08:00
|
|
|
|
2019-08-28 07:58:25 -07:00
|
|
|
fmt.Printf("importing genesis...\n")
|
2018-11-26 04:21:23 -08:00
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
_, newDB, newDir, _, _, err := SetupSimulation("leveldb-app-sim-2", "Simulation-2")
|
|
|
|
require.NoError(t, err, "simulation setup failed")
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2018-11-26 04:21:23 -08:00
|
|
|
defer func() {
|
|
|
|
newDB.Close()
|
2019-12-17 10:28:52 -08:00
|
|
|
require.NoError(t, os.RemoveAll(newDir))
|
2018-11-26 04:21:23 -08:00
|
|
|
}()
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2020-02-27 22:26:04 -08:00
|
|
|
newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, fauxMerkleModeOpt)
|
2019-05-18 01:42:24 -07:00
|
|
|
require.Equal(t, "SimApp", newApp.Name())
|
2019-09-04 10:33:32 -07:00
|
|
|
|
2018-11-26 04:21:23 -08:00
|
|
|
newApp.InitChain(abci.RequestInitChain{
|
|
|
|
AppStateBytes: appState,
|
|
|
|
})
|
|
|
|
|
2019-08-15 08:35:25 -07:00
|
|
|
_, _, err = simulation.SimulateFromSeed(
|
2019-12-17 10:28:52 -08:00
|
|
|
t, os.Stdout, newApp.BaseApp, AppStateFn(app.Codec(), app.SimulationManager()),
|
2019-12-05 01:29:54 -08:00
|
|
|
SimulationOperations(newApp, newApp.Codec(), config),
|
|
|
|
newApp.ModuleAccountAddrs(), config,
|
2019-08-15 08:35:25 -07:00
|
|
|
)
|
|
|
|
require.NoError(t, err)
|
2018-11-26 04:21:23 -08:00
|
|
|
}
|
|
|
|
|
2018-08-16 14:45:07 -07:00
|
|
|
// TODO: Make another test for the fuzzer itself, which just has noOp txs
|
2019-05-18 01:42:24 -07:00
|
|
|
// and doesn't depend on the application.
|
2018-08-16 08:36:15 -07:00
|
|
|
func TestAppStateDeterminism(t *testing.T) {
|
2019-09-09 11:13:43 -07:00
|
|
|
if !FlagEnabledValue {
|
2019-08-28 07:58:25 -07:00
|
|
|
t.Skip("skipping application simulation")
|
2018-08-16 08:36:15 -07:00
|
|
|
}
|
2018-08-17 07:19:33 -07:00
|
|
|
|
2019-08-15 08:35:25 -07:00
|
|
|
config := NewConfigFromFlags()
|
|
|
|
config.InitialBlockHeight = 1
|
|
|
|
config.ExportParamsPath = ""
|
|
|
|
config.OnOperation = false
|
|
|
|
config.AllInvariants = false
|
2019-10-23 02:14:45 -07:00
|
|
|
config.ChainID = helpers.SimAppChainID
|
2019-08-15 08:35:25 -07:00
|
|
|
|
2018-09-03 19:13:08 -07:00
|
|
|
numSeeds := 3
|
2018-08-17 07:19:33 -07:00
|
|
|
numTimesToRunPerSeed := 5
|
|
|
|
appHashList := make([]json.RawMessage, numTimesToRunPerSeed)
|
|
|
|
|
|
|
|
for i := 0; i < numSeeds; i++ {
|
2019-08-15 08:35:25 -07:00
|
|
|
config.Seed = rand.Int63()
|
2019-08-07 09:54:13 -07:00
|
|
|
|
2018-08-17 07:19:33 -07:00
|
|
|
for j := 0; j < numTimesToRunPerSeed; j++ {
|
2019-10-23 02:14:45 -07:00
|
|
|
var logger log.Logger
|
|
|
|
if FlagVerboseValue {
|
|
|
|
logger = log.TestingLogger()
|
|
|
|
} else {
|
|
|
|
logger = log.NewNopLogger()
|
|
|
|
}
|
|
|
|
|
2018-08-17 07:19:33 -07:00
|
|
|
db := dbm.NewMemDB()
|
2020-02-27 22:26:04 -08:00
|
|
|
app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, interBlockCacheOpt())
|
2018-08-17 07:19:33 -07:00
|
|
|
|
2019-08-07 09:54:13 -07:00
|
|
|
fmt.Printf(
|
2019-08-28 07:58:25 -07:00
|
|
|
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",
|
|
|
|
config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed,
|
2019-08-07 09:54:13 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
_, _, err := simulation.SimulateFromSeed(
|
2019-12-17 10:28:52 -08:00
|
|
|
t, os.Stdout, app.BaseApp, AppStateFn(app.Codec(), app.SimulationManager()),
|
2019-12-05 01:29:54 -08:00
|
|
|
SimulationOperations(app, app.Codec(), config),
|
|
|
|
app.ModuleAccountAddrs(), config,
|
2018-08-17 07:19:33 -07:00
|
|
|
)
|
2019-08-07 09:54:13 -07:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-12-17 10:28:52 -08:00
|
|
|
if config.Commit {
|
|
|
|
PrintStats(db)
|
|
|
|
}
|
|
|
|
|
2018-08-17 07:19:33 -07:00
|
|
|
appHash := app.LastCommitID().Hash
|
|
|
|
appHashList[j] = appHash
|
2019-08-07 09:54:13 -07:00
|
|
|
|
2019-08-15 08:35:25 -07:00
|
|
|
if j != 0 {
|
2019-08-28 07:58:25 -07:00
|
|
|
require.Equal(
|
2020-04-30 08:07:43 -07:00
|
|
|
t, string(appHashList[0]), string(appHashList[j]),
|
2019-08-28 07:58:25 -07:00
|
|
|
"non-determinism in seed %d: %d/%d, attempt: %d/%d\n", config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed,
|
|
|
|
)
|
2019-08-15 08:35:25 -07:00
|
|
|
}
|
2018-08-17 07:19:33 -07:00
|
|
|
}
|
2018-08-16 08:36:15 -07:00
|
|
|
}
|
|
|
|
}
|