feat: add x/nft app wiring integration tests (#12220)
* feat: add x/nft app wiring integration tests * updates * feedback
This commit is contained in:
parent
7688ce6e44
commit
8111a05594
@ -114,4 +114,4 @@ modules:
|
||||
|
||||
- name: genutil
|
||||
config:
|
||||
"@type": cosmos.genutil.module.v1.Module
|
||||
"@type": cosmos.genutil.module.v1.Module
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
46
x/nft/testutil/app.yaml
Normal 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
|
||||
12
x/nft/testutil/app_config.go
Normal file
12
x/nft/testutil/app_config.go
Normal 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)
|
||||
Loading…
Reference in New Issue
Block a user