Setup keeper integration tests for registry module
This commit is contained in:
parent
6d764319ce
commit
5e47fae17e
@ -30,6 +30,8 @@ import (
|
|||||||
bondkeeper "git.vdb.to/cerc-io/laconic2d/x/bond/keeper"
|
bondkeeper "git.vdb.to/cerc-io/laconic2d/x/bond/keeper"
|
||||||
bondmodule "git.vdb.to/cerc-io/laconic2d/x/bond/module"
|
bondmodule "git.vdb.to/cerc-io/laconic2d/x/bond/module"
|
||||||
registryTypes "git.vdb.to/cerc-io/laconic2d/x/registry"
|
registryTypes "git.vdb.to/cerc-io/laconic2d/x/registry"
|
||||||
|
registrykeeper "git.vdb.to/cerc-io/laconic2d/x/registry/keeper"
|
||||||
|
registrymodule "git.vdb.to/cerc-io/laconic2d/x/registry/module"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TestFixture struct {
|
type TestFixture struct {
|
||||||
@ -44,20 +46,21 @@ type TestFixture struct {
|
|||||||
|
|
||||||
AuctionKeeper *auctionkeeper.Keeper
|
AuctionKeeper *auctionkeeper.Keeper
|
||||||
BondKeeper *bondkeeper.Keeper
|
BondKeeper *bondkeeper.Keeper
|
||||||
// RegistryKeeper
|
RegistryKeeper registrykeeper.Keeper
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tf *TestFixture) Setup() error {
|
func (tf *TestFixture) Setup() error {
|
||||||
keys := storetypes.NewKVStoreKeys(
|
keys := storetypes.NewKVStoreKeys(
|
||||||
authtypes.StoreKey, banktypes.StoreKey, auctionTypes.StoreKey, bondTypes.StoreKey,
|
authtypes.StoreKey, banktypes.StoreKey, auctionTypes.StoreKey, bondTypes.StoreKey, registryTypes.StoreKey,
|
||||||
)
|
)
|
||||||
cdc := moduletestutil.MakeTestEncodingConfig(
|
cdc := moduletestutil.MakeTestEncodingConfig(
|
||||||
auth.AppModuleBasic{},
|
auth.AppModuleBasic{},
|
||||||
auctionmodule.AppModule{},
|
auctionmodule.AppModule{},
|
||||||
bondmodule.AppModule{},
|
bondmodule.AppModule{},
|
||||||
|
registrymodule.AppModule{},
|
||||||
).Codec
|
).Codec
|
||||||
|
|
||||||
logger := log.NewNopLogger() // Use log.NewTestLogger(tf.T()) for help with debugging
|
logger := log.NewNopLogger() // Use log.NewTestLogger(kts.T()) for help with debugging
|
||||||
cms := integration.CreateMultiStore(keys, logger)
|
cms := integration.CreateMultiStore(keys, logger)
|
||||||
|
|
||||||
newCtx := sdk.NewContext(cms, cmtprototypes.Header{}, true, logger)
|
newCtx := sdk.NewContext(cms, cmtprototypes.Header{}, true, logger)
|
||||||
@ -100,16 +103,20 @@ func (tf *TestFixture) Setup() error {
|
|||||||
|
|
||||||
bondKeeper := bondkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[bondTypes.StoreKey]), accountKeeper, bankKeeper)
|
bondKeeper := bondkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[bondTypes.StoreKey]), accountKeeper, bankKeeper)
|
||||||
|
|
||||||
|
registryKeeper := registrykeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[registryTypes.StoreKey]), accountKeeper, bankKeeper, bondKeeper, auctionKeeper)
|
||||||
|
|
||||||
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil)
|
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil)
|
||||||
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil)
|
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil)
|
||||||
auctionModule := auctionmodule.NewAppModule(cdc, auctionKeeper)
|
auctionModule := auctionmodule.NewAppModule(cdc, auctionKeeper)
|
||||||
bondModule := bondmodule.NewAppModule(cdc, bondKeeper)
|
bondModule := bondmodule.NewAppModule(cdc, bondKeeper)
|
||||||
|
registryModule := registrymodule.NewAppModule(cdc, registryKeeper)
|
||||||
|
|
||||||
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
|
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
|
||||||
authtypes.ModuleName: authModule,
|
authtypes.ModuleName: authModule,
|
||||||
banktypes.ModuleName: bankModule,
|
banktypes.ModuleName: bankModule,
|
||||||
auctionTypes.ModuleName: auctionModule,
|
auctionTypes.ModuleName: auctionModule,
|
||||||
bondTypes.ModuleName: bondModule,
|
bondTypes.ModuleName: bondModule,
|
||||||
|
registryTypes.ModuleName: registryModule,
|
||||||
})
|
})
|
||||||
|
|
||||||
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())
|
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())
|
||||||
@ -121,6 +128,9 @@ func (tf *TestFixture) Setup() error {
|
|||||||
bondTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), bondkeeper.NewMsgServerImpl(bondKeeper))
|
bondTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), bondkeeper.NewMsgServerImpl(bondKeeper))
|
||||||
bondTypes.RegisterQueryServer(integrationApp.QueryHelper(), bondkeeper.NewQueryServerImpl(bondKeeper))
|
bondTypes.RegisterQueryServer(integrationApp.QueryHelper(), bondkeeper.NewQueryServerImpl(bondKeeper))
|
||||||
|
|
||||||
|
registryTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), registrykeeper.NewMsgServerImpl(registryKeeper))
|
||||||
|
registryTypes.RegisterQueryServer(integrationApp.QueryHelper(), registrykeeper.NewQueryServerImpl(registryKeeper))
|
||||||
|
|
||||||
// set default params
|
// set default params
|
||||||
if err := auctionKeeper.Params.Set(sdkCtx, auctionTypes.DefaultParams()); err != nil {
|
if err := auctionKeeper.Params.Set(sdkCtx, auctionTypes.DefaultParams()); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -128,10 +138,14 @@ func (tf *TestFixture) Setup() error {
|
|||||||
if err := bondKeeper.Params.Set(sdkCtx, bondTypes.DefaultParams()); err != nil {
|
if err := bondKeeper.Params.Set(sdkCtx, bondTypes.DefaultParams()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := registryKeeper.Params.Set(sdkCtx, registryTypes.DefaultParams()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
tf.App = integrationApp
|
tf.App = integrationApp
|
||||||
tf.SdkCtx, tf.cdc, tf.keys = sdkCtx, cdc, keys
|
tf.SdkCtx, tf.cdc, tf.keys = sdkCtx, cdc, keys
|
||||||
tf.AccountKeeper, tf.BankKeeper, tf.AuctionKeeper, tf.BondKeeper = accountKeeper, bankKeeper, auctionKeeper, bondKeeper
|
tf.AccountKeeper, tf.BankKeeper = accountKeeper, bankKeeper
|
||||||
|
tf.AuctionKeeper, tf.BondKeeper, tf.RegistryKeeper = auctionKeeper, bondKeeper, registryKeeper
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
33
tests/integration/registry/keeper/common_test.go
Normal file
33
tests/integration/registry/keeper/common_test.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package keeper_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
integrationTest "git.vdb.to/cerc-io/laconic2d/tests/integration"
|
||||||
|
types "git.vdb.to/cerc-io/laconic2d/x/registry"
|
||||||
|
)
|
||||||
|
|
||||||
|
type KeeperTestSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
integrationTest.TestFixture
|
||||||
|
|
||||||
|
queryClient types.QueryClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (kts *KeeperTestSuite) SetupTest() {
|
||||||
|
kts.TestFixture.Setup()
|
||||||
|
|
||||||
|
// set default params
|
||||||
|
err := kts.RegistryKeeper.Params.Set(kts.SdkCtx, types.DefaultParams())
|
||||||
|
assert.Nil(kts.T(), err)
|
||||||
|
|
||||||
|
qr := kts.App.QueryHelper()
|
||||||
|
kts.queryClient = types.NewQueryClient(qr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRegistryKeeperTestSuite(t *testing.T) {
|
||||||
|
suite.Run(t, new(KeeperTestSuite))
|
||||||
|
}
|
27
tests/integration/registry/keeper/query_server_test.go
Normal file
27
tests/integration/registry/keeper/query_server_test.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package keeper_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
registrytypes "git.vdb.to/cerc-io/laconic2d/x/registry"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (kts *KeeperTestSuite) TestGrpcQueryParams() {
|
||||||
|
testCases := []struct {
|
||||||
|
msg string
|
||||||
|
req *registrytypes.QueryParamsRequest
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"Get Params",
|
||||||
|
®istrytypes.QueryParamsRequest{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range testCases {
|
||||||
|
kts.Run(fmt.Sprintf("Case %s ", test.msg), func() {
|
||||||
|
resp, _ := kts.queryClient.Params(context.Background(), test.req)
|
||||||
|
defaultParams := registrytypes.DefaultParams()
|
||||||
|
kts.Require().Equal(defaultParams.String(), resp.GetParams().String())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,9 @@ const (
|
|||||||
// ModuleName is the name of the registry module
|
// ModuleName is the name of the registry module
|
||||||
ModuleName = "registry"
|
ModuleName = "registry"
|
||||||
|
|
||||||
|
// StoreKey defines the primary module store key
|
||||||
|
StoreKey = ModuleName
|
||||||
|
|
||||||
// RecordRentModuleAccountName is the name of the module account that keeps track of record rents paid.
|
// RecordRentModuleAccountName is the name of the module account that keeps track of record rents paid.
|
||||||
RecordRentModuleAccountName = "record_rent"
|
RecordRentModuleAccountName = "record_rent"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user