Skip to content

Commit

Permalink
additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Zavgorodnii committed Dec 20, 2024
1 parent 5a180b7 commit f3bd034
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion tests/ibc/tokenfactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type TokenfactoryTestSuite struct {
IBCTestSuite
}

func TestPocTestSuite(t *testing.T) {
func TestTokenfactoryTestSuite(t *testing.T) {
suite.Run(t, new(TokenfactoryTestSuite))
}

Expand Down Expand Up @@ -123,3 +123,49 @@ func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrow() {
_, err = s.neutronChain.SendMsgs(burnMsg)
s.Assert().ErrorContains(err, "burning from IBC escrow accounts is forbidden")
}

func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrowReverse() {
// Create token factory denom
createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest")
_, err := s.neutronChain.SendMsgs(createDenomMsg)
s.Assert().NoError(err)

// Derive full token factory denom
denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom)

// Mint denom to sender
amount := sdk.NewCoin(denom, math.NewInt(10000000))
mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount)
_, err = s.neutronChain.SendMsgs(mintMsg)
s.Assert().NoError(err)

// Send IBC transfer
s.IBCTransfer(
s.neutronChainBPath,
s.neutronChainBPath.EndpointA,
s.neutronAddr,
s.neutronAddr,
amount.Denom,
amount.Amount,
"",
)

// Create token factory denom
createDenomMsg = tftypes.NewMsgCreateDenom(s.bundleB.Chain.SenderAccount.GetAddress().String(), "testtest")
_, err = s.bundleB.Chain.SendMsgs(createDenomMsg)
s.Assert().NoError(err)

// Derive IBC escrow address for channel
escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronChainBPath.EndpointB.ChannelID)

// Derive full token factory denom
denom = fmt.Sprintf("factory/%s/%s", s.bundleB.Chain.SenderAccount.GetAddress().String(), createDenomMsg.Subdenom)

// Mint denom to sender
amount = sdk.NewCoin(denom, math.NewInt(10000000))

// Burn tokens from escrow address
burnMsg := tftypes.NewMsgBurnFrom(s.bundleB.Chain.SenderAccount.GetAddress().String(), amount, escrowAddress.String())
_, err = s.bundleB.Chain.SendMsgs(burnMsg)
s.Assert().ErrorContains(err, "burning from IBC escrow accounts is forbidden")
}

0 comments on commit f3bd034

Please sign in to comment.