2018-07-17 14:06:30 -07:00
|
|
|
package app
|
2018-07-11 15:14:37 -07:00
|
|
|
|
|
|
|
import (
|
2018-07-17 14:06:30 -07:00
|
|
|
"os"
|
2018-07-11 15:14:37 -07:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2018-07-12 13:01:43 -07:00
|
|
|
|
|
|
|
dbm "github.com/tendermint/tendermint/libs/db"
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
|
|
|
2018-07-16 18:25:15 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/mock/simulation"
|
2018-07-17 11:33:53 -07:00
|
|
|
stake "github.com/cosmos/cosmos-sdk/x/stake"
|
2018-07-16 18:15:50 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
NumKeys = 10
|
|
|
|
NumBlocks = 1000
|
|
|
|
BlockSize = 1000
|
2018-07-17 14:06:30 -07:00
|
|
|
|
|
|
|
simulationEnv = "ENABLE_GAIA_SIMULATION"
|
2018-07-11 15:14:37 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestFullGaiaSimulation(t *testing.T) {
|
2018-07-17 14:06:30 -07:00
|
|
|
if os.Getenv(simulationEnv) == "" {
|
|
|
|
t.Skip("Skipping Gaia simulation")
|
|
|
|
}
|
2018-07-17 11:33:53 -07:00
|
|
|
|
2018-07-12 13:01:43 -07:00
|
|
|
// Setup Gaia application
|
|
|
|
logger := log.NewNopLogger()
|
|
|
|
db := dbm.NewMemDB()
|
2018-07-17 14:06:30 -07:00
|
|
|
app := NewGaiaApp(logger, db, nil)
|
2018-07-12 13:01:43 -07:00
|
|
|
require.Equal(t, "GaiaApp", app.Name())
|
2018-07-16 18:15:50 -07:00
|
|
|
|
2018-07-17 11:33:53 -07:00
|
|
|
// Default genesis state
|
2018-07-17 14:06:30 -07:00
|
|
|
genesis := GenesisState{
|
|
|
|
Accounts: []GenesisAccount{},
|
2018-07-17 11:33:53 -07:00
|
|
|
StakeData: stake.DefaultGenesisState(),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Marshal genesis
|
2018-07-17 14:06:30 -07:00
|
|
|
appState, err := MakeCodec().MarshalJSON(genesis)
|
2018-07-17 11:33:53 -07:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2018-07-16 18:15:50 -07:00
|
|
|
// Run randomized simulation
|
2018-07-17 11:33:53 -07:00
|
|
|
simulation.Simulate(
|
|
|
|
t, app.BaseApp, appState,
|
2018-07-16 18:25:15 -07:00
|
|
|
[]simulation.TestAndRunTx{},
|
|
|
|
[]simulation.RandSetup{},
|
|
|
|
[]simulation.Invariant{},
|
2018-07-16 18:15:50 -07:00
|
|
|
NumKeys,
|
|
|
|
NumBlocks,
|
|
|
|
BlockSize,
|
|
|
|
)
|
|
|
|
|
2018-07-11 15:14:37 -07:00
|
|
|
}
|