diff --git a/tests/integration/common.go b/tests/integration/common.go index 70ead0ab..4e605a3d 100644 --- a/tests/integration/common.go +++ b/tests/integration/common.go @@ -30,6 +30,8 @@ import ( bondkeeper "git.vdb.to/cerc-io/laconic2d/x/bond/keeper" bondmodule "git.vdb.to/cerc-io/laconic2d/x/bond/module" 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 { @@ -42,22 +44,23 @@ type TestFixture struct { AccountKeeper authkeeper.AccountKeeper BankKeeper bankkeeper.Keeper - AuctionKeeper *auctionkeeper.Keeper - BondKeeper *bondkeeper.Keeper - // RegistryKeeper + AuctionKeeper *auctionkeeper.Keeper + BondKeeper *bondkeeper.Keeper + RegistryKeeper registrykeeper.Keeper } func (tf *TestFixture) Setup() error { keys := storetypes.NewKVStoreKeys( - authtypes.StoreKey, banktypes.StoreKey, auctionTypes.StoreKey, bondTypes.StoreKey, + authtypes.StoreKey, banktypes.StoreKey, auctionTypes.StoreKey, bondTypes.StoreKey, registryTypes.StoreKey, ) cdc := moduletestutil.MakeTestEncodingConfig( auth.AppModuleBasic{}, auctionmodule.AppModule{}, bondmodule.AppModule{}, + registrymodule.AppModule{}, ).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) 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) + registryKeeper := registrykeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[registryTypes.StoreKey]), accountKeeper, bankKeeper, bondKeeper, auctionKeeper) + authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil) bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil) auctionModule := auctionmodule.NewAppModule(cdc, auctionKeeper) bondModule := bondmodule.NewAppModule(cdc, bondKeeper) + registryModule := registrymodule.NewAppModule(cdc, registryKeeper) integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ - authtypes.ModuleName: authModule, - banktypes.ModuleName: bankModule, - auctionTypes.ModuleName: auctionModule, - bondTypes.ModuleName: bondModule, + authtypes.ModuleName: authModule, + banktypes.ModuleName: bankModule, + auctionTypes.ModuleName: auctionModule, + bondTypes.ModuleName: bondModule, + registryTypes.ModuleName: registryModule, }) sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context()) @@ -121,6 +128,9 @@ func (tf *TestFixture) Setup() error { bondTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), bondkeeper.NewMsgServerImpl(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 if err := auctionKeeper.Params.Set(sdkCtx, auctionTypes.DefaultParams()); err != nil { return err @@ -128,10 +138,14 @@ func (tf *TestFixture) Setup() error { if err := bondKeeper.Params.Set(sdkCtx, bondTypes.DefaultParams()); err != nil { return err } + if err := registryKeeper.Params.Set(sdkCtx, registryTypes.DefaultParams()); err != nil { + return err + } tf.App = integrationApp 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 } diff --git a/tests/integration/registry/keeper/common_test.go b/tests/integration/registry/keeper/common_test.go new file mode 100644 index 00000000..f6237172 --- /dev/null +++ b/tests/integration/registry/keeper/common_test.go @@ -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)) +} diff --git a/tests/integration/registry/keeper/query_server_test.go b/tests/integration/registry/keeper/query_server_test.go new file mode 100644 index 00000000..ad0d50aa --- /dev/null +++ b/tests/integration/registry/keeper/query_server_test.go @@ -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()) + }) + } +} diff --git a/x/registry/keys.go b/x/registry/keys.go index 58e68269..8c5c39fa 100644 --- a/x/registry/keys.go +++ b/x/registry/keys.go @@ -6,6 +6,9 @@ const ( // ModuleName is the name of the registry module 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 = "record_rent"