Setup integration tests and CI #11

Merged
ashwin merged 11 commits from pm-add-tests into main 2024-02-29 11:54:36 +00:00
6 changed files with 281 additions and 143 deletions
Showing only changes of commit fad9ab8aa7 - Show all commits

View File

@ -3,120 +3,28 @@ package keeper_test
import ( import (
"testing" "testing"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
cmtprototypes "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/codec" integrationTest "git.vdb.to/cerc-io/laconic2d/tests/integration"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address" types "git.vdb.to/cerc-io/laconic2d/x/auction"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
auctionTypes "git.vdb.to/cerc-io/laconic2d/x/auction"
auctionkeeper "git.vdb.to/cerc-io/laconic2d/x/auction/keeper"
auctionmodule "git.vdb.to/cerc-io/laconic2d/x/auction/module"
bondTypes "git.vdb.to/cerc-io/laconic2d/x/bond"
registryTypes "git.vdb.to/cerc-io/laconic2d/x/registry"
) )
type KeeperTestSuite struct { type KeeperTestSuite struct {
suite.Suite suite.Suite
integrationTest.TestFixture
app *integration.App queryClient types.QueryClient
sdkCtx sdk.Context
cdc codec.Codec
keys map[string]*storetypes.KVStoreKey
accountKeeper authkeeper.AccountKeeper
bankKeeper bankkeeper.Keeper
auctionKeeper *auctionkeeper.Keeper
} }
func (kts *KeeperTestSuite) SetupTest() { func (kts *KeeperTestSuite) SetupTest() {
keys := storetypes.NewKVStoreKeys( err := kts.TestFixture.Setup()
authtypes.StoreKey, banktypes.StoreKey, auctionTypes.StoreKey, assert.Nil(kts.T(), err)
)
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}, auctionmodule.AppModule{}).Codec
logger := log.NewNopLogger() // Use log.NewTestLogger(kts.T()) for help with debugging qr := kts.App.QueryHelper()
cms := integration.CreateMultiStore(keys, logger) kts.queryClient = types.NewQueryClient(qr)
newCtx := sdk.NewContext(cms, cmtprototypes.Header{}, true, logger)
authority := authtypes.NewModuleAddress("gov")
maccPerms := map[string][]string{
minttypes.ModuleName: {authtypes.Minter},
auctionTypes.ModuleName: {},
auctionTypes.AuctionBurnModuleAccountName: {},
bondTypes.ModuleName: {},
registryTypes.ModuleName: {},
registryTypes.RecordRentModuleAccountName: {},
registryTypes.AuthorityRentModuleAccountName: {},
}
accountKeeper := authkeeper.NewAccountKeeper(
cdc,
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
authtypes.ProtoBaseAccount,
maccPerms,
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
sdk.Bech32MainPrefix,
authority.String(),
)
blockedAddresses := map[string]bool{
accountKeeper.GetAuthority(): false,
}
bankKeeper := bankkeeper.NewBaseKeeper(
cdc,
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
accountKeeper,
blockedAddresses,
authority.String(),
log.NewNopLogger(),
)
auctionKeeper := auctionkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[auctionTypes.StoreKey]), accountKeeper, bankKeeper)
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil)
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil)
auctionModule := auctionmodule.NewAppModule(cdc, auctionKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
auctionTypes.ModuleName: auctionModule,
})
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())
// Register MsgServer and QueryServer
auctionTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), auctionkeeper.NewMsgServerImpl(auctionKeeper))
auctionTypes.RegisterQueryServer(integrationApp.QueryHelper(), auctionkeeper.NewQueryServerImpl(auctionKeeper))
// set default staking params
assert.Nil(kts.T(), auctionKeeper.Params.Set(sdkCtx, auctionTypes.DefaultParams()))
kts.app = integrationApp
kts.sdkCtx, kts.cdc, kts.keys = sdkCtx, cdc, keys
kts.accountKeeper, kts.bankKeeper, kts.auctionKeeper = accountKeeper, bankKeeper, auctionKeeper
} }
func TestKeeperTestSuite(t *testing.T) { func TestAuctionKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite)) suite.Run(t, new(KeeperTestSuite))
} }

