feat: add x/nft app wiring integration tests (#12220)

* feat: add x/nft app wiring integration tests

* updates

* feedback
This commit is contained in:
Julien Robert 2022-06-10 16:13:32 +02:00 committed by GitHub
parent 7688ce6e44
commit 8111a05594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 99 additions and 2 deletions

View File

@ -114,4 +114,4 @@ modules:
- name: genutil
config:
"@type": cosmos.genutil.module.v1.Module
"@type": cosmos.genutil.module.v1.Module

View File

@ -33,7 +33,9 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/depinject"
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/api"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
@ -128,6 +130,39 @@ func DefaultConfig() Config {
}
}
func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) {
cfg := DefaultConfig()
var appBuilder *runtime.AppBuilder
var msgServiceRouter *baseapp.MsgServiceRouter
if err := depinject.Inject(appConfig,
&appBuilder,
&msgServiceRouter,
); err != nil {
return Config{}, err
}
cfg.GenesisState = appBuilder.DefaultGenesis()
cfg.AppConstructor = func(val Validator) servertypes.Application {
app := appBuilder.Build(
val.Ctx.Logger,
dbm.NewMemDB(),
nil,
msgServiceRouter,
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)),
baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices),
)
if err := app.Load(true); err != nil {
panic(err)
}
return app
}
return cfg, nil
}
type (
// Network defines a local in-process testing network using SimApp. It can be
// configured to start any number of validators, each with its own RPC and API

View File

@ -1,15 +1,19 @@
package testutil
import (
_ "embed"
"testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/x/nft/testutil"
)
func TestIntegrationTestSuite(t *testing.T) {
cfg := network.DefaultConfig()
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg.NumValidators = 1
suite.Run(t, NewIntegrationTestSuite(cfg))
}

46
x/nft/testutil/app.yaml Normal file
View File

@ -0,0 +1,46 @@
modules:
- name: runtime
config:
"@type": cosmos.app.runtime.v1alpha1.Module
app_name: NftApp
begin_blockers: [staking, auth, bank, genutil, nft, params]
end_blockers: [staking, auth, bank, genutil, nft, params]
init_genesis: [auth, bank, staking, genutil, nft, params]
- name: auth
config:
"@type": cosmos.auth.module.v1.Module
bech32_prefix: cosmos
module_account_permissions:
- account: fee_collector
- account: bonded_tokens_pool
permissions: [burner, staking]
- account: not_bonded_tokens_pool
permissions: [burner, staking]
- account: nft
- name: bank
config:
"@type": cosmos.bank.module.v1.Module
- name: params
config:
"@type": cosmos.params.module.v1.Module
- name: tx
config:
"@type": cosmos.tx.module.v1.Module
- name: nft
config:
"@type": cosmos.nft.module.v1.Module
- name: staking
config:
"@type": cosmos.staking.module.v1.Module
- name: genutil
config:
"@type": cosmos.genutil.module.v1.Module

View File

@ -0,0 +1,12 @@
package testutil
import (
_ "embed"
"cosmossdk.io/core/appconfig"
)
//go:embed app.yaml
var appConfig []byte
var AppConfig = appconfig.LoadYAML(appConfig)