test: Update networksuite with testapp builder (#304)

This commit is contained in:
Eric Warehime 2023-12-14 09:53:25 -08:00 committed by GitHub
parent af3bb52d57
commit 4b6e481c3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,14 @@ package networksuite
import (
"math/rand"
"os"
"cosmossdk.io/log"
pruningtypes "cosmossdk.io/store/pruning/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"cosmossdk.io/math"
"github.com/cosmos/gogoproto/proto"
@ -31,9 +39,22 @@ type NetworkTestSuite struct {
// SetupSuite setups the local network with a genesis state.
func (nts *NetworkTestSuite) SetupSuite() {
var (
r = sample.Rand()
cfg = network.NewConfig(app.AppConfig)
r = sample.Rand()
cfg = network.NewConfig(app.AppConfig)
appCons = func(val network.ValidatorI) servertypes.Application {
return app.New(
log.NewLogger(os.Stdout),
dbm.NewMemDB(),
nil,
true,
simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir),
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
baseapp.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
baseapp.SetChainID(cfg.ChainID),
)
}
)
cfg.AppConstructor = appCons
updateGenesisConfigState := func(moduleName string, moduleState proto.Message) {
buf, err := cfg.Codec.MarshalJSON(moduleState)