Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update e2e-live-tests with new hub and rollapp #359

Merged
merged 9 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -533,42 +533,50 @@ e2e-test-all: e2e-test-ibc-success-evm \
clean-e2e-live:
sh clean-live.sh

e2e-live-test-ibc-transfer-success: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestIBCTransfer_Live .
e2e-live-test-ibc-transfer-success-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestIBCTransferRolX_Live .

e2e-live-test-delayedack-rollapp-to-hub: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestDelayackRollappToHub_Live .
e2e-live-test-ibc-transfer-success-roly: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestIBCTransferRolY_Live .

e2e-live-test-eibc-timeout: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCTimeout_Live .
e2e-live-test-delayedack-rollapp-to-hub-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestDelayackRollappToHubRolX_Live .

e2e-live-test-delayack-ack-error-from-dym: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_AckError_Dym_EVM_Live .
e2e-live-test-eibc-timeout-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCTimeoutRolX_Live .

e2e-live-test-eibc-3rd-token: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_3rd_Token_Live .
e2e-live-test-eibc-timeout-roly: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCTimeoutRolY_Live .

e2e-live-test-eibc-3rd-token-timeout: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_3rd_Token_Timeout_Live .
e2e-live-test-delayack-ack-error-from-dym-roly: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_AckError_Dym_RolY_Live .

e2e-live-test-eibc-pfm: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCPFM_Live .
e2e-live-test-eibc-3rd-token-roly: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_3rd_Token_RolY_Live .

e2e-live-test-eibc-3rd-token-timeout-roly: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_3rd_Token_Timeout_RolY_Live .

e2e-live-test-eibc-pfm-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCPFMRolX_Live .

e2e-live-test-eibc-invalid-fee: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_Invalid_Fee_Live .
e2e-live-test-eibc-invalid-fee-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_Invalid_Fee_RolX_Live .

e2e-live-test-eibc-fulfillment: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCFulfill_Live .
e2e-live-test-eibc-fulfillment-rolx: clean-e2e-live
cd live-tests && go test -timeout=35m -race -v -run TestEIBCFulfillRolX_Live .

e2e-live-test-delayack-rollapp-to-hub-no-finalized: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestDelayackRollappToHubNoFinalized_Live .
e2e-live-test-delayack-rollapp-to-hub-no-finalized-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestDelayackRollappToHubNoFinalizedRolX_Live .

e2e-live-test-eibc-no-memo: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_No_Memo_Live .
e2e-live-test-eibc-no-memo-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_No_Memo_RolX_Live .

e2e-live-test-eibc-demand-order-ignored: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_Demand_Order_Ignored_Live .
e2e-live-test-eibc-demand-order-ignored-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBC_Demand_Order_Ignored_RolX_Live .

e2e-live-test-eibc-eibc-fee-bgt-amount: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCFeeBgtAmount_Live .
e2e-live-test-eibc-eibc-fee-bgt-amount-rolx: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCFeeBgtAmountRolX_Live .

e2e-live-test-eibc-eibc-fee-bgt-amount-roly: clean-e2e-live
cd live-tests && go test -timeout=25m -race -v -run TestEIBCFeeBgtAmountRolY_Live .
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ replace (
)

