2024-02-29 11:54:35 +00:00
|
|
|
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"
|
|
|
|
|
2024-04-01 09:57:26 +00:00
|
|
|
auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
|
|
|
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
|
|
|
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
|
|
|
bondTypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
|
|
|
bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
|
|
|
bondmodule "git.vdb.to/cerc-io/laconicd/x/bond/module"
|
|
|
|
registryTypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
|
|
|
registrykeeper "git.vdb.to/cerc-io/laconicd/x/registry/keeper"
|
|
|
|
registrymodule "git.vdb.to/cerc-io/laconicd/x/registry/module"
|
2024-02-29 11:54:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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 registrykeeper.Keeper
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tf *TestFixture) Setup() error {
|
|
|
|
keys := storetypes.NewKVStoreKeys(
|
|
|
|
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(kts.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)
|
|
|
|
|
2024-08-22 13:52:23 +00:00
|
|
|
bondKeeper := bondkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[bondTypes.StoreKey]), accountKeeper, bankKeeper, authority.String())
|
2024-02-29 11:54:35 +00:00
|
|
|
|
2024-07-11 05:16:31 +00:00
|
|
|
registryKeeper := registrykeeper.NewKeeper(
|
|
|
|
cdc,
|
|
|
|
runtime.NewKVStoreService(keys[registryTypes.StoreKey]),
|
|
|
|
accountKeeper,
|
|
|
|
bankKeeper,
|
|
|
|
bondKeeper,
|
|
|
|
auctionKeeper,
|
2024-09-02 04:13:08 +00:00
|
|
|
authority.String(),
|
2024-07-11 05:16:31 +00:00
|
|
|
)
|
2024-02-29 11:54:35 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
registryTypes.ModuleName: registryModule,
|
|
|
|
})
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
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 = accountKeeper, bankKeeper
|
|
|
|
tf.AuctionKeeper, tf.BondKeeper, tf.RegistryKeeper = auctionKeeper, bondKeeper, registryKeeper
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type BondDenomProvider struct{}
|
|
|
|
|
|
|
|
func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) {
|
|
|
|
return sdk.DefaultBondDenom, nil
|
|
|
|
}
|