Skip to content

Commit

Permalink
Merge branch 'main' into ducnt/grace_period
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 committed Feb 27, 2024
2 parents f001453 + 93be5df commit 0879bb4
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 13 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"
- "e2e-ibc-grace-period"
fail-fast: false
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: E2E Tests

on:
workflow_dispatch:
pull_request:
types:
# trigger workflow if PR is opened directly as R4R.
- opened
# trigger workflow if changes are pushed to the branch.
- synchronize
# trigger workflow if PR is marked ready for review.
- ready_for_review
paths-ignore:
- 'docs/**'
- '**.md'
- 'LICENSE'

permissions:
contents: read
packages: write

jobs:
# e2e-tests-by runs the actual go test command to trigger the test.
e2e-tests:
strategy:
matrix:
tests:
- "e2e-test-ibc-success"
- "e2e-test-ibc-timeout"
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: dymensionxyz/e2e-tests
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: "1.21.4"

- name: E2E Tests
run: make ${{ matrix.tests }}
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
###############################################################################

# 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 .

e2e-ibc-grace-period:
e2e-test-ibc-grace-period:
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
e2e-test-all: e2e-test-ibc-success e2e-test-ibc-timeout e2e-test-ibc-grace-period

.PHONY: e2e-test-ibc e2e-test-ibc-timeout e2e-ibc-grace-period e2e-test-all
.PHONY: e2e-test-ibc-success e2e-test-ibc-timeout e2e-test-ibc-grace-period 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)
}
7 changes: 4 additions & 3 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 @@ -17,8 +18,8 @@ import (

const ibcPath = "dymension-demo"

// TestIBCTransfer ensure that the transfer between Hub and Rollapp is accurate.
func TestIBCTransfer(t *testing.T) {
// TestStart is a basic test to assert that spinning up a dymension network with 1 validator works properly.
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 0879bb4

Please sign in to comment.