From 1f04e7a8089ddabc3808d08ec3aa451969d0d2f0 Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Sun, 23 Apr 2023 19:39:14 +0800 Subject: [PATCH] chore(test): move code to test helpers --- app/app.go | 10 ---------- testutil/helpers/test_helpers.go | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/app.go b/app/app.go index 40c7a0262..7b962b98a 100644 --- a/app/app.go +++ b/app/app.go @@ -346,16 +346,6 @@ func (app *App) RegisterNodeService(clientCtx client.Context) { // TestingApp functions -// GetBaseApp implements the TestingApp interface. -func (app *App) GetBaseApp() *baseapp.BaseApp { - return app.BaseApp -} - -// GetTxConfig implements the TestingApp interface. -func (app *App) GetTxConfig() client.TxConfig { - return MakeEncodingConfig().TxConfig -} - // GetModules implements the TestingApp interface. func (app *App) GetModules() map[string]module.AppModule { return app.mm.Modules diff --git a/testutil/helpers/test_helpers.go b/testutil/helpers/test_helpers.go index 455600c0d..76680966f 100644 --- a/testutil/helpers/test_helpers.go +++ b/testutil/helpers/test_helpers.go @@ -434,6 +434,17 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, gasPrice sdk.Coin, gas uint64, c type TestingApp struct { *app.App + TxConfig client.TxConfig +} + +// GetBaseApp implements the TestingApp interface. +func (app *TestingApp) GetBaseApp() *baseapp.BaseApp { + return app.BaseApp +} + +// GetTxConfig implements the TestingApp interface. +func (app *TestingApp) GetTxConfig() client.TxConfig { + return app.TxConfig } func (app *TestingApp) GetStakingKeeper() ibctestingtypes.StakingKeeper { @@ -451,9 +462,9 @@ func (app *TestingApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { // SetupTestingApp initializes the IBC-go testing application func SetupTestingApp() (ibctesting.TestingApp, map[string]json.RawMessage) { cfg := app.MakeEncodingConfig() - resultApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), + myApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, map[int64]bool{}, os.TempDir(), 5, cfg, simapp.EmptyAppOptions{}) - testingApp := &TestingApp{resultApp} + testingApp := &TestingApp{App: myApp, TxConfig: cfg.TxConfig} return testingApp, app.NewDefAppGenesisByDenom(fxtypes.DefaultDenom, cfg.Codec) }