View File

@ -6,17 +6,14 @@ import (
"cosmossdk.io/math" "cosmossdk.io/math"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
integrationTest "git.vdb.to/cerc-io/laconic2d/tests/integration"
types "git.vdb.to/cerc-io/laconic2d/x/auction" types "git.vdb.to/cerc-io/laconic2d/x/auction"
) )
const testCommitHash = "71D8CF34026E32A3A34C2C2D4ADF25ABC8D7943A4619761BE27F196603D91B9D" const testCommitHash = "71D8CF34026E32A3A34C2C2D4ADF25ABC8D7943A4619761BE27F196603D91B9D"
func (kts *KeeperTestSuite) TestGrpcQueryParams() { func (kts *KeeperTestSuite) TestGrpcQueryParams() {
qr := kts.app.QueryHelper()
queryClient := types.NewQueryClient(qr)
testCases := []struct { testCases := []struct {
msg string msg string
req *types.QueryParamsRequest req *types.QueryParamsRequest
@ -28,7 +25,7 @@ func (kts *KeeperTestSuite) TestGrpcQueryParams() {
} }
for _, test := range testCases { for _, test := range testCases {
kts.Run(fmt.Sprintf("Case %s", test.msg), func() { kts.Run(fmt.Sprintf("Case %s", test.msg), func() {
resp, err := queryClient.Params(context.Background(), test.req) resp, err := kts.queryClient.Params(context.Background(), test.req)
kts.Require().Nil(err) kts.Require().Nil(err)
kts.Require().Equal(*(resp.Params), types.DefaultParams()) kts.Require().Equal(*(resp.Params), types.DefaultParams())
}) })
@ -36,9 +33,6 @@ func (kts *KeeperTestSuite) TestGrpcQueryParams() {
} }
func (kts *KeeperTestSuite) TestGrpcGetAuction() { func (kts *KeeperTestSuite) TestGrpcGetAuction() {
qr := kts.app.QueryHelper()
queryClient := types.NewQueryClient(qr)
testCases := []struct { testCases := []struct {
msg string msg string
req *types.QueryAuctionRequest req *types.QueryAuctionRequest
@ -66,11 +60,11 @@ func (kts *KeeperTestSuite) TestGrpcGetAuction() {
expectedAuction = *auction expectedAuction = *auction
} }
resp, err := queryClient.GetAuction(context.Background(), test.req) resp, err := kts.queryClient.GetAuction(context.Background(), test.req)
if test.createAuction { if test.createAuction {
kts.Require().Nil(err) kts.Require().Nil(err)
kts.Require().NotNil(resp.GetAuction()) kts.Require().NotNil(resp.GetAuction())
kts.Require().EqualExportedValues(expectedAuction, *resp.GetAuction()) kts.Require().EqualExportedValues(expectedAuction, *(resp.GetAuction()))
} else { } else {
kts.Require().NotNil(err) kts.Require().NotNil(err)
kts.Require().Error(err) kts.Require().Error(err)
@ -80,9 +74,6 @@ func (kts *KeeperTestSuite) TestGrpcGetAuction() {
} }
func (kts *KeeperTestSuite) TestGrpcGetAllAuctions() { func (kts *KeeperTestSuite) TestGrpcGetAllAuctions() {
qr := kts.app.QueryHelper()
queryClient := types.NewQueryClient(qr)
testCases := []struct { testCases := []struct {
msg string msg string
req *types.QueryAuctionsRequest req *types.QueryAuctionsRequest
@ -111,16 +102,13 @@ func (kts *KeeperTestSuite) TestGrpcGetAllAuctions() {
kts.Require().Nil(err) kts.Require().Nil(err)
} }
resp, _ := queryClient.Auctions(context.Background(), test.req) resp, _ := kts.queryClient.Auctions(context.Background(), test.req)
kts.Require().Equal(test.auctionCount, len(resp.GetAuctions().Auctions)) kts.Require().Equal(test.auctionCount, len(resp.GetAuctions().Auctions))
}) })
} }
} }
func (kts *KeeperTestSuite) TestGrpcGetBids() { func (kts *KeeperTestSuite) TestGrpcGetBids() {
qr := kts.app.QueryHelper()
queryClient := types.NewQueryClient(qr)
testCases := []struct { testCases := []struct {
msg string msg string
req *types.QueryBidsRequest req *types.QueryBidsRequest
@ -159,7 +147,7 @@ func (kts *KeeperTestSuite) TestGrpcGetBids() {
test.req.AuctionId = auction.Id test.req.AuctionId = auction.Id
} }
resp, err := queryClient.GetBids(context.Background(), test.req) resp, err := kts.queryClient.GetBids(context.Background(), test.req)
if test.createAuction { if test.createAuction {
kts.Require().Nil(err) kts.Require().Nil(err)
kts.Require().Equal(test.bidCount, len(resp.GetBids())) kts.Require().Equal(test.bidCount, len(resp.GetBids()))
@ -172,9 +160,6 @@ func (kts *KeeperTestSuite) TestGrpcGetBids() {
} }
func (kts *KeeperTestSuite) TestGrpcGetBid() { func (kts *KeeperTestSuite) TestGrpcGetBid() {
qr := kts.app.QueryHelper()
queryClient := types.NewQueryClient(qr)
testCases := []struct { testCases := []struct {
msg string msg string
req *types.QueryBidRequest req *types.QueryBidRequest
@ -201,7 +186,7 @@ func (kts *KeeperTestSuite) TestGrpcGetBid() {
test.req.Bidder = bid.BidderAddress test.req.Bidder = bid.BidderAddress
} }
resp, err := queryClient.GetBid(context.Background(), test.req) resp, err := kts.queryClient.GetBid(context.Background(), test.req)
if test.createAuctionAndBid { if test.createAuctionAndBid {
kts.Require().NoError(err) kts.Require().NoError(err)
kts.Require().NotNil(resp.Bid) kts.Require().NotNil(resp.Bid)
@ -215,9 +200,6 @@ func (kts *KeeperTestSuite) TestGrpcGetBid() {
} }
func (kts *KeeperTestSuite) TestGrpcGetAuctionsByBidder() { func (kts *KeeperTestSuite) TestGrpcGetAuctionsByBidder() {
qr := kts.app.QueryHelper()
queryClient := types.NewQueryClient(qr)
testCases := []struct { testCases := []struct {
msg string msg string
req *types.QueryAuctionsByBidderRequest req *types.QueryAuctionsByBidderRequest
@ -246,7 +228,7 @@ func (kts *KeeperTestSuite) TestGrpcGetAuctionsByBidder() {
test.req.BidderAddress = bid.BidderAddress test.req.BidderAddress = bid.BidderAddress
} }
resp, err := queryClient.AuctionsByBidder(context.Background(), test.req) resp, err := kts.queryClient.AuctionsByBidder(context.Background(), test.req)
if test.createAuctionAndCommitBid { if test.createAuctionAndCommitBid {
kts.Require().NoError(err) kts.Require().NoError(err)
kts.Require().NotNil(resp.Auctions) kts.Require().NotNil(resp.Auctions)
@ -260,9 +242,6 @@ func (kts *KeeperTestSuite) TestGrpcGetAuctionsByBidder() {
} }
func (kts *KeeperTestSuite) TestGrpcGetAuctionsByOwner() { func (kts *KeeperTestSuite) TestGrpcGetAuctionsByOwner() {
qr := kts.app.QueryHelper()
queryClient := types.NewQueryClient(qr)
testCases := []struct { testCases := []struct {
msg string msg string
req *types.QueryAuctionsByOwnerRequest req *types.QueryAuctionsByOwnerRequest
@ -291,7 +270,7 @@ func (kts *KeeperTestSuite) TestGrpcGetAuctionsByOwner() {
test.req.OwnerAddress = auction.OwnerAddress test.req.OwnerAddress = auction.OwnerAddress
} }
resp, err := queryClient.AuctionsByOwner(context.Background(), test.req) resp, err := kts.queryClient.AuctionsByOwner(context.Background(), test.req)
if test.createAuction { if test.createAuction {
kts.Require().NoError(err) kts.Require().NoError(err)
kts.Require().NotNil(resp.Auctions) kts.Require().NotNil(resp.Auctions)
@ -305,9 +284,6 @@ func (kts *KeeperTestSuite) TestGrpcGetAuctionsByOwner() {
} }
func (kts *KeeperTestSuite) TestGrpcQueryBalance() { func (kts *KeeperTestSuite) TestGrpcQueryBalance() {
qr := kts.app.QueryHelper()
queryClient := types.NewQueryClient(qr)
testCases := []struct { testCases := []struct {
msg string msg string
req *types.QueryGetAuctionModuleBalanceRequest req *types.QueryGetAuctionModuleBalanceRequest
@ -334,20 +310,21 @@ func (kts *KeeperTestSuite) TestGrpcQueryBalance() {
kts.Require().NoError(err) kts.Require().NoError(err)
} }
resp, err := queryClient.GetAuctionModuleBalance(context.Background(), test.req) resp, err := kts.queryClient.GetAuctionModuleBalance(context.Background(), test.req)
kts.Require().NoError(err) kts.Require().NoError(err)
kts.Require().Equal(test.auctionCount, len(resp.GetBalance())) kts.Require().Equal(test.auctionCount, len(resp.GetBalance()))
} }
} }
func (kts *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.Auction, *types.Bid, error) { func (kts *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.Auction, *types.Bid, error) {
ctx, k := kts.sdkCtx, kts.auctionKeeper ctx, k := kts.SdkCtx, kts.AuctionKeeper
accCount := 1 accCount := 1
if commitBid { if commitBid {
accCount++ accCount++
} }
accounts := simtestutil.AddTestAddrs(kts.bankKeeper, bondDenomProvider{}, ctx, 2, math.NewInt(100)) // Create funded account(s)
accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(100))
params, err := k.GetParams(ctx) params, err := k.GetParams(ctx)
if err != nil { if err != nil {
@ -370,9 +347,3 @@ func (kts *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.Au
return auction, nil, nil return auction, nil, nil
} }
type bondDenomProvider struct{}
func (bdp bondDenomProvider) BondDenom(ctx context.Context) (string, error) {
return sdk.DefaultBondDenom, nil
}

View File

@ -0,0 +1,30 @@
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/bond"
)
type KeeperTestSuite struct {
suite.Suite
integrationTest.TestFixture
queryClient types.QueryClient
}
func (kts *KeeperTestSuite) SetupTest() {
err := kts.TestFixture.Setup()
assert.Nil(kts.T(), err)
qr := kts.App.QueryHelper()
kts.queryClient = types.NewQueryClient(qr)
}
func TestBondKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}

View File

@ -0,0 +1,83 @@
package keeper_test
import (
"context"
"fmt"
"cosmossdk.io/math"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
integrationTest "git.vdb.to/cerc-io/laconic2d/tests/integration"
types "git.vdb.to/cerc-io/laconic2d/x/bond"
)
func (kts *KeeperTestSuite) TestGrpcQueryParams() {
testCases := []struct {
msg string
req *types.QueryParamsRequest
}{
{
"fetch params",
&types.QueryParamsRequest{},
},
}
for _, test := range testCases {
kts.Run(fmt.Sprintf("Case %s", test.msg), func() {
resp, err := kts.queryClient.Params(context.Background(), test.req)
kts.Require().Nil(err)
kts.Require().Equal(*(resp.Params), types.DefaultParams())
})
}
}
func (kts *KeeperTestSuite) TestGrpcQueryBondsList() {
testCases := []struct {
msg string
req *types.QueryGetBondsRequest
resp *types.QueryGetBondsResponse
noOfBonds int
createBonds bool
}{
{
"empty request",
&types.QueryGetBondsRequest{},
&types.QueryGetBondsResponse{},
0,
false,
},
{
"Get Bonds",
&types.QueryGetBondsRequest{},
&types.QueryGetBondsResponse{},
1,
true,
},
}
for _, test := range testCases {
kts.Run(fmt.Sprintf("Case %s ", test.msg), func() {
if test.createBonds {
_, err := kts.createBond()
kts.Require().NoError(err)
}
resp, _ := kts.queryClient.Bonds(context.Background(), test.req)
kts.Require().Equal(test.noOfBonds, len(resp.GetBonds()))
})
}
}
func (kts *KeeperTestSuite) createBond() (*types.Bond, error) {
ctx, k := kts.SdkCtx, kts.BondKeeper
accCount := 1
// Create funded account(s)
accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(1000))
bond, err := k.CreateBond(ctx, accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))))
if err != nil {
return nil, err
}
return bond, nil
}

143
tests/integration/common.go Normal file
View File

@ -0,0 +1,143 @@
package integration_test
import (
"context"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
cmtprototypes "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/integration"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
auctionTypes "git.vdb.to/cerc-io/laconic2d/x/auction"
auctionkeeper "git.vdb.to/cerc-io/laconic2d/x/auction/keeper"
auctionmodule "git.vdb.to/cerc-io/laconic2d/x/auction/module"
bondTypes "git.vdb.to/cerc-io/laconic2d/x/bond"
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"
)
type TestFixture struct {
App *integration.App
SdkCtx sdk.Context
cdc codec.Codec
keys map[string]*storetypes.KVStoreKey
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
AuctionKeeper *auctionkeeper.Keeper
BondKeeper *bondkeeper.Keeper
// RegistryKeeper
}
func (tf *TestFixture) Setup() error {
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, auctionTypes.StoreKey, bondTypes.StoreKey,
)
cdc := moduletestutil.MakeTestEncodingConfig(
auth.AppModuleBasic{},
auctionmodule.AppModule{},
bondmodule.AppModule{},
).Codec
logger := log.NewNopLogger() // Use log.NewTestLogger(tf.T()) for help with debugging
cms := integration.CreateMultiStore(keys, logger)
newCtx := sdk.NewContext(cms, cmtprototypes.Header{}, true, logger)
authority := authtypes.NewModuleAddress("gov")
maccPerms := map[string][]string{
minttypes.ModuleName: {authtypes.Minter},
auctionTypes.ModuleName: {},
auctionTypes.AuctionBurnModuleAccountName: {},
bondTypes.ModuleName: {},
registryTypes.ModuleName: {},
registryTypes.RecordRentModuleAccountName: {},
registryTypes.AuthorityRentModuleAccountName: {},
}
accountKeeper := authkeeper.NewAccountKeeper(
cdc,
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
authtypes.ProtoBaseAccount,
maccPerms,
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
sdk.Bech32MainPrefix,
authority.String(),
)
blockedAddresses := map[string]bool{
accountKeeper.GetAuthority(): false,
}
bankKeeper := bankkeeper.NewBaseKeeper(
cdc,
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
accountKeeper,
blockedAddresses,
authority.String(),
log.NewNopLogger(),
)
auctionKeeper := auctionkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[auctionTypes.StoreKey]), accountKeeper, bankKeeper)
bondKeeper := bondkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[auctionTypes.StoreKey]), accountKeeper, bankKeeper)
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)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
auctionTypes.ModuleName: auctionModule,
bondTypes.ModuleName: bondModule,
})
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())
// Register MsgServer and QueryServer
auctionTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), auctionkeeper.NewMsgServerImpl(auctionKeeper))
auctionTypes.RegisterQueryServer(integrationApp.QueryHelper(), auctionkeeper.NewQueryServerImpl(auctionKeeper))
bondTypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), bondkeeper.NewMsgServerImpl(bondKeeper))
bondTypes.RegisterQueryServer(integrationApp.QueryHelper(), bondkeeper.NewQueryServerImpl(bondKeeper))
// set default params
if err := auctionKeeper.Params.Set(sdkCtx, auctionTypes.DefaultParams()); err != nil {
return err
}
if err := bondKeeper.Params.Set(sdkCtx, bondTypes.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
return nil
}
type BondDenomProvider struct{}
func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) {
return sdk.DefaultBondDenom, nil
}

View File

@ -4,6 +4,9 @@ import "cosmossdk.io/collections"
const ( const (
ModuleName = "bond" ModuleName = "bond"
// StoreKey defines the primary module store key
StoreKey = ModuleName
) )
// Store prefixes // Store prefixes