require (
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869
github.com/decentrio/rollup-e2e-testing v0.0.0-20240805094848-68d57d56ae62
github.com/decentrio/e2e-testing-live v0.0.0-20240805104706-dc8d537e8007
github.com/decentrio/rollup-e2e-testing v0.0.0-20240807082808-165b0678bfbb
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240717194206-54c0fca5fada
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 h1:qWpUYGOsrSC+1Vmd2TjhbsSpntvvx9PsX3AoeMunFxc=
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869/go.mod h1:HZNYnPwmSxkwTPjSD5yolauc1Vx1ZzKL4FFMxTq4H5Y=
github.com/decentrio/rollup-e2e-testing v0.0.0-20240805094848-68d57d56ae62 h1:9FL0ehOjknP7jgDXYlJ91MytI02CyYJOwtIZfelqypM=
github.com/decentrio/rollup-e2e-testing v0.0.0-20240805094848-68d57d56ae62/go.mod h1:NwTceYVxAaIZI65g/PdibVnGRMXuZzqzhDIkWsqJaQM=
github.com/decentrio/e2e-testing-live v0.0.0-20240805104706-dc8d537e8007 h1:nZx4zQTGwk7STTqSj5UKVeMo18RC38hk0C7nXc4T35w=
github.com/decentrio/e2e-testing-live v0.0.0-20240805104706-dc8d537e8007/go.mod h1:qLIf3XX6bQsQlmVqhbNOiLc/ONeA0NDiPmpsrljJkXc=
github.com/decentrio/rollup-e2e-testing v0.0.0-20240807082808-165b0678bfbb h1:ElITwp9D3LbC1ubglR9imMmkKRSMmKFyTzyjtahChAI=
github.com/decentrio/rollup-e2e-testing v0.0.0-20240807082808-165b0678bfbb/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
Expand Down
229 changes: 229 additions & 0 deletions live-tests/delayed_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
package livetests

import (
"context"
"fmt"
"sync"
"testing"
"time"

sdkmath "cosmossdk.io/math"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
"github.com/decentrio/e2e-testing-live/cosmos"
"github.com/decentrio/e2e-testing-live/testutil"
"github.com/decentrio/rollup-e2e-testing/ibc"
"github.com/stretchr/testify/require"
)

// TestDelayackRollappToHubNoFinalized_Live test IBC transfer from rollapp to hub, so that its succeeds (creates rollapp packet) when rollapp has NO FINALIZED STATES AT ALL (just pending)
func TestDelayackRollappToHubNoFinalizedRolX_Live(t *testing.T) {
if testing.Short() {
t.Skip()
}
ctx := context.Background()

hub := cosmos.CosmosChain{
RPCAddr: "rpc-blumbus.mzonder.com:443",
GrpcAddr: "grpc-blumbus.mzonder.com:9090",
ChainID: "blumbus_111-1",
Bin: "dymd",
GasPrices: "1000adym",
GasAdjustment: "1.1",
Denom: "adym",
}

rollappX := cosmos.CosmosChain{
RPCAddr: "rpc.rolxtwo.evm.ra.blumbus.noisnemyd.xyz:443",
GrpcAddr: "3.123.185.77:9090",
ChainID: "rolx_100004-1",
Bin: "rollapp-evm",
GasPrices: "0.0arolx",
GasAdjustment: "1.1",
Denom: "arolx",
}

dymensionUser, err := hub.CreateUser("dym1")
require.NoError(t, err)
rollappXUser, err := rollappX.CreateUser("rolx1")
require.NoError(t, err)

err = hub.NewClient("https://" + hub.RPCAddr)
require.NoError(t, err)

err = rollappX.NewClient("https://" + rollappX.RPCAddr)
require.NoError(t, err)

dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym")
rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx")

// Wait for blocks
testutil.WaitForBlocks(ctx, 5, hub)

// Get the IBC denom
rollappXTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappX, rollappXUser.Denom)
rollappXIBCDenom := transfertypes.ParseDenomTrace(rollappXTokenDenom).IBCDenom()

dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr)
require.NoError(t, err)
fmt.Println("hub original balance: ", dymensionOrigBal, dymensionUser.Denom)

rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr)
require.NoError(t, err)
fmt.Println("rollapp x original balance: ", rollappXOrigBal, rollappXUser.Denom)

erc20_OrigBal, err := GetERC20Balance(ctx, erc20IBCDenom, rollappX.GrpcAddr)
require.NoError(t, err)
fmt.Println("rol x user balance of denom send from dym: ", erc20_OrigBal)

// Compose an IBC transfer and send from rollapp -> hub
transferData := ibc.WalletData{
Address: dymensionUser.Address,
Denom: rollappXUser.Denom,
Amount: transferAmount,
}

var options ibc.TransferOptions
_, err = cosmos.SendIBCTransfer(rollappX, channelIDRollappXDym, rollappXUser.Address, transferData, rolxFee, options)
require.NoError(t, err)
// Amount should not be received by hub yet
testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, sdkmath.NewInt(0))

// Check the state info status every 5 seconds to ensure it is always pending
// Run QueryRollappState in parallel with WaitForBlocks
var wg sync.WaitGroup
wg.Add(2)

