Skip to content

Commit

Permalink
Fix: Fix test IBC Timeout (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
GNaD13 authored Feb 26, 2024
1 parent 04837da commit 93be5df
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-workflow-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
tests:
- "e2e-test-ibc"
- "e2e-test-ibc-success"
- "e2e-test-ibc-timeout"
fail-fast: false
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
tests:
- "e2e-test-ibc"
- "e2e-test-ibc-success"
- "e2e-test-ibc-timeout"
fail-fast: false
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
###############################################################################

# Executes IBC tests via rollup-e2e-testing
e2e-test-ibc:
cd tests && go test -timeout=25m -race -v -run TestIBCTransfer .
e2e-test-ibc-success:
cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess .

# Executes IBC tests via rollup-e2e-testing
e2e-test-ibc-timeout:
cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout .

# Executes all tests via rollup-e2e-testing
e2e-test-all: e2e-test-ibc e2e-test-ibc-timeout
e2e-test-all: e2e-test-ibc-success e2e-test-ibc-timeout

.PHONY: e2e-test-ibc e2e-test-ibc-timeout e2e-test-all
.PHONY: e2e-test-ibc-success e2e-test-ibc-timeout e2e-test-all

13 changes: 9 additions & 4 deletions tests/ibc_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tests

import (
"context"
"fmt"
"testing"

"cosmossdk.io/math"
Expand All @@ -28,7 +29,7 @@ func TestIBCTransferTimeout(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-TestIBCTransferTimeout:26657"
dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name())
dymintTomlOverrides["rollapp_id"] = "demo-dymension-rollapp"

configFileOverrides["config/dymint.toml"] = dymintTomlOverrides
Expand Down Expand Up @@ -184,6 +185,11 @@ func TestIBCTransferTimeout(t *testing.T) {
dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom()
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0))

// According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight
// in order to trigger ibc timeout or else it will trigger callback
err = testutil.WaitForBlocks(ctx, 5, rollapp1)
require.NoError(t, err)

err = r.StartRelayer(ctx, eRep, ibcPath)
require.NoError(t, err)

Expand All @@ -196,11 +202,10 @@ func TestIBCTransferTimeout(t *testing.T) {
},
)

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

// Assert funds were returned to the sender after the timeout has occured
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount)
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0))

testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount)
}
5 changes: 3 additions & 2 deletions tests/ibc_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tests

import (
"context"
"fmt"
"testing"

"cosmossdk.io/math"
Expand All @@ -18,7 +19,7 @@ import (
const ibcPath = "dymension-demo"

// TestStart is a basic test to assert that spinning up a dymension network with 1 validator works properly.
func TestIBCTransfer(t *testing.T) {
func TestIBCTransferSuccess(t *testing.T) {
if testing.Short() {
t.Skip()
}
Expand All @@ -28,7 +29,7 @@ func TestIBCTransfer(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-TestIBCTransfer:26657"
dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name())
dymintTomlOverrides["rollapp_id"] = "demo-dymension-rollapp"

configFileOverrides["config/dymint.toml"] = dymintTomlOverrides
Expand Down

0 comments on commit 93be5df

Please sign in to comment.