From 67620cdd0c2351a645fbcb344085819e0b35a110 Mon Sep 17 00:00:00 2001 From: javiersuweijie Date: Thu, 30 May 2024 15:40:11 +0800 Subject: [PATCH] test --- x/tokenfactory/keeper/msg_server_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index bd6ba3f8..4ae109b0 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "fmt" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "testing" "github.com/stretchr/testify/suite" @@ -187,6 +188,26 @@ func (s *KeeperTestSuite) TestBurnDenomMsg() { } } +func (s *KeeperTestSuite) TestForceTransferMsgFromModuleAcc() { + // Create a denom + res, _ := s.msgServer.CreateDenom(sdk.WrapSDKContext(s.Ctx), types.NewMsgCreateDenom(s.TestAccs[0].String(), "bitcoin")) + defaultDenom := res.GetNewTokenDenom() + + s.Run(fmt.Sprintf("test force transfer"), func() { + mintAmt := sdk.NewInt64Coin(defaultDenom, 10) + + _, err := s.msgServer.Mint(sdk.WrapSDKContext(s.Ctx), types.NewMsgMint(s.TestAccs[0].String(), mintAmt)) + + govModAcc := s.App.Keepers.AccountKeeper.GetModuleAccount(s.Ctx, govtypes.ModuleName) + + err = s.App.Keepers.BankKeeper.SendCoins(s.Ctx, s.TestAccs[0], govModAcc.GetAddress(), sdk.NewCoins(mintAmt)) + s.Require().NoError(err) + + _, err = s.msgServer.ForceTransfer(s.Ctx, types.NewMsgForceTransfer(s.TestAccs[0].String(), mintAmt, govModAcc.GetAddress().String(), s.TestAccs[1].String())) + s.Require().ErrorContains(err, "send from module acc not available") + }) +} + // TestCreateDenomMsg tests TypeMsgCreateDenom message is emitted on a successful denom creation func (s *KeeperTestSuite) TestCreateDenomMsg() { for _, tc := range []struct {