From 8c8c089c74591a22b228f214916004ff47644fa3 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 09:58:17 +0700 Subject: [PATCH 01/11] add e2e-test-grace-period --- .github/workflows/e2e-test-workflow-call.yml | 1 + Makefile | 9 +- tests/grace_period_test.go | 229 +++++++++++++++++++ 3 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 tests/grace_period_test.go diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 86edb631..2d4bf714 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -20,6 +20,7 @@ jobs: tests: - "e2e-test-ibc" - "e2e-test-ibc-timeout" + - "e2e-test-grace-period" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index 03cbe2dd..f87f88a6 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,12 @@ e2e-test-ibc: # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-timeout: cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout . - + +e2e-test-grace-period: + cd tests && go test -timeout=25m -race -v -run TestGracePeriodCompliance . + # Executes all tests via rollup-e2e-testing -e2e-test-all: e2e-test-ibc e2e-test-ibc-timeout +e2e-test-all: e2e-test-ibc e2e-test-ibc-timeout e2e-test-grace-period -.PHONY: e2e-test-ibc e2e-test-ibc-timeout e2e-test-all +.PHONY: e2e-test-ibc e2e-test-ibc-timeout e2e-test-grace-period e2e-test-all diff --git a/tests/grace_period_test.go b/tests/grace_period_test.go new file mode 100644 index 00000000..60425596 --- /dev/null +++ b/tests/grace_period_test.go @@ -0,0 +1,229 @@ +package tests + +import ( + "context" + "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" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +// TestStart is a basic test to assert that spinning up a dymension network with 1 validator works properly. +func TestGracePeriodCompliance(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = "http://dymension_100-1-val-0-TestGracePeriodCompliance:26657" + dymintTomlOverrides["rollapp_id"] = "demo-dymension-rollapp" + + modifyGenesisKV := []cosmos.GenesisKV{ + { + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: "20", + }, + } + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := cosmos.NewBuiltinChainFactory(zaptest.NewLogger(t), []*cosmos.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp", + Name: "rollapp-temp", + ChainID: "demo-dymension-rollapp", + Images: []ibc.DockerImage{rollappImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "udym", + CoinType: "118", + GasPrices: "0.0udym", + EncodingConfig: evmConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: cosmos.ModifyGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*cosmos.CosmosChain) + dymension := chains[1].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := relayer.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/cosmos/relayer", "reece-v2.3.1-ethermint", "100:1000"), + ).Build(t, client, network) + + ic := test.NewSetup(). + AddChain(rollapp1). + AddChain(dymension). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: false, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + // Compose an IBC transfer and send from rollapp -> dymension + var transferAmount = math.NewInt(1_000_000) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + // Assert balance was not updated on the rollapp + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // 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() + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // Assert funds are waiting + 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) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) + + // Stop relayer after relaying + err = r.StopRelayer(ctx, eRep) + require.NoError(t, err, "an error occurred while stopping the relayer") + + channel, err = ibc.GetTransferChannel(ctx, r, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID) + require.NoError(t, err) + + transferData = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from dymension -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Get the IBC denom for dymension on roll app + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, rollapp1) + require.NoError(t, err) + + // Assert funds are waiting + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} From ae78ec477141f8c7974a4849bf1de58c40285e02 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 10:29:02 +0700 Subject: [PATCH 02/11] update comment description --- tests/grace_period_test.go | 6 +++--- tests/ibc_transfer_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/grace_period_test.go b/tests/grace_period_test.go index 60425596..01eda598 100644 --- a/tests/grace_period_test.go +++ b/tests/grace_period_test.go @@ -16,8 +16,8 @@ import ( "go.uber.org/zap/zaptest" ) -// TestStart is a basic test to assert that spinning up a dymension network with 1 validator works properly. -func TestGracePeriodCompliance(t *testing.T) { +// IBCGracePeriodCompliance ensures that the grace period for transaction finalization is correctly enforced on hub and rollapp. +func IBCGracePeriodCompliance(t *testing.T) { if testing.Short() { t.Skip() } @@ -27,7 +27,7 @@ func TestGracePeriodCompliance(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = "http://dymension_100-1-val-0-TestGracePeriodCompliance:26657" + dymintTomlOverrides["node_address"] = "http://dymension_100-1-val-0-IBCGracePeriodCompliance:26657" dymintTomlOverrides["rollapp_id"] = "demo-dymension-rollapp" modifyGenesisKV := []cosmos.GenesisKV{ diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index 033fe41c..ed84c88f 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -17,7 +17,7 @@ import ( const ibcPath = "dymension-demo" -// TestStart is a basic test to assert that spinning up a dymension network with 1 validator works properly. +// TestIBCTransfer ensure that the transfer between Hub and Rollapp is accurate. func TestIBCTransfer(t *testing.T) { if testing.Short() { t.Skip() From 463490985551926dba61392c298c737de957546b Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 10:35:21 +0700 Subject: [PATCH 03/11] update comment description --- tests/grace_period_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/grace_period_test.go b/tests/grace_period_test.go index 01eda598..2a3919ba 100644 --- a/tests/grace_period_test.go +++ b/tests/grace_period_test.go @@ -161,7 +161,8 @@ func IBCGracePeriodCompliance(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - // Assert balance was not updated on the rollapp + + // Assert balance was updated on the rollapp because transfer amount was deducted from wallet balance testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) // Get the IBC denom for urax on Hub @@ -182,6 +183,7 @@ func IBCGracePeriodCompliance(t *testing.T) { err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) require.NoError(t, err) + // Assert balance was updated on the Hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) @@ -201,8 +203,10 @@ func IBCGracePeriodCompliance(t *testing.T) { // Compose an IBC transfer and send from dymension -> rollapp _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - // Assert balance was updated on the rollapp + + // Assert balance was updated on the rollapp because transfer amount was deducted from wallet balance testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -214,7 +218,7 @@ func IBCGracePeriodCompliance(t *testing.T) { err = testutil.WaitForBlocks(ctx, 5, rollapp1) require.NoError(t, err) - // Assert funds are waiting + // Assert balance was updated on the Rollapp testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) From f758fe7c6abe474b420c6448e3ab1f55fc5bb385 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 10:37:17 +0700 Subject: [PATCH 04/11] update comment description --- tests/grace_period_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/grace_period_test.go b/tests/grace_period_test.go index 2a3919ba..9e5e1bea 100644 --- a/tests/grace_period_test.go +++ b/tests/grace_period_test.go @@ -204,7 +204,7 @@ func IBCGracePeriodCompliance(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - // Assert balance was updated on the rollapp because transfer amount was deducted from wallet balance + // Assert balance was updated on the Hub because transfer amount was deducted from wallet balance testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) // Get the IBC denom for dymension on roll app From 1485ecdaecc363478c8f3d8e8970cdf229f6f7ef Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 10:47:32 +0700 Subject: [PATCH 05/11] update makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f87f88a6..d14d1589 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ e2e-test-ibc-timeout: cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout . e2e-test-grace-period: - cd tests && go test -timeout=25m -race -v -run TestGracePeriodCompliance . + cd tests && go test -timeout=25m -race -v -run IBCGracePeriodCompliance . # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc e2e-test-ibc-timeout e2e-test-grace-period From c6482fef049099c92815fb6732777d89dce7e7b1 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 10:49:05 +0700 Subject: [PATCH 06/11] update makefile --- .github/workflows/e2e-test-workflow-call.yml | 3 +-- Makefile | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 4953f255..1d53ea54 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -20,8 +20,7 @@ jobs: tests: - "e2e-test-ibc" - "e2e-test-ibc-timeout" - - "e2e-test-grace-period" - fail-fast: false + - "e2e-ibc-grace-period" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index d14d1589..6445f1f1 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ e2e-test-ibc: e2e-test-ibc-timeout: cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout . -e2e-test-grace-period: +e2e-ibc-grace-period: cd tests && go test -timeout=25m -race -v -run IBCGracePeriodCompliance . # Executes all tests via rollup-e2e-testing From ad14e367bdbb287beffad1dc97524b89b219d3e6 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 10:57:54 +0700 Subject: [PATCH 07/11] update makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6445f1f1..53a0e9d1 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ e2e-ibc-grace-period: cd tests && go test -timeout=25m -race -v -run IBCGracePeriodCompliance . # Executes all tests via rollup-e2e-testing -e2e-test-all: e2e-test-ibc e2e-test-ibc-timeout e2e-test-grace-period +e2e-test-all: e2e-test-ibc e2e-test-ibc-timeout e2e-ibc-grace-period -.PHONY: e2e-test-ibc e2e-test-ibc-timeout e2e-test-grace-period e2e-test-all +.PHONY: e2e-test-ibc e2e-test-ibc-timeout e2e-ibc-grace-period e2e-test-all From 82989fd47880250c1895d97e68b9502abd863f7b Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 11:19:48 +0700 Subject: [PATCH 08/11] reverse order test --- Makefile | 2 +- ...eriod_test.go => ibc_grace_period_test.go} | 77 +++++++++---------- tests/setup.go | 6 +- 3 files changed, 39 insertions(+), 46 deletions(-) rename tests/{grace_period_test.go => ibc_grace_period_test.go} (92%) diff --git a/Makefile b/Makefile index 53a0e9d1..401db840 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ e2e-test-ibc-timeout: cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout . e2e-ibc-grace-period: - cd tests && go test -timeout=25m -race -v -run IBCGracePeriodCompliance . + cd tests && go test -timeout=25m -race -v -run TestIBCGracePeriodCompliance . # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc e2e-test-ibc-timeout e2e-ibc-grace-period diff --git a/tests/grace_period_test.go b/tests/ibc_grace_period_test.go similarity index 92% rename from tests/grace_period_test.go rename to tests/ibc_grace_period_test.go index 9e5e1bea..b21a9e1d 100644 --- a/tests/grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -16,8 +16,8 @@ import ( "go.uber.org/zap/zaptest" ) -// IBCGracePeriodCompliance ensures that the grace period for transaction finalization is correctly enforced on hub and rollapp. -func IBCGracePeriodCompliance(t *testing.T) { +// TestIBCGracePeriodCompliance ensures that the grace period for transaction finalization is correctly enforced on hub and rollapp. +func TestIBCGracePeriodCompliance(t *testing.T) { if testing.Short() { t.Skip() } @@ -27,7 +27,7 @@ func IBCGracePeriodCompliance(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = "http://dymension_100-1-val-0-IBCGracePeriodCompliance:26657" + dymintTomlOverrides["node_address"] = "http://dymension_100-1-val-0-TestIBCGracePeriodCompliance:26657" dymintTomlOverrides["rollapp_id"] = "demo-dymension-rollapp" modifyGenesisKV := []cosmos.GenesisKV{ @@ -150,10 +150,41 @@ func IBCGracePeriodCompliance(t *testing.T) { // Compose an IBC transfer and send from rollapp -> dymension var transferAmount = math.NewInt(1_000_000) - channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + channel, err := ibc.GetTransferChannel(ctx, r, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID) require.NoError(t, err) transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from dymension -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the Hub because transfer amount was deducted from wallet balance + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // Get the IBC denom for dymension on roll app + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, rollapp1) + require.NoError(t, err) + + // Assert balance was updated on the Rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) + + channel, err = ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: rollapp1.Config().Denom, Amount: transferAmount, @@ -169,9 +200,6 @@ func IBCGracePeriodCompliance(t *testing.T) { rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) @@ -187,41 +215,6 @@ func IBCGracePeriodCompliance(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) - // Stop relayer after relaying - err = r.StopRelayer(ctx, eRep) - require.NoError(t, err, "an error occurred while stopping the relayer") - - channel, err = ibc.GetTransferChannel(ctx, r, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID) - require.NoError(t, err) - - transferData = ibc.WalletData{ - Address: rollappUserAddr, - Denom: dymension.Config().Denom, - Amount: transferAmount, - } - - // Compose an IBC transfer and send from dymension -> rollapp - _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - require.NoError(t, err) - - // Assert balance was updated on the Hub because transfer amount was deducted from wallet balance - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) - - // Get the IBC denom for dymension on roll app - dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) - - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 5, rollapp1) - require.NoError(t, err) - - // Assert balance was updated on the Rollapp - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) - t.Cleanup( func() { err := r.StopRelayer(ctx, eRep) diff --git a/tests/setup.go b/tests/setup.go index ed9d901a..70e1c844 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -14,7 +14,7 @@ import ( var ( DymensionMainRepo = "ghcr.io/dymensionxyz/dymension" - RollappMainRepo = "ghcr.io/dymensionxyz/rollapp" + RollappMainRepo = "ghcr.io/decentrio/rollapp" dymensionVersion, rollappVersion = GetDockerImageVersion() @@ -52,12 +52,12 @@ var ( func GetDockerImageVersion() (dymensionVersion, rollappVersion string) { dymensionVersion, found := os.LookupEnv("DYMENSION_CI") if !found { - dymensionVersion = "latest" + dymensionVersion = "e2e" } rollappVersion, found = os.LookupEnv("ROLLAPP_CI") if !found { - rollappVersion = "latest" + rollappVersion = "e2e" } return dymensionVersion, rollappVersion } From f0014537ed30cb508690dc12eaf45310d9b60403 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 26 Feb 2024 13:08:29 +0700 Subject: [PATCH 09/11] revert --- .github/workflows/e2e-test-workflow-call.yml | 1 + tests/setup.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 1d53ea54..f7565b72 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -21,6 +21,7 @@ jobs: - "e2e-test-ibc" - "e2e-test-ibc-timeout" - "e2e-ibc-grace-period" + fail-fast: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/tests/setup.go b/tests/setup.go index 70e1c844..ed9d901a 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -14,7 +14,7 @@ import ( var ( DymensionMainRepo = "ghcr.io/dymensionxyz/dymension" - RollappMainRepo = "ghcr.io/decentrio/rollapp" + RollappMainRepo = "ghcr.io/dymensionxyz/rollapp" dymensionVersion, rollappVersion = GetDockerImageVersion() @@ -52,12 +52,12 @@ var ( func GetDockerImageVersion() (dymensionVersion, rollappVersion string) { dymensionVersion, found := os.LookupEnv("DYMENSION_CI") if !found { - dymensionVersion = "e2e" + dymensionVersion = "latest" } rollappVersion, found = os.LookupEnv("ROLLAPP_CI") if !found { - rollappVersion = "e2e" + rollappVersion = "latest" } return dymensionVersion, rollappVersion } From 1851a9b0bccdc89f76e56596dfe4d477514454ec Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Tue, 27 Feb 2024 09:43:36 +0700 Subject: [PATCH 10/11] rename --- .github/workflows/e2e-test-workflow-call.yml | 2 +- .github/workflows/e2e_test.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index c7565471..ff209836 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -20,7 +20,7 @@ jobs: tests: - "e2e-test-ibc-success" - "e2e-test-ibc-timeout" - - "e2e-ibc-grace-period" + - "e2e-test-ibc-grace-period" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 81251353..040c98ea 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -27,6 +27,7 @@ jobs: tests: - "e2e-test-ibc-success" - "e2e-test-ibc-timeout" + - "e2e-test-ibc-grace-period" fail-fast: false runs-on: ubuntu-latest steps: From 9542bb7ebefcea850b34ad348d63d7d907e8c68b Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Tue, 27 Feb 2024 10:01:21 +0700 Subject: [PATCH 11/11] add comment --- tests/ibc_transfer_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index ecc64bef..493e8f74 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -18,7 +18,7 @@ import ( const ibcPath = "dymension-demo" -// TestStart is a basic test to assert that spinning up a dymension network with 1 validator works properly. +// TestIBCTransferSuccess ensure that the transfer between Hub and Rollapp is accurate. func TestIBCTransferSuccess(t *testing.T) { if testing.Short() { t.Skip()