diff --git a/Makefile b/Makefile index 02fb21715..b3b5851d6 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,11 @@ test_race: test_sim: @echo "Running individual module simulations." @go test $(PACKAGES_SIMTEST) -v - @echo "Running full Gaia simulation. This may take several minutes. Set the environment variable 'GAIA_SIMULATION_SEED' to run with a constant seed." + @echo "Running full Gaia simulation. This may take several minutes." + @echo "Set the environment variable 'GAIA_SIMULATION_SEED' to run with a constant seed." + @echo "Set the environment variable 'GAIA_SIMULATION_KEYS' to run with the specified number of keys." + @echo "Set the environment variable 'GAIA_SIMULATION_BLOCKS' to run with the specified number of blocks." + @echo "Set the environment variable 'GAIA_SIMULATION_BLOCK_SIZE' to run with the specified block size (operations per block)." @GAIA_SIMULATION_ENABLED=1 go test ./cmd/gaia/app -run TestFullGaiaSimulation -v test_cover: diff --git a/cmd/gaia/app/sim_test.go b/cmd/gaia/app/sim_test.go index 745824f00..89b1b54aa 100644 --- a/cmd/gaia/app/sim_test.go +++ b/cmd/gaia/app/sim_test.go @@ -21,9 +21,9 @@ import ( ) const ( - NumKeys = 10 - NumBlocks = 100 - BlockSize = 100 + defaultNumKeys = 10 + defaultNumBlocks = 100 + defaultBlockSize = 100 simulationEnvEnable = "GAIA_SIMULATION_ENABLED" simulationEnvSeed = "GAIA_SIMULATION_SEED" @@ -82,6 +82,27 @@ func TestFullGaiaSimulation(t *testing.T) { seed = time.Now().UnixNano() } + keys := defaultNumKeys + envKeys := os.Getenv(simulationEnvKeys) + if envKeys != "" { + keys, err = strconv.Atoi(envKeys) + require.Nil(t, err) + } + + blocks := defaultNumBlocks + envBlocks := os.Getenv(simulationEnvBlocks) + if envBlocks != "" { + blocks, err = strconv.Atoi(envBlocks) + require.Nil(t, err) + } + + blockSize := defaultBlockSize + envBlockSize := os.Getenv(simulationEnvBlockSize) + if envBlockSize != "" { + blockSize, err = strconv.Atoi(envBlockSize) + require.Nil(t, err) + } + // Run randomized simulation simulation.SimulateFromSeed( t, app.BaseApp, appStateFn, seed, @@ -100,9 +121,9 @@ func TestFullGaiaSimulation(t *testing.T) { banksim.NonnegativeBalanceInvariant(app.accountMapper), stakesim.AllInvariants(app.coinKeeper, app.stakeKeeper, app.accountMapper), }, - NumKeys, - NumBlocks, - BlockSize, + keys, + blocks, + blockSize, ) }