Skip to content

Commit

Permalink
Fix encoding config creation
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski committed Jul 18, 2022
1 parent 4c3cd14 commit 7390871
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
13 changes: 9 additions & 4 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,9 @@ func ModuleAccountAddrs() map[string]bool {
}

// NewTestAppConstructor returns a new simapp AppConstructor for network simulation tests
func NewTestAppConstructor(encodingCfg testutil.TestEncodingConfig) network.TestFixture {
cfg := simappparams.EncodingConfig{
func NewTestAppConstructor() network.TestFixture {
encodingCfg := MakeTestEncodingConfig()
cfg := testutil.TestEncodingConfig{
TxConfig: encodingCfg.TxConfig,
Codec: encodingCfg.Codec,
Amino: encodingCfg.Amino,
Expand All @@ -368,12 +369,16 @@ func NewTestAppConstructor(encodingCfg testutil.TestEncodingConfig) network.Test
appCtr := func(val testutil.Validator) servertypes.Application {
return NewSimApp(
val.GetCtx().Logger, dbm.NewMemDB(), nil, true,
cfg,
encodingCfg,
simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir),
bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
)
}

return network.TestFixture{AppConstructor: appCtr, GenesisState: ModuleBasics.DefaultGenesis(cfg.Codec)}
return network.TestFixture{
AppConstructor: appCtr,
GenesisState: ModuleBasics.DefaultGenesis(cfg.Codec),
EncodingConfig: cfg,
}
}
16 changes: 8 additions & 8 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ var lock = new(sync.Mutex)
// AppConstructor defines a function which accepts a network configuration and
// creates an ABCI Application to provide to Tendermint.
type AppConstructor = func(val moduletestutil.Validator) servertypes.Application
type TestFixtureFactory = func(cfg moduletestutil.TestEncodingConfig) TestFixture
type TestFixtureFactory = func() TestFixture

type TestFixture struct {
AppConstructor AppConstructor
GenesisState map[string]json.RawMessage
EncodingConfig moduletestutil.TestEncodingConfig
}

// Config defines the necessary configuration used to bootstrap and start an
Expand Down Expand Up @@ -97,14 +98,13 @@ type Config struct {
// DefaultConfig returns a sane default configuration suitable for nearly all
// testing requirements.
func DefaultConfig(factory TestFixtureFactory) Config {
encCfg := moduletestutil.MakeTestEncodingConfig()
fixture := factory(encCfg)
fixture := factory()

return Config{
Codec: encCfg.Codec,
TxConfig: encCfg.TxConfig,
LegacyAmino: encCfg.Amino,
InterfaceRegistry: encCfg.InterfaceRegistry,
Codec: fixture.EncodingConfig.Codec,
TxConfig: fixture.EncodingConfig.TxConfig,
LegacyAmino: fixture.EncodingConfig.Amino,
InterfaceRegistry: fixture.EncodingConfig.InterfaceRegistry,
AccountRetriever: authtypes.AccountRetriever{},
AppConstructor: fixture.AppConstructor,
GenesisState: fixture.GenesisState,
Expand Down Expand Up @@ -143,7 +143,7 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) {
return Config{}, err
}

cfg := DefaultConfig(func(cfg moduletestutil.TestEncodingConfig) TestFixture {
cfg := DefaultConfig(func() TestFixture {
return TestFixture{}
})
cfg.Codec = cdc
Expand Down

0 comments on commit 7390871

Please sign in to comment.