Skip to content

Commit

Permalink
Merge branch 'main' into ducnt/matrix_rollapp
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 authored Mar 15, 2024
2 parents c54d6f9 + 18d7f01 commit a4d0bfc
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 14 deletions.
4 changes: 2 additions & 2 deletions tests/ibc_grace_period_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ func TestIBCGracePeriodCompliance(t *testing.T) {
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount))
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0))

// Wait a 30 blocks
err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1)
// Wait a 40 blocks
err = testutil.WaitForBlocks(ctx, 40, dymension, rollapp1)
require.NoError(t, err)

// Assert balance was updated on the Hub
Expand Down
2 changes: 1 addition & 1 deletion tests/ibc_pfm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func TestIBCTransferMultiHop(t *testing.T) {
err = transferTx.Validate()
require.NoError(t, err)

err = testutil.WaitForBlocks(ctx, 15, rollapp1)
err = testutil.WaitForBlocks(ctx, 40, rollapp1, osmosis)
require.NoError(t, err)

testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount))
Expand Down
3 changes: 1 addition & 2 deletions tests/ibc_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func TestIBCTransferTimeout(t *testing.T) {
ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV),
ConfigFileOverrides: nil,
},
// ChainConfig: dymensionConfig,
NumValidators: &numHubVals,
NumFullNodes: &numHubFullNodes,
},
Expand Down Expand Up @@ -221,7 +220,7 @@ func TestIBCTransferTimeout(t *testing.T) {
err = r.StartRelayer(ctx, eRep, ibcPath)
require.NoError(t, err)

err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp1)
err = testutil.WaitForBlocks(ctx, 40, dymension, rollapp1)
require.NoError(t, err)

// Assert funds were returned to the sender after the timeout has occured
Expand Down
65 changes: 56 additions & 9 deletions tests/ibc_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"cosmossdk.io/math"
transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
test "github.com/decentrio/rollup-e2e-testing"
"github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub"
"github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp"
Expand Down Expand Up @@ -36,10 +37,11 @@ func TestIBCTransferSuccess(t *testing.T) {

configFileOverrides["config/dymint.toml"] = dymintTomlOverrides
// Create chain factory with dymension
numHubVals := 1
numHubVals := 2
numHubFullNodes := 1
numRollAppFn := 0
numRollAppVals := 1

cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{
{
Name: "rollapp1",
Expand Down Expand Up @@ -152,18 +154,63 @@ func TestIBCTransferSuccess(t *testing.T) {
channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID)
require.NoError(t, err)

err = r.StartRelayer(ctx, eRep, ibcPath)
require.NoError(t, err)
t.Cleanup(
func() {
err := r.StopRelayer(ctx, eRep)
if err != nil {
t.Logf("an error occurred while stopping the relayer: %s", err)
}
},
)

// Compose an IBC transfer and send from dymension -> rollapp
var transferAmount = math.NewInt(1_000_000)

err = dymension.IBCTransfer(ctx,
dymension, rollapp1, transferAmount, dymensionUserAddr,
rollappUserAddr, r, ibcPath, channel,
eRep, ibc.TransferOptions{})
transferData := ibc.WalletData{
Address: rollappUserAddr,
Denom: dymension.Config().Denom,
Amount: transferAmount,
}

// Compose an IBC transfer and send from Hub -> rollapp
_, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{})
require.NoError(t, err)
// Assert balance was updated on the hub
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount))

err = rollapp1.IBCTransfer(ctx,
rollapp1, dymension, transferAmount, rollappUserAddr,
dymensionUserAddr, r, ibcPath, channel,
eRep, ibc.TransferOptions{})
err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)

// Get the IBC denom
dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom)
dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom()

testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount))
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount)

transferData = ibc.WalletData{
Address: dymensionUserAddr,
Denom: rollapp1.Config().Denom,
Amount: transferAmount,
}

// Compose an IBC transfer and send from rollapp -> Hub
_, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{})
require.NoError(t, err)

// Assert balance was updated on the hub
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount))

err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1)
require.NoError(t, err)

// Get the IBC denom for urax on Hub
rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom)
rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom()

// Assert funds were returned to the sender after the timeout has occured
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount))
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount)
}
4 changes: 4 additions & 0 deletions tests/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ var (
Key: "app_state.feemarket.params.no_base_fee",
Value: true,
},
{
Key: "app_state.feemarket.params.min_gas_price",
Value: "0",
},
}

dymensionGenesisKV = []cosmos.GenesisKV{
Expand Down

0 comments on commit a4d0bfc

Please sign in to comment.