From eda7eb48cd0a68afa7adb605eec8d1ac23815be8 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Tue, 17 Jul 2018 23:06:30 +0200 Subject: [PATCH] Gaia simulation needs internal field access --- Makefile | 6 +++--- cmd/gaia/{simulation => app}/sim_test.go | 17 +++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) rename cmd/gaia/{simulation => app}/sim_test.go (74%) diff --git a/Makefile b/Makefile index 6f5b55e55..5d2cb8493 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PACKAGES=$(shell go list ./... | grep -v '/vendor/') -PACKAGES_NOCLITEST=$(shell go list ./... | grep -v '/vendor/' | grep -v '/simulation' | grep -v github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test) -PACKAGES_SIMTEST=$(shell go list ./... | grep -v '/vendor/' | grep '/simulation') +PACKAGES_NOCLITEST=$(shell go list ./... | grep -v '/vendor/' | grep -v github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test) +PACKAGES_SIMTEST=$(shell go list ./... | grep -v '/vendor/') COMMIT_HASH := $(shell git rev-parse --short HEAD) BUILD_TAGS = netgo ledger BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=${COMMIT_HASH}" @@ -114,7 +114,7 @@ test_race: @go test -race $(PACKAGES_NOCLITEST) test_sim: - @go test $(PACKAGES_SIMTEST) -v + @ENABLE_GAIA_SIMULATION=1 go test ./cmd/gaia/app -run TestFullGaiaSimulation -v test_cover: @bash tests/test_cover.sh diff --git a/cmd/gaia/simulation/sim_test.go b/cmd/gaia/app/sim_test.go similarity index 74% rename from cmd/gaia/simulation/sim_test.go rename to cmd/gaia/app/sim_test.go index 2d36e0fa2..a42a34bc6 100644 --- a/cmd/gaia/simulation/sim_test.go +++ b/cmd/gaia/app/sim_test.go @@ -1,6 +1,7 @@ -package simulation +package app import ( + "os" "testing" "github.com/stretchr/testify/require" @@ -8,7 +9,6 @@ import ( dbm "github.com/tendermint/tendermint/libs/db" "github.com/tendermint/tendermint/libs/log" - gaia "github.com/cosmos/cosmos-sdk/cmd/gaia/app" "github.com/cosmos/cosmos-sdk/x/mock/simulation" stake "github.com/cosmos/cosmos-sdk/x/stake" ) @@ -17,24 +17,29 @@ const ( NumKeys = 10 NumBlocks = 1000 BlockSize = 1000 + + simulationEnv = "ENABLE_GAIA_SIMULATION" ) func TestFullGaiaSimulation(t *testing.T) { + if os.Getenv(simulationEnv) == "" { + t.Skip("Skipping Gaia simulation") + } // Setup Gaia application logger := log.NewNopLogger() db := dbm.NewMemDB() - app := gaia.NewGaiaApp(logger, db, nil) + app := NewGaiaApp(logger, db, nil) require.Equal(t, "GaiaApp", app.Name()) // Default genesis state - genesis := gaia.GenesisState{ - Accounts: []gaia.GenesisAccount{}, + genesis := GenesisState{ + Accounts: []GenesisAccount{}, StakeData: stake.DefaultGenesisState(), } // Marshal genesis - appState, err := gaia.MakeCodec().MarshalJSON(genesis) + appState, err := MakeCodec().MarshalJSON(genesis) if err != nil { panic(err) }