package keeper_test
import (
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cybercongress/go-cyber/v7/app/apptesting"
"github.com/cybercongress/go-cyber/v7/x/tokenfactory/types"
"github.com/stretchr/testify/suite"
)
type KeeperTestSuite struct {
apptesting.KeeperTestHelper
queryClient types.QueryClient
bankQueryClient banktypes.QueryClient
msgServer types.MsgServer
defaultDenom string
}
func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}
func (suite *KeeperTestSuite) SetupTest() {
suite.Setup()
fundAccsAmount := sdk.NewCoins(sdk.NewCoin(types.DefaultParams().DenomCreationFee[0].Denom, types.DefaultParams().DenomCreationFee[0].Amount.MulRaw(100)), sdk.NewCoin(apptesting.SecondaryDenom, apptesting.SecondaryAmount))
for _, acc := range suite.TestAccs {
suite.FundAcc(acc, fundAccsAmount)
}
suite.queryClient = types.NewQueryClient(suite.QueryHelper)
suite.bankQueryClient = banktypes.NewQueryClient(suite.QueryHelper)
suite.msgServer = keeper.NewMsgServerImpl(suite.App.AppKeepers.TokenFactoryKeeper)
}
func (suite *KeeperTestSuite) CreateDefaultDenom() {
res, _ := suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin"))
suite.defaultDenom = res.GetNewTokenDenom()
}
func (suite *KeeperTestSuite) TestCreateModuleAccount() {
app := suite.App
tokenfactoryModuleAccount := app.AppKeepers.AccountKeeper.GetAccount(suite.Ctx, app.AppKeepers.AccountKeeper.GetModuleAddress(types.ModuleName))
app.AppKeepers.AccountKeeper.RemoveAccount(suite.Ctx, tokenfactoryModuleAccount)
suite.Ctx = app.BaseApp.NewContext(false, tmproto.Header{ChainID: "testing"})
tokenfactoryModuleAccount = app.AppKeepers.AccountKeeper.GetAccount(suite.Ctx, app.AppKeepers.AccountKeeper.GetModuleAddress(types.ModuleName))
suite.Require().Nil(tokenfactoryModuleAccount)
app.AppKeepers.TokenFactoryKeeper.CreateModuleAccount(suite.Ctx)
tokenfactoryModuleAccount = app.AppKeepers.AccountKeeper.GetAccount(suite.Ctx, app.AppKeepers.AccountKeeper.GetModuleAddress(types.ModuleName))
suite.Require().NotNil(tokenfactoryModuleAccount)
}