Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersuweijie committed May 30, 2024
1 parent e6d56f9 commit 67620cd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions x/tokenfactory/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper_test

import (
"fmt"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"testing"

"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 67620cd

Please sign in to comment.