Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanhNhann committed Dec 13, 2024
1 parent ce617c2 commit 849143f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 64 deletions.
45 changes: 0 additions & 45 deletions tests/eibc_ack_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"strconv"
"testing"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/x/params/client/utils"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
Expand Down Expand Up @@ -1275,49 +1273,6 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) {

var options ibc.TransferOptions

// register ibc denom on rollapp1
metadata := banktypes.Metadata{
Description: "IBC token from rollapp 2",
DenomUnits: []*banktypes.DenomUnit{
{
Denom: thirdPartyIBCDenomOnRA,
Exponent: 0,
Aliases: []string{"urax"},
},
{
Denom: "urax",
Exponent: 6,
},
},
// Setting base as IBC hash denom since bank keepers's SetDenomMetadata uses
// Base as key path and the IBC hash is what gives this token uniqueness
// on the executing chain
Base: thirdPartyIBCDenomOnRA,
Display: "urax",
Name: "urax",
Symbol: "urax",
}

data := map[string][]banktypes.Metadata{
"metadata": {metadata},
}

contentFile, err := json.Marshal(data)
require.NoError(t, err)
rollapp1.GetNode().WriteFile(ctx, contentFile, "./ibcmetadata.json")
deposit := "500000000000" + rollapp1.Config().Denom
rollapp1.GetNode().HostName()
_, err = rollapp1.GetNode().RegisterIBCTokenDenomProposal(ctx, rollapp1UserAddr, deposit, rollapp1.GetNode().HomeDir()+"/ibcmetadata.json")
require.NoError(t, err)

err = rollapp1.VoteOnProposalAllValidators(ctx, "1", cosmos.ProposalVoteYes)
require.NoError(t, err, "failed to submit votes")

height, err := rollapp1.Height(ctx)
require.NoError(t, err, "error fetching height")
_, err = cosmos.PollForProposalStatus(ctx, rollapp1.CosmosChain, height, height+30, "1", cosmos.ProposalStatusPassed)
require.NoError(t, err, "proposal status did not change to passed")

t.Run("Demand order is created upon AckError for rollapp token", func(t *testing.T) {
transferData := ibc.WalletData{
Address: marketMakerAddr,
Expand Down
38 changes: 19 additions & 19 deletions tests/erc20_ibc_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,34 +523,34 @@ func TestERC20RollAppToHubNewRegister_EVM(t *testing.T) {
// // Assert balance was updated on the hub
// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount))
// // Check fund was set to erc20 module account on rollapp
erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20")
require.NoError(t, err)
erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address
rollappErc20MaccBalance, err := rollapp1.GetBalance(ctx, erc20MAccAddr, dymensionIBCDenom)
require.NoError(t, err)
// erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20")
// require.NoError(t, err)
// erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address
// rollappErc20MaccBalance, err := rollapp1.GetBalance(ctx, erc20MAccAddr, dymensionIBCDenom)
// require.NoError(t, err)

require.True(t, rollappErc20MaccBalance.Equal(transferAmount))
require.NoError(t, err)
// require.True(t, rollappErc20MaccBalance.Equal(transferAmount))
// require.NoError(t, err)

tokenPair, err := rollapp1.GetNode().QueryErc20TokenPair(ctx, dymensionIBCDenom)
require.NoError(t, err)
require.NotNil(t, tokenPair)
// tokenPair, err := rollapp1.GetNode().QueryErc20TokenPair(ctx, dymensionIBCDenom)
// require.NoError(t, err)
// require.NotNil(t, tokenPair)

// convert erc20
_, err = rollapp1.GetNode().ConvertErc20(ctx, rollappUser.KeyName(), tokenPair.Erc20Address, transferAmount.String(), rollappUserAddr, rollappUserAddr, rollapp1.Config().ChainID)
require.NoError(t, err, "can not convert erc20 to cosmos coin")
// // convert erc20
// _, err = rollapp1.GetNode().ConvertErc20(ctx, rollappUser.KeyName(), tokenPair.Erc20Address, transferAmount.String(), rollappUserAddr, rollappUserAddr, rollapp1.Config().ChainID)
// require.NoError(t, err, "can not convert erc20 to cosmos coin")

err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1)
require.NoError(t, err)
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount)
// err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1)
// require.NoError(t, err)
// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount)

rollappAdrrHex := common.BytesToAddress(rollappUser.Address())
_, err = rollapp1.GetNode().ConvertCoin(ctx, rollappUser.KeyName(), fmt.Sprintf("%v%s", transferAmount, dymensionIBCDenom), rollappAdrrHex.String())
_, err = rollapp1.GetNode().ConvertCoin(ctx, rollappUser.KeyName(), fmt.Sprintf("%v%s", transferAmount, rollapp1.Config().Denom), rollappAdrrHex.String())
require.NoError(t, err)

// register erc20 erc20
_, err = rollapp1.GetNode().RegisterERC20AsToken(ctx, rollappUser.KeyName(), tokenPair.Erc20Address)
require.NoError(t, err, "can not register erc20 to cosmos coin")
// _, err = rollapp1.GetNode().RegisterERC20AsToken(ctx, rollappUser.KeyName(), tokenPair.Erc20Address)
// require.NoError(t, err, "can not register erc20 to cosmos coin")

err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1)
require.NoError(t, err)
Expand Down

0 comments on commit 849143f

Please sign in to comment.