// Channel to capture errors
errChan := make(chan error, 1)

// Goroutine to query Rollapp state every 5 seconds
go func() {
defer wg.Done()
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
timeout := time.After(400 * time.Second) // Set a timeout for the whole check

for {
select {
case <-ticker.C:
res, err := hub.QueryRollappState(rollappX.ChainID, false)
if err != nil {
errChan <- err
return
}
if res.StateInfo.Status != "PENDING" {
errChan <- fmt.Errorf("unexpected state: %s", res.StateInfo.Status)
return
}
case <-timeout:
return
}
}
}()

// Goroutine to wait for blocks
go func() {
defer wg.Done()
testutil.WaitForBlocks(ctx, disputed_period_plus_batch_submit_blocks, hub)
fmt.Println("wait for blocks done")
}()

// Wait for both goroutines to complete
wg.Wait()
close(errChan)

// Check for errors from goroutines
if err := <-errChan; err != nil {
require.NoError(t, err)
}

// TODO: sub bridging fee on new version
testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, transferAmount)

}

// TestDelayackRollappToHub_Live test delayack, rollapp token transfer should only be recieved on the hub upon rollapp finalized state (assume no elBC packet, i.e no memo)
func TestDelayackRollappToHubRolX_Live(t *testing.T) {
if testing.Short() {
t.Skip()
}
ctx := context.Background()

hub := cosmos.CosmosChain{
RPCAddr: "rpc-blumbus.mzonder.com:443",
GrpcAddr: "grpc-blumbus.mzonder.com:9090",
ChainID: "blumbus_111-1",
Bin: "dymd",
GasPrices: "1000adym",
GasAdjustment: "1.1",
Denom: "adym",
}

rollappX := cosmos.CosmosChain{
RPCAddr: "rpc.rolxtwo.evm.ra.blumbus.noisnemyd.xyz:443",
GrpcAddr: "3.123.185.77:9090",
ChainID: "rolx_100004-1",
Bin: "rollapp-evm",
GasPrices: "0.0arolx",
GasAdjustment: "1.1",
Denom: "arolx",
}

dymensionUser, err := hub.CreateUser("dym1")
require.NoError(t, err)
rollappXUser, err := rollappX.CreateUser("rolx1")
require.NoError(t, err)

err = hub.NewClient("https://" + hub.RPCAddr)
require.NoError(t, err)

err = rollappX.NewClient("https://" + rollappX.RPCAddr)
require.NoError(t, err)

dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym")
rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx")

// Wait for blocks
testutil.WaitForBlocks(ctx, 5, hub)

// Get the IBC denom
rollappXTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappX, rollappXUser.Denom)
rollappXIBCDenom := transfertypes.ParseDenomTrace(rollappXTokenDenom).IBCDenom()

dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr)
require.NoError(t, err)
fmt.Println("hub original balance: ", dymensionOrigBal, dymensionUser.Denom)

rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr)
require.NoError(t, err)
fmt.Println("rollapp x original balance: ", rollappXOrigBal, rollappXUser.Denom)

erc20_OrigBal, err := GetERC20Balance(ctx, erc20IBCDenom, rollappX.GrpcAddr)
require.NoError(t, err)
fmt.Println("rol x user balance of denom send from dym: ", erc20_OrigBal)

// Compose an IBC transfer and send from rollapp -> hub
transferData := ibc.WalletData{
Address: dymensionUser.Address,
Denom: rollappXUser.Denom,
Amount: transferAmount,
}

var options ibc.TransferOptions
_, err = cosmos.SendIBCTransfer(rollappX, channelIDRollappXDym, rollappXUser.Address, transferData, rolxFee, options)
require.NoError(t, err)
// Amount should not be received by hub yet
testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, sdkmath.NewInt(0))

rollappXHeight, err := rollappX.Height(ctx)
require.NoError(t, err)
fmt.Println(rollappXHeight)
// wait until the packet is finalized on Rollapp 1
isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 1000)
require.NoError(t, err)
require.True(t, isFinalized)

fmt.Println("rollapp x ibc denom: ", rollappXIBCDenom, dymensionUser)
// TODO: sub bridging fee on new version
testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, transferAmount)
}
Loading
Loading