From 045b4fa397dc4f2645c593cb94a4f16082b37081 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Fri, 2 Aug 2024 14:45:51 +0700 Subject: [PATCH 1/7] bump e2e-live-testing --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 68ae669c..3d0df375 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ replace ( ) require ( - github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 + github.com/decentrio/e2e-testing-live v0.0.0-20240802071159-64acaa57d39b github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4 github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240717194206-54c0fca5fada ) diff --git a/go.sum b/go.sum index de98de44..692ab820 100644 --- a/go.sum +++ b/go.sum @@ -382,8 +382,8 @@ 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/e2e-testing-live v0.0.0-20240802071159-64acaa57d39b h1:TzZuUmWEhSkcQwRFW9US7EK4G8Br0tY6d3tQtJ7IWFA= +github.com/decentrio/e2e-testing-live v0.0.0-20240802071159-64acaa57d39b/go.mod h1:qLIf3XX6bQsQlmVqhbNOiLc/ONeA0NDiPmpsrljJkXc= github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4 h1:ZZFkAHWyK8KEF/tsyNIQ3xIhQHr2hAFyz0KE4iJM1q0= github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4/go.mod h1:NwTceYVxAaIZI65g/PdibVnGRMXuZzqzhDIkWsqJaQM= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= From f1b4bf98521d53800003424aba76423557f03c93 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Fri, 2 Aug 2024 15:31:21 +0700 Subject: [PATCH 2/7] broadcast-mode async --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3d0df375..a7ea83e8 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ replace ( ) require ( - github.com/decentrio/e2e-testing-live v0.0.0-20240802071159-64acaa57d39b + github.com/decentrio/e2e-testing-live v0.0.0-20240802082952-038b1a1c41b5 github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4 github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240717194206-54c0fca5fada ) diff --git a/go.sum b/go.sum index 692ab820..97f207f7 100644 --- a/go.sum +++ b/go.sum @@ -382,8 +382,8 @@ 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-20240802071159-64acaa57d39b h1:TzZuUmWEhSkcQwRFW9US7EK4G8Br0tY6d3tQtJ7IWFA= -github.com/decentrio/e2e-testing-live v0.0.0-20240802071159-64acaa57d39b/go.mod h1:qLIf3XX6bQsQlmVqhbNOiLc/ONeA0NDiPmpsrljJkXc= +github.com/decentrio/e2e-testing-live v0.0.0-20240802082952-038b1a1c41b5 h1:vcjhGuZ7EfzPI4YxllABeeYoMFlAmfc7UhF95ChxShg= +github.com/decentrio/e2e-testing-live v0.0.0-20240802082952-038b1a1c41b5/go.mod h1:qLIf3XX6bQsQlmVqhbNOiLc/ONeA0NDiPmpsrljJkXc= github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4 h1:ZZFkAHWyK8KEF/tsyNIQ3xIhQHr2hAFyz0KE4iJM1q0= github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4/go.mod h1:NwTceYVxAaIZI65g/PdibVnGRMXuZzqzhDIkWsqJaQM= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= From a77530b5e9b773ee1073fa0ebd71b9e785450a0b Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Sat, 3 Aug 2024 21:57:09 +0700 Subject: [PATCH 3/7] refactor --- Makefile | 60 +-- live-tests/delayed_test.go | 229 +++++++++++ live-tests/eibc_3rd_token_test.go | 54 +-- live-tests/eibc_ack_error_test.go | 29 +- live-tests/eibc_demand_order_ignored_test.go | 2 +- live-tests/eibc_fulfillment_test.go | 22 +- live-tests/eibc_invalid_fee_test.go | 176 ++++++++- live-tests/eibc_no_memo_test.go | 2 +- live-tests/eibc_pfm_test.go | 2 +- live-tests/eibc_timeout_test.go | 107 +++-- live-tests/ibc_transfer_test.go | 396 ++----------------- 11 files changed, 559 insertions(+), 520 deletions(-) create mode 100644 live-tests/delayed_test.go diff --git a/Makefile b/Makefile index 363b926c..bed5521f 100644 --- a/Makefile +++ b/Makefile @@ -530,42 +530,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=25m -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 . \ No newline at end of file diff --git a/live-tests/delayed_test.go b/live-tests/delayed_test.go new file mode 100644 index 00000000..520b03e0 --- /dev/null +++ b/live-tests/delayed_test.go @@ -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 + 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(500 * 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 + 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, 500) + 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) +} diff --git a/live-tests/eibc_3rd_token_test.go b/live-tests/eibc_3rd_token_test.go index 1fdae486..784c1aca 100644 --- a/live-tests/eibc_3rd_token_test.go +++ b/live-tests/eibc_3rd_token_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_3rd_Token_Live(t *testing.T) { +func TestEIBC_3rd_Token_RolY_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -37,15 +37,6 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { GasAdjustment: "1.1", Denom: "utia", } - 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", - } rollappY := cosmos.CosmosChain{ RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", GrpcAddr: "18.153.150.111:9090", @@ -64,8 +55,7 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { // create market maker marketMaker, err := hub.CreateUser("dym2") require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) + rollappYUser, err := rollappY.CreateUser("roly1") require.NoError(t, err) @@ -73,8 +63,6 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { require.NoError(t, err) err = mocha.NewClient("https://" + mocha.RPCAddr) require.NoError(t, err) - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) err = rollappY.NewClient("https://" + rollappY.RPCAddr) require.NoError(t, err) @@ -83,15 +71,12 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { testutil.WaitForBlocks(ctx, 2, hub) marketMaker.GetFaucet("http://18.184.170.181:3000/api/get-dym") mochaUser.GetFaucet("http://18.184.170.181:3000/api/get-tia") - rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx") rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) // Get the IBC denom - // rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) - // rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() mochaTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymMocha, mocha.Denom) mochaIBCDenom := transfertypes.ParseDenomTrace(mochaTokenDenom).IBCDenom() @@ -105,9 +90,6 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { mmOrigBal, err := marketMaker.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) fmt.Println(mmOrigBal) - rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappXOrigBal) rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) require.NoError(t, err) fmt.Println(rollappYOrigBal) @@ -125,6 +107,7 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(mocha, channelIDMochaDym, mochaUser.Address, transferData, mochaFee, options) + require.NoError(t, err) t.Log("mochaIBCDenom:", mochaIBCDenom) @@ -138,6 +121,7 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(hub, channelIDDymRollappY, dymensionUser.Address, transferData, dymFee, options) + require.NoError(t, err) testutil.WaitForBlocks(ctx, 10, hub) @@ -212,7 +196,7 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { require.True(t, balance.Equal(transferAmountMM.Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountMM.Sub(eibcFee), balance)) } -func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { +func TestEIBC_3rd_Token_Timeout_RolY_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -235,15 +219,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { GasAdjustment: "1.1", Denom: "utia", } - 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", - } rollappY := cosmos.CosmosChain{ RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", GrpcAddr: "18.153.150.111:9090", @@ -262,8 +237,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { // create market maker marketMaker, err := hub.CreateUser("dym2") require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) rollappYUser, err := rollappY.CreateUser("roly1") require.NoError(t, err) @@ -271,8 +244,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { require.NoError(t, err) err = mocha.NewClient("https://" + mocha.RPCAddr) require.NoError(t, err) - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) err = rollappY.NewClient("https://" + rollappY.RPCAddr) require.NoError(t, err) @@ -283,8 +254,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { testutil.WaitForBlocks(ctx, 2, hub) mochaUser.GetFaucet("http://18.184.170.181:3000/api/get-tia") testutil.WaitForBlocks(ctx, 2, hub) - rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx") - testutil.WaitForBlocks(ctx, 2, hub) rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks @@ -306,9 +275,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { mmOrigBal, err := marketMaker.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) fmt.Println(mmOrigBal) - rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappXOrigBal) rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) require.NoError(t, err) fmt.Println(rollappYOrigBal) @@ -331,6 +297,7 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(mocha, channelIDMochaDym, mochaUser.Address, transferData, mochaFee, ibc.TransferOptions{}) + require.NoError(t, err) t.Log("mochaIBCDenom:", mochaIBCDenom) @@ -340,6 +307,7 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(mocha, channelIDMochaDym, mochaUser.Address, transferData, mochaFee, ibc.TransferOptions{}) + require.NoError(t, err) testutil.WaitForBlocks(ctx, 10, hub) @@ -351,10 +319,11 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(hub, channelIDDymRollappY, dymensionUser.Address, transferData, dymFee, options) + require.NoError(t, err) - rollappXHeight, err := rollappX.Height(ctx) + rollappYHeight, err := rollappY.Height(ctx) require.NoError(t, err) - fmt.Println(rollappXHeight) + fmt.Println(rollappYHeight) testutil.AssertBalance(t, ctx, rollappYUser, mochaIBCDenom, rollappY.GrpcAddr, math.ZeroInt()) testutil.AssertBalance(t, ctx, rollappYUser, secondHopIBCDenom, rollappY.GrpcAddr, math.ZeroInt()) @@ -378,10 +347,11 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { } } - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 500) require.NoError(t, err) require.True(t, isFinalized) balance, err := marketMaker.GetBalance(ctx, mochaIBCDenom, hub.GrpcAddr) + require.NoError(t, err) fmt.Println(balance) } diff --git a/live-tests/eibc_ack_error_test.go b/live-tests/eibc_ack_error_test.go index 63f17fa8..b0216278 100644 --- a/live-tests/eibc_ack_error_test.go +++ b/live-tests/eibc_ack_error_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { +func TestEIBC_AckError_Dym_RolY_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -43,16 +43,6 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { Denom: "utia", } - 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", - } - rollappY := cosmos.CosmosChain{ RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", GrpcAddr: "18.153.150.111:9090", @@ -67,8 +57,6 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { require.NoError(t, err) mochaUser, err := mocha.CreateUser("mocha1") require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) rollappYUser, err := rollappY.CreateUser("roly1") require.NoError(t, err) @@ -78,15 +66,11 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { err = mocha.NewClient("https://" + mocha.RPCAddr) require.NoError(t, err) - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.RPCAddr) require.NoError(t, err) dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym") mochaUser.GetFaucet("http://18.184.170.181:3000/api/get-tia") - rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx") rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks @@ -104,10 +88,6 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { require.NoError(t, err) fmt.Println(dymensionOrigBal) - rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappXOrigBal) - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) require.NoError(t, err) fmt.Println(rollappYOrigBal) @@ -116,11 +96,6 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { require.NoError(t, err) fmt.Println(mochaOrigBal) - // Get ERC20 balance - erc20_OrigBal, err := GetERC20Balance(ctx, erc20IBCDenom, rollappX.GrpcAddr) - require.NoError(t, err) - fmt.Println(erc20_OrigBal) - // Use mocha to trigger ack error because rollapp isn't registered with mocha token var options ibc.TransferOptions @@ -197,7 +172,7 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) // fund was return to roly user and dym user balance stay the same - testutil.AssertBalance(t, ctx, rollappYUser, mochaRollappYIBCDenom, rollappX.GrpcAddr, transferAmountMM) + testutil.AssertBalance(t, ctx, rollappYUser, mochaRollappYIBCDenom, rollappY.GrpcAddr, transferAmountMM) testutil.AssertBalance(t, ctx, dymensionUser, mochaIBCDenom, hub.GrpcAddr, transferAmountMM) } diff --git a/live-tests/eibc_demand_order_ignored_test.go b/live-tests/eibc_demand_order_ignored_test.go index d564a0d1..a3bc079d 100644 --- a/live-tests/eibc_demand_order_ignored_test.go +++ b/live-tests/eibc_demand_order_ignored_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_Demand_Order_Ignored_Live(t *testing.T) { +func TestEIBC_Demand_Order_Ignored_RolX_Live(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/live-tests/eibc_fulfillment_test.go b/live-tests/eibc_fulfillment_test.go index 2e9acb1e..dc27795d 100644 --- a/live-tests/eibc_fulfillment_test.go +++ b/live-tests/eibc_fulfillment_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBCFulfill_Live(t *testing.T) { +func TestEIBCFulfillRolX_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -37,15 +37,6 @@ func TestEIBCFulfill_Live(t *testing.T) { GasAdjustment: "1.1", Denom: "arolx", } - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } dymensionUser, err := hub.CreateUser("dym1") require.NoError(t, err) @@ -54,22 +45,16 @@ func TestEIBCFulfill_Live(t *testing.T) { require.NoError(t, err) rollappXUser, err := rollappX.CreateUser("rolx1") require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) err = hub.NewClient("https://" + hub.RPCAddr) require.NoError(t, err) err = rollappX.NewClient("https://" + rollappX.RPCAddr) require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.RPCAddr) - require.NoError(t, err) dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym") testutil.WaitForBlocks(ctx, 2, hub) marketMaker.GetFaucet("http://18.184.170.181:3000/api/get-dym") testutil.WaitForBlocks(ctx, 2, hub) rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx") - testutil.WaitForBlocks(ctx, 2, hub) - rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) @@ -87,9 +72,6 @@ func TestEIBCFulfill_Live(t *testing.T) { rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) require.NoError(t, err) fmt.Println(rollappXOrigBal) - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappYOrigBal) transferAmountMM := math.NewInt(100000000000) // Compose an IBC transfer and send from rollappx -> marketmaker @@ -111,7 +93,7 @@ func TestEIBCFulfill_Live(t *testing.T) { require.NoError(t, err) fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) require.NoError(t, err) require.True(t, isFinalized) diff --git a/live-tests/eibc_invalid_fee_test.go b/live-tests/eibc_invalid_fee_test.go index 9deda63b..760aae6a 100644 --- a/live-tests/eibc_invalid_fee_test.go +++ b/live-tests/eibc_invalid_fee_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "cosmossdk.io/math" + 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" @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_Invalid_Fee_Live(t *testing.T) { +func TestEIBC_Invalid_Fee_RolX_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -70,7 +70,7 @@ func TestEIBC_Invalid_Fee_Live(t *testing.T) { var options ibc.TransferOptions - multiplier := math.NewInt(10) + multiplier := sdkmath.NewInt(10) eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 options.Memo = BuildEIbcMemo(eibcFee) @@ -114,9 +114,177 @@ func TestEIBC_Invalid_Fee_Live(t *testing.T) { require.True(t, len(eibcEvents) == 1) // verify 1 EIBC event was registered on the hub // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) require.NoError(t, err) require.True(t, isFinalized) testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, transferAmount) } + +func TestEIBCFeeBgtAmountRolX_Live(t *testing.T) { + if testing.Short() { + t.Skip() + } + ctx := context.Background() + + // Configuration for live network + 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) + + 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) + + var options ibc.TransferOptions + + // create eIBC memo with fee 2 times the transfer amount + multiplier := sdkmath.NewInt(2) + eibcFee := transferAmount.Mul(multiplier) // example transfer amount * 0.1 + + // Compose an IBC transfer and send from rollappX -> hub + // Send IBC transfer with corrupted memo 1 + options.Memo = BuildEIbcMemo(eibcFee) + transferData := ibc.WalletData{ + Address: dymensionUser.Address, + Denom: rollappX.Denom, + Amount: transferAmount, + } + _, err = cosmos.SendIBCTransfer(rollappX, channelIDDymRollappX, rollappXUser.Address, transferData, rolxFee, options) + require.Error(t, err) + + // wait until the packet is finalized on Rollapp 1 + rollappXHeight, err := rollappX.Height(ctx) + require.NoError(t, err) + fmt.Println(rollappXHeight) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) + require.NoError(t, err) + require.True(t, isFinalized) + + // Verify that the amount is returned to the sender + testutil.AssertBalance(t, ctx, dymensionUser, dymensionUser.Denom, hub.GrpcAddr, dymensionOrigBal) + // Verify that the amount is not received by the receiver + testutil.AssertBalance(t, ctx, rollappXUser, rollappX.Denom, rollappX.GrpcAddr, rollappXOrigBal) +} + +func TestEIBCFeeBgtAmountRolY_Live(t *testing.T) { + if testing.Short() { + t.Skip() + } + ctx := context.Background() + + // Configuration for live network + 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", + } + + rollappY := cosmos.CosmosChain{ + RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", + GrpcAddr: "18.153.150.111:9090", + ChainID: "rollappy_700002-1", + Bin: "rollapp-wasm", + GasPrices: "0.0aroly", + GasAdjustment: "1.1", + Denom: "aroly", + } + + dymensionUser, err := hub.CreateUser("dym1") + require.NoError(t, err) + rollappYUser, err := rollappY.CreateUser("roly1") + require.NoError(t, err) + + err = hub.NewClient("https://" + hub.RPCAddr) + require.NoError(t, err) + + err = rollappY.NewClient("https://" + rollappY.RPCAddr) + require.NoError(t, err) + + dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym") + rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") + + // Wait for blocks + testutil.WaitForBlocks(ctx, 5, hub) + + dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) + require.NoError(t, err) + fmt.Println("hub original balance: ", dymensionOrigBal, dymensionUser.Denom) + + rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) + require.NoError(t, err) + fmt.Println("rollapp y original balance: ", rollappYOrigBal, rollappYUser.Denom) + + var options ibc.TransferOptions + + // create eIBC memo with fee 2 times the transfer amount + multiplier := sdkmath.NewInt(2) + eibcFee := transferAmount.Mul(multiplier) // example transfer amount * 0.1 + + // Send IBC transfer with corrupted memo 1 + options.Memo = BuildEIbcMemo(eibcFee) + + // Compose in IBC transfer and send from rollappY -> hub + transferData := ibc.WalletData{ + Address: dymensionUser.Address, + Denom: rollappY.Denom, + Amount: transferAmount, + } + _, err = cosmos.SendIBCTransfer(rollappY, channelIDDymRollappY, rollappYUser.Address, transferData, rolyFee, options) + require.Error(t, err) + + // wait until the packet is finalized on Rollapp 1 + rollappYHeight, err := rollappY.Height(ctx) + require.NoError(t, err) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 500) + require.NoError(t, err) + require.True(t, isFinalized) + + // Verify that the amount is returned to the sender + testutil.AssertBalance(t, ctx, dymensionUser, dymensionUser.Denom, hub.GrpcAddr, dymensionOrigBal) +} diff --git a/live-tests/eibc_no_memo_test.go b/live-tests/eibc_no_memo_test.go index 42fed762..63da88e0 100644 --- a/live-tests/eibc_no_memo_test.go +++ b/live-tests/eibc_no_memo_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_No_Memo_Live(t *testing.T) { +func TestEIBC_No_Memo_RolX_Live(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/live-tests/eibc_pfm_test.go b/live-tests/eibc_pfm_test.go index 9232527b..6989da99 100644 --- a/live-tests/eibc_pfm_test.go +++ b/live-tests/eibc_pfm_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBCPFM_Live(t *testing.T) { +func TestEIBCPFMRolX_Live(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/live-tests/eibc_timeout_test.go b/live-tests/eibc_timeout_test.go index b4f241f6..a93539e0 100644 --- a/live-tests/eibc_timeout_test.go +++ b/live-tests/eibc_timeout_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBCTimeout_Live(t *testing.T) { +func TestEIBCTimeoutRolX_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -40,22 +40,10 @@ func TestEIBCTimeout_Live(t *testing.T) { Denom: "arolx", } - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } - dymensionUser, err := hub.CreateUser("dym1") require.NoError(t, err) rollappXUser, err := rollappX.CreateUser("rolx1") require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) err = hub.NewClient("https://" + hub.RPCAddr) require.NoError(t, err) @@ -63,12 +51,8 @@ func TestEIBCTimeout_Live(t *testing.T) { err = rollappX.NewClient("https://" + rollappX.RPCAddr) require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.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") - rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) @@ -77,12 +61,6 @@ func TestEIBCTimeout_Live(t *testing.T) { rollappXTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappX, rollappXUser.Denom) rollappXIBCDenom := transfertypes.ParseDenomTrace(rollappXTokenDenom).IBCDenom() - rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) - rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() - - // hubTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDRollappXDym, dymensionUser.Denom) - // hubIBCDenom := transfertypes.ParseDenomTrace(hubTokenDenom).IBCDenom() - dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) fmt.Println(dymensionOrigBal) @@ -91,10 +69,6 @@ func TestEIBCTimeout_Live(t *testing.T) { require.NoError(t, err) fmt.Println(rollappXOrigBal) - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappYOrigBal) - height, err := rollappX.Height(ctx) require.NoError(t, err) erc20_OrigBal, err := rollappXUser.GetERC20Balance(rollappX.JsonRPCAddr, erc20Contract, int64(height)) @@ -142,7 +116,7 @@ func TestEIBCTimeout_Live(t *testing.T) { fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) require.NoError(t, err) require.True(t, isFinalized) @@ -153,9 +127,78 @@ func TestEIBCTimeout_Live(t *testing.T) { fmt.Println(erc20_Bal) require.Equal(t, erc20_OrigBal, erc20_Bal) testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, math.ZeroInt()) +} + +func TestEIBCTimeoutRolY_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", + } + + rollappY := cosmos.CosmosChain{ + RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", + GrpcAddr: "18.153.150.111:9090", + ChainID: "rollappy_700002-1", + Bin: "rollapp-wasm", + GasPrices: "0.0aroly", + GasAdjustment: "1.1", + Denom: "aroly", + } + + dymensionUser, err := hub.CreateUser("dym1") + require.NoError(t, err) + rollappYUser, err := rollappY.CreateUser("roly1") + require.NoError(t, err) + + err = hub.NewClient("https://" + hub.RPCAddr) + require.NoError(t, err) + + err = rollappY.NewClient("https://" + rollappY.RPCAddr) + require.NoError(t, err) + + dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym") + rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") + + // Wait for blocks + testutil.WaitForBlocks(ctx, 5, hub) + + // Get the IBC denom + rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) + rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() + + dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) + require.NoError(t, err) + fmt.Println(dymensionOrigBal) + + rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) + require.NoError(t, err) + fmt.Println(rollappYOrigBal) + + height, err := rollappY.Height(ctx) + require.NoError(t, err) + erc20_OrigBal, err := rollappYUser.GetERC20Balance(rollappY.JsonRPCAddr, erc20Contract, int64(height)) + require.NoError(t, err) + fmt.Println(erc20_OrigBal) + + // Set a short timeout for IBC transfer + options := ibc.TransferOptions{ + Timeout: &ibc.IBCTimeout{ + NanoSeconds: 1000000, // 1 ms - this will cause the transfer to timeout before it is picked by a relayer + }, + } // Compose an IBC transfer and send from dymension -> rollapp - transferData = ibc.WalletData{ + transferData := ibc.WalletData{ Address: rollappYUser.Address, Denom: dymensionUser.Denom, Amount: transferAmount, @@ -176,18 +219,18 @@ func TestEIBCTimeout_Live(t *testing.T) { cosmos.SendIBCTransfer(rollappY, channelIDRollappYDym, rollappYUser.Address, transferData, rolyFee, options) require.NoError(t, err) - rollappYHeight, err := rollappX.Height(ctx) + rollappYHeight, err := rollappY.Height(ctx) require.NoError(t, err) fmt.Println(rollappYHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err = hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 500) require.NoError(t, err) require.True(t, isFinalized) height, err = rollappY.Height(ctx) require.NoError(t, err) - erc20_Bal, err = rollappYUser.GetERC20Balance(rollappY.JsonRPCAddr, erc20Contract, int64(height)) + erc20_Bal, err := rollappYUser.GetERC20Balance(rollappY.JsonRPCAddr, erc20Contract, int64(height)) require.NoError(t, err) fmt.Println(erc20_Bal) require.Equal(t, erc20_OrigBal, erc20_Bal) diff --git a/live-tests/ibc_transfer_test.go b/live-tests/ibc_transfer_test.go index ef759f0c..5f08e223 100644 --- a/live-tests/ibc_transfer_test.go +++ b/live-tests/ibc_transfer_test.go @@ -4,12 +4,9 @@ import ( "context" "fmt" "math/big" - "sync" "testing" - "time" "cosmossdk.io/math" - 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" @@ -17,7 +14,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestIBCTransfer_Live(t *testing.T) { +func TestIBCTransferRolX_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -44,22 +41,10 @@ func TestIBCTransfer_Live(t *testing.T) { Denom: "arolx", } - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } - dymensionUser, err := hub.CreateUser("dym1") require.NoError(t, err) rollappXUser, err := rollappX.CreateUser("rolx1") require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) err = hub.NewClient("https://" + hub.RPCAddr) require.NoError(t, err) @@ -67,12 +52,8 @@ func TestIBCTransfer_Live(t *testing.T) { err = rollappX.NewClient("https://" + rollappX.RPCAddr) require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.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") - rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) @@ -81,12 +62,6 @@ func TestIBCTransfer_Live(t *testing.T) { rollappXTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappX, rollappXUser.Denom) rollappXIBCDenom := transfertypes.ParseDenomTrace(rollappXTokenDenom).IBCDenom() - rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) - rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() - - hubTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDRollappXDym, dymensionUser.Denom) - hubIBCDenom := transfertypes.ParseDenomTrace(hubTokenDenom).IBCDenom() - dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) fmt.Println(dymensionOrigBal) @@ -95,10 +70,6 @@ func TestIBCTransfer_Live(t *testing.T) { require.NoError(t, err) fmt.Println(rollappXOrigBal) - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappYOrigBal) - height, err := rollappX.Height(ctx) require.NoError(t, err) erc20_OrigBal, err := rollappXUser.GetERC20Balance(rollappX.JsonRPCAddr, erc20Contract, int64(height)) @@ -148,49 +119,14 @@ func TestIBCTransfer_Live(t *testing.T) { fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) - require.NoError(t, err) - require.True(t, isFinalized) - - // Compose an IBC transfer and send from hub -> rollappY - transferData = ibc.WalletData{ - Address: rollappYUser.Address, - Denom: dymensionUser.Denom, - Amount: transferAmount, - } - - cosmos.SendIBCTransfer(hub, channelIDDymRollappY, dymensionUser.Address, transferData, dymFee, ibc.TransferOptions{}) - require.NoError(t, err) - - testutil.WaitForBlocks(ctx, 3, hub) - - // Compose an IBC transfer and send from rollappY -> hub - transferData = ibc.WalletData{ - Address: dymensionUser.Address, - Denom: rollappYUser.Denom, - Amount: transferAmount, - } - - cosmos.SendIBCTransfer(rollappY, channelIDRollappYDym, rollappYUser.Address, transferData, rolyFee, options) - require.NoError(t, err) - - rollappYHeight, err := rollappY.Height(ctx) - require.NoError(t, err) - - fmt.Println(rollappYHeight) - // wait until the packet is finalized on Rollapp 1 - isFinalized, err = hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) require.NoError(t, err) require.True(t, isFinalized) testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, transferAmount.Sub(eibcFee)) - // rolly currently don't support eibc - testutil.AssertBalance(t, ctx, rollappYUser, hubIBCDenom, rollappY.GrpcAddr, transferAmount) - testutil.AssertBalance(t, ctx, dymensionUser, rollappYIBCDenom, hub.GrpcAddr, transferAmount) } -// 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 TestDelayackRollappToHubNoFinalized_Live(t *testing.T) { +func TestIBCTransferRolY_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -206,16 +142,6 @@ func TestDelayackRollappToHubNoFinalized_Live(t *testing.T) { 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", - } - rollappY := cosmos.CosmosChain{ RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", GrpcAddr: "18.153.150.111:9090", @@ -228,336 +154,74 @@ func TestDelayackRollappToHubNoFinalized_Live(t *testing.T) { dymensionUser, err := hub.CreateUser("dym1") require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) rollappYUser, err := rollappY.CreateUser("roly1") require.NoError(t, err) err = hub.NewClient("https://" + hub.RPCAddr) require.NoError(t, err) - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.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") rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) - // Get the IBC denom - rollappXTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappX, rollappXUser.Denom) - rollappXIBCDenom := transfertypes.ParseDenomTrace(rollappXTokenDenom).IBCDenom() + rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) + rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() - dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) - require.NoError(t, err) - fmt.Println("hub original balance: ", dymensionOrigBal, dymensionUser.Denom) + hubTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDRollappXDym, dymensionUser.Denom) + hubIBCDenom := transfertypes.ParseDenomTrace(hubTokenDenom).IBCDenom() - rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) + dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) - fmt.Println("rollapp x original balance: ", rollappXOrigBal, rollappXUser.Denom) + fmt.Println(dymensionOrigBal) rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) require.NoError(t, err) - fmt.Println("rollapp y original balance: ", rollappYOrigBal, rollappYUser.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) + fmt.Println(rollappYOrigBal) - // Compose an IBC transfer and send from rollapp -> hub + // Compose an IBC transfer and send from hub -> rollappY transferData := ibc.WalletData{ - Address: dymensionUser.Address, - Denom: rollappXUser.Denom, + Address: rollappYUser.Address, + Denom: dymensionUser.Denom, Amount: transferAmount, } - var options ibc.TransferOptions - 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 TestDelayackRollappToHub_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", - } - - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } - - dymensionUser, err := hub.CreateUser("dym1") - require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) - - err = hub.NewClient("https://" + hub.RPCAddr) - require.NoError(t, err) - - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) - - err = rollappY.NewClient("https://" + rollappY.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") - rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") - - // 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) - - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) + cosmos.SendIBCTransfer(hub, channelIDDymRollappY, dymensionUser.Address, transferData, dymFee, ibc.TransferOptions{}) require.NoError(t, err) - fmt.Println("rollapp y original balance: ", rollappYOrigBal, rollappYUser.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) + testutil.WaitForBlocks(ctx, 3, hub) - // Compose an IBC transfer and send from rollapp -> hub - transferData := ibc.WalletData{ + // Compose an IBC transfer and send from rollappY -> hub + transferData = ibc.WalletData{ Address: dymensionUser.Address, - Denom: rollappXUser.Denom, + Denom: rollappYUser.Denom, Amount: transferAmount, } - var options ibc.TransferOptions - 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, 400) - 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) -} - -func TestEIBCFeeBgtAmount_Live(t *testing.T) { - if testing.Short() { - t.Skip() - } - ctx := context.Background() - - // Configuration for live network - 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", - } - - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } - - dymensionUser, err := hub.CreateUser("dym1") - require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) - - err = hub.NewClient("https://" + hub.RPCAddr) - require.NoError(t, err) - - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) - - err = rollappY.NewClient("https://" + rollappY.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") - // rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") - - // Wait for blocks - testutil.WaitForBlocks(ctx, 5, hub) - - 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) - - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) - require.NoError(t, err) - fmt.Println("rollapp y original balance: ", rollappYOrigBal, rollappYUser.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) + multiplier := math.NewInt(10) + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 var options ibc.TransferOptions - - // create eIBC memo with fee 2 times the transfer amount - multiplier := sdkmath.NewInt(2) - eibcFee := transferAmount.Mul(multiplier) // example transfer amount * 0.1 - - // Compose an IBC transfer and send from rollappX -> hub - // Send IBC transfer with corrupted memo 1 + // set eIBC specific memo options.Memo = BuildEIbcMemo(eibcFee) - transferData := ibc.WalletData{ - Address: dymensionUser.Address, - Denom: rollappX.Denom, - Amount: transferAmount, - } - _, err = cosmos.SendIBCTransfer(rollappX, channelIDDymRollappX, rollappXUser.Address, transferData, rolxFee, options) - require.Error(t, err) - // Compose in IBC transfer and send from rollappY -> hub - transferData = ibc.WalletData{ - Address: dymensionUser.Address, - Denom: rollappY.Denom, - Amount: transferAmount, - } - _, err = cosmos.SendIBCTransfer(rollappY, channelIDDymRollappY, rollappYUser.Address, transferData, rolyFee, options) - require.Error(t, err) + cosmos.SendIBCTransfer(rollappY, channelIDRollappYDym, rollappYUser.Address, transferData, rolyFee, options) + require.NoError(t, err) - // wait until the packet is finalized on Rollapp 1 - rollappXHeight, err := rollappX.Height(ctx) rollappYHeight, err := rollappY.Height(ctx) require.NoError(t, err) - fmt.Println(rollappXHeight) - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) - require.NoError(t, err) - require.True(t, isFinalized) - isFinalized, err = hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 400) + + fmt.Println(rollappYHeight) + // wait until the packet is finalized on Rollapp 1 + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 500) require.NoError(t, err) require.True(t, isFinalized) - // Verify that the amount is returned to the sender - testutil.AssertBalance(t, ctx, dymensionUser, dymensionUser.Denom, hub.GrpcAddr, dymensionOrigBal) - // Verify that the amount is not received by the receiver - testutil.AssertBalance(t, ctx, rollappXUser, rollappX.Denom, rollappX.GrpcAddr, rollappXOrigBal) + // rolly currently don't support eibc + testutil.AssertBalance(t, ctx, rollappYUser, hubIBCDenom, rollappY.GrpcAddr, transferAmount) + testutil.AssertBalance(t, ctx, dymensionUser, rollappYIBCDenom, hub.GrpcAddr, transferAmount) } From 263061b7e9161df0cbdd43a1aee65b830723b6da Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Sat, 3 Aug 2024 21:57:09 +0700 Subject: [PATCH 4/7] fix eibc_invalid_fee test --- Makefile | 60 +-- live-tests/delayed_test.go | 229 +++++++++++ live-tests/eibc_3rd_token_test.go | 54 +-- live-tests/eibc_ack_error_test.go | 29 +- live-tests/eibc_demand_order_ignored_test.go | 2 +- live-tests/eibc_fulfillment_test.go | 22 +- live-tests/eibc_invalid_fee_test.go | 178 ++++++++- live-tests/eibc_no_memo_test.go | 2 +- live-tests/eibc_pfm_test.go | 2 +- live-tests/eibc_timeout_test.go | 107 +++-- live-tests/ibc_transfer_test.go | 396 ++----------------- 11 files changed, 560 insertions(+), 521 deletions(-) create mode 100644 live-tests/delayed_test.go diff --git a/Makefile b/Makefile index 363b926c..bed5521f 100644 --- a/Makefile +++ b/Makefile @@ -530,42 +530,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=25m -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 . \ No newline at end of file diff --git a/live-tests/delayed_test.go b/live-tests/delayed_test.go new file mode 100644 index 00000000..520b03e0 --- /dev/null +++ b/live-tests/delayed_test.go @@ -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 + 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(500 * 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 + 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, 500) + 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) +} diff --git a/live-tests/eibc_3rd_token_test.go b/live-tests/eibc_3rd_token_test.go index 1fdae486..784c1aca 100644 --- a/live-tests/eibc_3rd_token_test.go +++ b/live-tests/eibc_3rd_token_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_3rd_Token_Live(t *testing.T) { +func TestEIBC_3rd_Token_RolY_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -37,15 +37,6 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { GasAdjustment: "1.1", Denom: "utia", } - 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", - } rollappY := cosmos.CosmosChain{ RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", GrpcAddr: "18.153.150.111:9090", @@ -64,8 +55,7 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { // create market maker marketMaker, err := hub.CreateUser("dym2") require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) + rollappYUser, err := rollappY.CreateUser("roly1") require.NoError(t, err) @@ -73,8 +63,6 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { require.NoError(t, err) err = mocha.NewClient("https://" + mocha.RPCAddr) require.NoError(t, err) - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) err = rollappY.NewClient("https://" + rollappY.RPCAddr) require.NoError(t, err) @@ -83,15 +71,12 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { testutil.WaitForBlocks(ctx, 2, hub) marketMaker.GetFaucet("http://18.184.170.181:3000/api/get-dym") mochaUser.GetFaucet("http://18.184.170.181:3000/api/get-tia") - rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx") rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) // Get the IBC denom - // rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) - // rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() mochaTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymMocha, mocha.Denom) mochaIBCDenom := transfertypes.ParseDenomTrace(mochaTokenDenom).IBCDenom() @@ -105,9 +90,6 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { mmOrigBal, err := marketMaker.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) fmt.Println(mmOrigBal) - rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappXOrigBal) rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) require.NoError(t, err) fmt.Println(rollappYOrigBal) @@ -125,6 +107,7 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(mocha, channelIDMochaDym, mochaUser.Address, transferData, mochaFee, options) + require.NoError(t, err) t.Log("mochaIBCDenom:", mochaIBCDenom) @@ -138,6 +121,7 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(hub, channelIDDymRollappY, dymensionUser.Address, transferData, dymFee, options) + require.NoError(t, err) testutil.WaitForBlocks(ctx, 10, hub) @@ -212,7 +196,7 @@ func TestEIBC_3rd_Token_Live(t *testing.T) { require.True(t, balance.Equal(transferAmountMM.Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountMM.Sub(eibcFee), balance)) } -func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { +func TestEIBC_3rd_Token_Timeout_RolY_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -235,15 +219,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { GasAdjustment: "1.1", Denom: "utia", } - 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", - } rollappY := cosmos.CosmosChain{ RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", GrpcAddr: "18.153.150.111:9090", @@ -262,8 +237,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { // create market maker marketMaker, err := hub.CreateUser("dym2") require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) rollappYUser, err := rollappY.CreateUser("roly1") require.NoError(t, err) @@ -271,8 +244,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { require.NoError(t, err) err = mocha.NewClient("https://" + mocha.RPCAddr) require.NoError(t, err) - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) err = rollappY.NewClient("https://" + rollappY.RPCAddr) require.NoError(t, err) @@ -283,8 +254,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { testutil.WaitForBlocks(ctx, 2, hub) mochaUser.GetFaucet("http://18.184.170.181:3000/api/get-tia") testutil.WaitForBlocks(ctx, 2, hub) - rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx") - testutil.WaitForBlocks(ctx, 2, hub) rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks @@ -306,9 +275,6 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { mmOrigBal, err := marketMaker.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) fmt.Println(mmOrigBal) - rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappXOrigBal) rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) require.NoError(t, err) fmt.Println(rollappYOrigBal) @@ -331,6 +297,7 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(mocha, channelIDMochaDym, mochaUser.Address, transferData, mochaFee, ibc.TransferOptions{}) + require.NoError(t, err) t.Log("mochaIBCDenom:", mochaIBCDenom) @@ -340,6 +307,7 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(mocha, channelIDMochaDym, mochaUser.Address, transferData, mochaFee, ibc.TransferOptions{}) + require.NoError(t, err) testutil.WaitForBlocks(ctx, 10, hub) @@ -351,10 +319,11 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { Amount: transferAmountMM.Add(transferAmountMM), } _, err = cosmos.SendIBCTransfer(hub, channelIDDymRollappY, dymensionUser.Address, transferData, dymFee, options) + require.NoError(t, err) - rollappXHeight, err := rollappX.Height(ctx) + rollappYHeight, err := rollappY.Height(ctx) require.NoError(t, err) - fmt.Println(rollappXHeight) + fmt.Println(rollappYHeight) testutil.AssertBalance(t, ctx, rollappYUser, mochaIBCDenom, rollappY.GrpcAddr, math.ZeroInt()) testutil.AssertBalance(t, ctx, rollappYUser, secondHopIBCDenom, rollappY.GrpcAddr, math.ZeroInt()) @@ -378,10 +347,11 @@ func TestEIBC_3rd_Token_Timeout_Live(t *testing.T) { } } - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 500) require.NoError(t, err) require.True(t, isFinalized) balance, err := marketMaker.GetBalance(ctx, mochaIBCDenom, hub.GrpcAddr) + require.NoError(t, err) fmt.Println(balance) } diff --git a/live-tests/eibc_ack_error_test.go b/live-tests/eibc_ack_error_test.go index 63f17fa8..b0216278 100644 --- a/live-tests/eibc_ack_error_test.go +++ b/live-tests/eibc_ack_error_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { +func TestEIBC_AckError_Dym_RolY_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -43,16 +43,6 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { Denom: "utia", } - 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", - } - rollappY := cosmos.CosmosChain{ RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", GrpcAddr: "18.153.150.111:9090", @@ -67,8 +57,6 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { require.NoError(t, err) mochaUser, err := mocha.CreateUser("mocha1") require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) rollappYUser, err := rollappY.CreateUser("roly1") require.NoError(t, err) @@ -78,15 +66,11 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { err = mocha.NewClient("https://" + mocha.RPCAddr) require.NoError(t, err) - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.RPCAddr) require.NoError(t, err) dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym") mochaUser.GetFaucet("http://18.184.170.181:3000/api/get-tia") - rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx") rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks @@ -104,10 +88,6 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { require.NoError(t, err) fmt.Println(dymensionOrigBal) - rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappXOrigBal) - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) require.NoError(t, err) fmt.Println(rollappYOrigBal) @@ -116,11 +96,6 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { require.NoError(t, err) fmt.Println(mochaOrigBal) - // Get ERC20 balance - erc20_OrigBal, err := GetERC20Balance(ctx, erc20IBCDenom, rollappX.GrpcAddr) - require.NoError(t, err) - fmt.Println(erc20_OrigBal) - // Use mocha to trigger ack error because rollapp isn't registered with mocha token var options ibc.TransferOptions @@ -197,7 +172,7 @@ func TestEIBC_AckError_Dym_EVM_Live(t *testing.T) { // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) // fund was return to roly user and dym user balance stay the same - testutil.AssertBalance(t, ctx, rollappYUser, mochaRollappYIBCDenom, rollappX.GrpcAddr, transferAmountMM) + testutil.AssertBalance(t, ctx, rollappYUser, mochaRollappYIBCDenom, rollappY.GrpcAddr, transferAmountMM) testutil.AssertBalance(t, ctx, dymensionUser, mochaIBCDenom, hub.GrpcAddr, transferAmountMM) } diff --git a/live-tests/eibc_demand_order_ignored_test.go b/live-tests/eibc_demand_order_ignored_test.go index d564a0d1..a3bc079d 100644 --- a/live-tests/eibc_demand_order_ignored_test.go +++ b/live-tests/eibc_demand_order_ignored_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_Demand_Order_Ignored_Live(t *testing.T) { +func TestEIBC_Demand_Order_Ignored_RolX_Live(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/live-tests/eibc_fulfillment_test.go b/live-tests/eibc_fulfillment_test.go index 2e9acb1e..dc27795d 100644 --- a/live-tests/eibc_fulfillment_test.go +++ b/live-tests/eibc_fulfillment_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBCFulfill_Live(t *testing.T) { +func TestEIBCFulfillRolX_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -37,15 +37,6 @@ func TestEIBCFulfill_Live(t *testing.T) { GasAdjustment: "1.1", Denom: "arolx", } - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } dymensionUser, err := hub.CreateUser("dym1") require.NoError(t, err) @@ -54,22 +45,16 @@ func TestEIBCFulfill_Live(t *testing.T) { require.NoError(t, err) rollappXUser, err := rollappX.CreateUser("rolx1") require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) err = hub.NewClient("https://" + hub.RPCAddr) require.NoError(t, err) err = rollappX.NewClient("https://" + rollappX.RPCAddr) require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.RPCAddr) - require.NoError(t, err) dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym") testutil.WaitForBlocks(ctx, 2, hub) marketMaker.GetFaucet("http://18.184.170.181:3000/api/get-dym") testutil.WaitForBlocks(ctx, 2, hub) rollappXUser.GetFaucet("http://18.184.170.181:3000/api/get-rollx") - testutil.WaitForBlocks(ctx, 2, hub) - rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) @@ -87,9 +72,6 @@ func TestEIBCFulfill_Live(t *testing.T) { rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) require.NoError(t, err) fmt.Println(rollappXOrigBal) - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappYOrigBal) transferAmountMM := math.NewInt(100000000000) // Compose an IBC transfer and send from rollappx -> marketmaker @@ -111,7 +93,7 @@ func TestEIBCFulfill_Live(t *testing.T) { require.NoError(t, err) fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) require.NoError(t, err) require.True(t, isFinalized) diff --git a/live-tests/eibc_invalid_fee_test.go b/live-tests/eibc_invalid_fee_test.go index 9deda63b..e3d06d51 100644 --- a/live-tests/eibc_invalid_fee_test.go +++ b/live-tests/eibc_invalid_fee_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "cosmossdk.io/math" + 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" @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_Invalid_Fee_Live(t *testing.T) { +func TestEIBC_Invalid_Fee_RolX_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -70,7 +70,7 @@ func TestEIBC_Invalid_Fee_Live(t *testing.T) { var options ibc.TransferOptions - multiplier := math.NewInt(10) + multiplier := sdkmath.NewInt(10) eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 options.Memo = BuildEIbcMemo(eibcFee) @@ -106,7 +106,7 @@ func TestEIBC_Invalid_Fee_Live(t *testing.T) { fmt.Println(rollappXHeight) encoding := encodingConfig() - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 20, false, encoding.InterfaceRegistry) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 40, false, encoding.InterfaceRegistry) require.NoError(t, err) for i, eibcEvent := range eibcEvents { fmt.Println(i, "EIBC Event:", eibcEvent) @@ -114,9 +114,177 @@ func TestEIBC_Invalid_Fee_Live(t *testing.T) { require.True(t, len(eibcEvents) == 1) // verify 1 EIBC event was registered on the hub // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) require.NoError(t, err) require.True(t, isFinalized) testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, transferAmount) } + +func TestEIBCFeeBgtAmountRolX_Live(t *testing.T) { + if testing.Short() { + t.Skip() + } + ctx := context.Background() + + // Configuration for live network + 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) + + 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) + + var options ibc.TransferOptions + + // create eIBC memo with fee 2 times the transfer amount + multiplier := sdkmath.NewInt(2) + eibcFee := transferAmount.Mul(multiplier) // example transfer amount * 0.1 + + // Compose an IBC transfer and send from rollappX -> hub + // Send IBC transfer with corrupted memo 1 + options.Memo = BuildEIbcMemo(eibcFee) + transferData := ibc.WalletData{ + Address: dymensionUser.Address, + Denom: rollappX.Denom, + Amount: transferAmount, + } + _, err = cosmos.SendIBCTransfer(rollappX, channelIDDymRollappX, rollappXUser.Address, transferData, rolxFee, options) + require.Error(t, err) + + // wait until the packet is finalized on Rollapp 1 + rollappXHeight, err := rollappX.Height(ctx) + require.NoError(t, err) + fmt.Println(rollappXHeight) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) + require.NoError(t, err) + require.True(t, isFinalized) + + // Verify that the amount is returned to the sender + testutil.AssertBalance(t, ctx, dymensionUser, dymensionUser.Denom, hub.GrpcAddr, dymensionOrigBal) + // Verify that the amount is not received by the receiver + testutil.AssertBalance(t, ctx, rollappXUser, rollappX.Denom, rollappX.GrpcAddr, rollappXOrigBal) +} + +func TestEIBCFeeBgtAmountRolY_Live(t *testing.T) { + if testing.Short() { + t.Skip() + } + ctx := context.Background() + + // Configuration for live network + 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", + } + + rollappY := cosmos.CosmosChain{ + RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", + GrpcAddr: "18.153.150.111:9090", + ChainID: "rollappy_700002-1", + Bin: "rollapp-wasm", + GasPrices: "0.0aroly", + GasAdjustment: "1.1", + Denom: "aroly", + } + + dymensionUser, err := hub.CreateUser("dym1") + require.NoError(t, err) + rollappYUser, err := rollappY.CreateUser("roly1") + require.NoError(t, err) + + err = hub.NewClient("https://" + hub.RPCAddr) + require.NoError(t, err) + + err = rollappY.NewClient("https://" + rollappY.RPCAddr) + require.NoError(t, err) + + dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym") + rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") + + // Wait for blocks + testutil.WaitForBlocks(ctx, 5, hub) + + dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) + require.NoError(t, err) + fmt.Println("hub original balance: ", dymensionOrigBal, dymensionUser.Denom) + + rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) + require.NoError(t, err) + fmt.Println("rollapp y original balance: ", rollappYOrigBal, rollappYUser.Denom) + + var options ibc.TransferOptions + + // create eIBC memo with fee 2 times the transfer amount + multiplier := sdkmath.NewInt(2) + eibcFee := transferAmount.Mul(multiplier) // example transfer amount * 0.1 + + // Send IBC transfer with corrupted memo 1 + options.Memo = BuildEIbcMemo(eibcFee) + + // Compose in IBC transfer and send from rollappY -> hub + transferData := ibc.WalletData{ + Address: dymensionUser.Address, + Denom: rollappY.Denom, + Amount: transferAmount, + } + _, err = cosmos.SendIBCTransfer(rollappY, channelIDDymRollappY, rollappYUser.Address, transferData, rolyFee, options) + require.Error(t, err) + + // wait until the packet is finalized on Rollapp 1 + rollappYHeight, err := rollappY.Height(ctx) + require.NoError(t, err) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 500) + require.NoError(t, err) + require.True(t, isFinalized) + + // Verify that the amount is returned to the sender + testutil.AssertBalance(t, ctx, dymensionUser, dymensionUser.Denom, hub.GrpcAddr, dymensionOrigBal) +} diff --git a/live-tests/eibc_no_memo_test.go b/live-tests/eibc_no_memo_test.go index 42fed762..63da88e0 100644 --- a/live-tests/eibc_no_memo_test.go +++ b/live-tests/eibc_no_memo_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBC_No_Memo_Live(t *testing.T) { +func TestEIBC_No_Memo_RolX_Live(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/live-tests/eibc_pfm_test.go b/live-tests/eibc_pfm_test.go index 9232527b..6989da99 100644 --- a/live-tests/eibc_pfm_test.go +++ b/live-tests/eibc_pfm_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBCPFM_Live(t *testing.T) { +func TestEIBCPFMRolX_Live(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/live-tests/eibc_timeout_test.go b/live-tests/eibc_timeout_test.go index b4f241f6..a93539e0 100644 --- a/live-tests/eibc_timeout_test.go +++ b/live-tests/eibc_timeout_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestEIBCTimeout_Live(t *testing.T) { +func TestEIBCTimeoutRolX_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -40,22 +40,10 @@ func TestEIBCTimeout_Live(t *testing.T) { Denom: "arolx", } - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } - dymensionUser, err := hub.CreateUser("dym1") require.NoError(t, err) rollappXUser, err := rollappX.CreateUser("rolx1") require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) err = hub.NewClient("https://" + hub.RPCAddr) require.NoError(t, err) @@ -63,12 +51,8 @@ func TestEIBCTimeout_Live(t *testing.T) { err = rollappX.NewClient("https://" + rollappX.RPCAddr) require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.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") - rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) @@ -77,12 +61,6 @@ func TestEIBCTimeout_Live(t *testing.T) { rollappXTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappX, rollappXUser.Denom) rollappXIBCDenom := transfertypes.ParseDenomTrace(rollappXTokenDenom).IBCDenom() - rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) - rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() - - // hubTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDRollappXDym, dymensionUser.Denom) - // hubIBCDenom := transfertypes.ParseDenomTrace(hubTokenDenom).IBCDenom() - dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) fmt.Println(dymensionOrigBal) @@ -91,10 +69,6 @@ func TestEIBCTimeout_Live(t *testing.T) { require.NoError(t, err) fmt.Println(rollappXOrigBal) - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappYOrigBal) - height, err := rollappX.Height(ctx) require.NoError(t, err) erc20_OrigBal, err := rollappXUser.GetERC20Balance(rollappX.JsonRPCAddr, erc20Contract, int64(height)) @@ -142,7 +116,7 @@ func TestEIBCTimeout_Live(t *testing.T) { fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) require.NoError(t, err) require.True(t, isFinalized) @@ -153,9 +127,78 @@ func TestEIBCTimeout_Live(t *testing.T) { fmt.Println(erc20_Bal) require.Equal(t, erc20_OrigBal, erc20_Bal) testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, math.ZeroInt()) +} + +func TestEIBCTimeoutRolY_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", + } + + rollappY := cosmos.CosmosChain{ + RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", + GrpcAddr: "18.153.150.111:9090", + ChainID: "rollappy_700002-1", + Bin: "rollapp-wasm", + GasPrices: "0.0aroly", + GasAdjustment: "1.1", + Denom: "aroly", + } + + dymensionUser, err := hub.CreateUser("dym1") + require.NoError(t, err) + rollappYUser, err := rollappY.CreateUser("roly1") + require.NoError(t, err) + + err = hub.NewClient("https://" + hub.RPCAddr) + require.NoError(t, err) + + err = rollappY.NewClient("https://" + rollappY.RPCAddr) + require.NoError(t, err) + + dymensionUser.GetFaucet("http://18.184.170.181:3000/api/get-dym") + rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") + + // Wait for blocks + testutil.WaitForBlocks(ctx, 5, hub) + + // Get the IBC denom + rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) + rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() + + dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) + require.NoError(t, err) + fmt.Println(dymensionOrigBal) + + rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) + require.NoError(t, err) + fmt.Println(rollappYOrigBal) + + height, err := rollappY.Height(ctx) + require.NoError(t, err) + erc20_OrigBal, err := rollappYUser.GetERC20Balance(rollappY.JsonRPCAddr, erc20Contract, int64(height)) + require.NoError(t, err) + fmt.Println(erc20_OrigBal) + + // Set a short timeout for IBC transfer + options := ibc.TransferOptions{ + Timeout: &ibc.IBCTimeout{ + NanoSeconds: 1000000, // 1 ms - this will cause the transfer to timeout before it is picked by a relayer + }, + } // Compose an IBC transfer and send from dymension -> rollapp - transferData = ibc.WalletData{ + transferData := ibc.WalletData{ Address: rollappYUser.Address, Denom: dymensionUser.Denom, Amount: transferAmount, @@ -176,18 +219,18 @@ func TestEIBCTimeout_Live(t *testing.T) { cosmos.SendIBCTransfer(rollappY, channelIDRollappYDym, rollappYUser.Address, transferData, rolyFee, options) require.NoError(t, err) - rollappYHeight, err := rollappX.Height(ctx) + rollappYHeight, err := rollappY.Height(ctx) require.NoError(t, err) fmt.Println(rollappYHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err = hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 500) require.NoError(t, err) require.True(t, isFinalized) height, err = rollappY.Height(ctx) require.NoError(t, err) - erc20_Bal, err = rollappYUser.GetERC20Balance(rollappY.JsonRPCAddr, erc20Contract, int64(height)) + erc20_Bal, err := rollappYUser.GetERC20Balance(rollappY.JsonRPCAddr, erc20Contract, int64(height)) require.NoError(t, err) fmt.Println(erc20_Bal) require.Equal(t, erc20_OrigBal, erc20_Bal) diff --git a/live-tests/ibc_transfer_test.go b/live-tests/ibc_transfer_test.go index ef759f0c..5f08e223 100644 --- a/live-tests/ibc_transfer_test.go +++ b/live-tests/ibc_transfer_test.go @@ -4,12 +4,9 @@ import ( "context" "fmt" "math/big" - "sync" "testing" - "time" "cosmossdk.io/math" - 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" @@ -17,7 +14,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestIBCTransfer_Live(t *testing.T) { +func TestIBCTransferRolX_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -44,22 +41,10 @@ func TestIBCTransfer_Live(t *testing.T) { Denom: "arolx", } - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } - dymensionUser, err := hub.CreateUser("dym1") require.NoError(t, err) rollappXUser, err := rollappX.CreateUser("rolx1") require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) err = hub.NewClient("https://" + hub.RPCAddr) require.NoError(t, err) @@ -67,12 +52,8 @@ func TestIBCTransfer_Live(t *testing.T) { err = rollappX.NewClient("https://" + rollappX.RPCAddr) require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.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") - rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) @@ -81,12 +62,6 @@ func TestIBCTransfer_Live(t *testing.T) { rollappXTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappX, rollappXUser.Denom) rollappXIBCDenom := transfertypes.ParseDenomTrace(rollappXTokenDenom).IBCDenom() - rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) - rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() - - hubTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDRollappXDym, dymensionUser.Denom) - hubIBCDenom := transfertypes.ParseDenomTrace(hubTokenDenom).IBCDenom() - dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) fmt.Println(dymensionOrigBal) @@ -95,10 +70,6 @@ func TestIBCTransfer_Live(t *testing.T) { require.NoError(t, err) fmt.Println(rollappXOrigBal) - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) - require.NoError(t, err) - fmt.Println(rollappYOrigBal) - height, err := rollappX.Height(ctx) require.NoError(t, err) erc20_OrigBal, err := rollappXUser.GetERC20Balance(rollappX.JsonRPCAddr, erc20Contract, int64(height)) @@ -148,49 +119,14 @@ func TestIBCTransfer_Live(t *testing.T) { fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) - require.NoError(t, err) - require.True(t, isFinalized) - - // Compose an IBC transfer and send from hub -> rollappY - transferData = ibc.WalletData{ - Address: rollappYUser.Address, - Denom: dymensionUser.Denom, - Amount: transferAmount, - } - - cosmos.SendIBCTransfer(hub, channelIDDymRollappY, dymensionUser.Address, transferData, dymFee, ibc.TransferOptions{}) - require.NoError(t, err) - - testutil.WaitForBlocks(ctx, 3, hub) - - // Compose an IBC transfer and send from rollappY -> hub - transferData = ibc.WalletData{ - Address: dymensionUser.Address, - Denom: rollappYUser.Denom, - Amount: transferAmount, - } - - cosmos.SendIBCTransfer(rollappY, channelIDRollappYDym, rollappYUser.Address, transferData, rolyFee, options) - require.NoError(t, err) - - rollappYHeight, err := rollappY.Height(ctx) - require.NoError(t, err) - - fmt.Println(rollappYHeight) - // wait until the packet is finalized on Rollapp 1 - isFinalized, err = hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 400) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) require.NoError(t, err) require.True(t, isFinalized) testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, transferAmount.Sub(eibcFee)) - // rolly currently don't support eibc - testutil.AssertBalance(t, ctx, rollappYUser, hubIBCDenom, rollappY.GrpcAddr, transferAmount) - testutil.AssertBalance(t, ctx, dymensionUser, rollappYIBCDenom, hub.GrpcAddr, transferAmount) } -// 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 TestDelayackRollappToHubNoFinalized_Live(t *testing.T) { +func TestIBCTransferRolY_Live(t *testing.T) { if testing.Short() { t.Skip() } @@ -206,16 +142,6 @@ func TestDelayackRollappToHubNoFinalized_Live(t *testing.T) { 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", - } - rollappY := cosmos.CosmosChain{ RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", GrpcAddr: "18.153.150.111:9090", @@ -228,336 +154,74 @@ func TestDelayackRollappToHubNoFinalized_Live(t *testing.T) { dymensionUser, err := hub.CreateUser("dym1") require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) rollappYUser, err := rollappY.CreateUser("roly1") require.NoError(t, err) err = hub.NewClient("https://" + hub.RPCAddr) require.NoError(t, err) - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) - err = rollappY.NewClient("https://" + rollappY.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") rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") // Wait for blocks testutil.WaitForBlocks(ctx, 5, hub) - // Get the IBC denom - rollappXTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappX, rollappXUser.Denom) - rollappXIBCDenom := transfertypes.ParseDenomTrace(rollappXTokenDenom).IBCDenom() + rollappYTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDDymRollappY, rollappYUser.Denom) + rollappYIBCDenom := transfertypes.ParseDenomTrace(rollappYTokenDenom).IBCDenom() - dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) - require.NoError(t, err) - fmt.Println("hub original balance: ", dymensionOrigBal, dymensionUser.Denom) + hubTokenDenom := transfertypes.GetPrefixedDenom("transfer", channelIDRollappXDym, dymensionUser.Denom) + hubIBCDenom := transfertypes.ParseDenomTrace(hubTokenDenom).IBCDenom() - rollappXOrigBal, err := rollappXUser.GetBalance(ctx, rollappXUser.Denom, rollappX.GrpcAddr) + dymensionOrigBal, err := dymensionUser.GetBalance(ctx, dymensionUser.Denom, hub.GrpcAddr) require.NoError(t, err) - fmt.Println("rollapp x original balance: ", rollappXOrigBal, rollappXUser.Denom) + fmt.Println(dymensionOrigBal) rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) require.NoError(t, err) - fmt.Println("rollapp y original balance: ", rollappYOrigBal, rollappYUser.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) + fmt.Println(rollappYOrigBal) - // Compose an IBC transfer and send from rollapp -> hub + // Compose an IBC transfer and send from hub -> rollappY transferData := ibc.WalletData{ - Address: dymensionUser.Address, - Denom: rollappXUser.Denom, + Address: rollappYUser.Address, + Denom: dymensionUser.Denom, Amount: transferAmount, } - var options ibc.TransferOptions - 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 TestDelayackRollappToHub_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", - } - - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } - - dymensionUser, err := hub.CreateUser("dym1") - require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) - - err = hub.NewClient("https://" + hub.RPCAddr) - require.NoError(t, err) - - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) - - err = rollappY.NewClient("https://" + rollappY.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") - rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") - - // 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) - - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) + cosmos.SendIBCTransfer(hub, channelIDDymRollappY, dymensionUser.Address, transferData, dymFee, ibc.TransferOptions{}) require.NoError(t, err) - fmt.Println("rollapp y original balance: ", rollappYOrigBal, rollappYUser.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) + testutil.WaitForBlocks(ctx, 3, hub) - // Compose an IBC transfer and send from rollapp -> hub - transferData := ibc.WalletData{ + // Compose an IBC transfer and send from rollappY -> hub + transferData = ibc.WalletData{ Address: dymensionUser.Address, - Denom: rollappXUser.Denom, + Denom: rollappYUser.Denom, Amount: transferAmount, } - var options ibc.TransferOptions - 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, 400) - 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) -} - -func TestEIBCFeeBgtAmount_Live(t *testing.T) { - if testing.Short() { - t.Skip() - } - ctx := context.Background() - - // Configuration for live network - 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", - } - - rollappY := cosmos.CosmosChain{ - RPCAddr: "rpc.roly.wasm.ra.blumbus.noisnemyd.xyz:443", - GrpcAddr: "18.153.150.111:9090", - ChainID: "rollappy_700002-1", - Bin: "rollapp-wasm", - GasPrices: "0.0aroly", - GasAdjustment: "1.1", - Denom: "aroly", - } - - dymensionUser, err := hub.CreateUser("dym1") - require.NoError(t, err) - rollappXUser, err := rollappX.CreateUser("rolx1") - require.NoError(t, err) - rollappYUser, err := rollappY.CreateUser("roly1") - require.NoError(t, err) - - err = hub.NewClient("https://" + hub.RPCAddr) - require.NoError(t, err) - - err = rollappX.NewClient("https://" + rollappX.RPCAddr) - require.NoError(t, err) - - err = rollappY.NewClient("https://" + rollappY.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") - // rollappYUser.GetFaucet("http://18.184.170.181:3000/api/get-rolly") - - // Wait for blocks - testutil.WaitForBlocks(ctx, 5, hub) - - 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) - - rollappYOrigBal, err := rollappYUser.GetBalance(ctx, rollappYUser.Denom, rollappY.GrpcAddr) - require.NoError(t, err) - fmt.Println("rollapp y original balance: ", rollappYOrigBal, rollappYUser.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) + multiplier := math.NewInt(10) + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 var options ibc.TransferOptions - - // create eIBC memo with fee 2 times the transfer amount - multiplier := sdkmath.NewInt(2) - eibcFee := transferAmount.Mul(multiplier) // example transfer amount * 0.1 - - // Compose an IBC transfer and send from rollappX -> hub - // Send IBC transfer with corrupted memo 1 + // set eIBC specific memo options.Memo = BuildEIbcMemo(eibcFee) - transferData := ibc.WalletData{ - Address: dymensionUser.Address, - Denom: rollappX.Denom, - Amount: transferAmount, - } - _, err = cosmos.SendIBCTransfer(rollappX, channelIDDymRollappX, rollappXUser.Address, transferData, rolxFee, options) - require.Error(t, err) - // Compose in IBC transfer and send from rollappY -> hub - transferData = ibc.WalletData{ - Address: dymensionUser.Address, - Denom: rollappY.Denom, - Amount: transferAmount, - } - _, err = cosmos.SendIBCTransfer(rollappY, channelIDDymRollappY, rollappYUser.Address, transferData, rolyFee, options) - require.Error(t, err) + cosmos.SendIBCTransfer(rollappY, channelIDRollappYDym, rollappYUser.Address, transferData, rolyFee, options) + require.NoError(t, err) - // wait until the packet is finalized on Rollapp 1 - rollappXHeight, err := rollappX.Height(ctx) rollappYHeight, err := rollappY.Height(ctx) require.NoError(t, err) - fmt.Println(rollappXHeight) - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 400) - require.NoError(t, err) - require.True(t, isFinalized) - isFinalized, err = hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 400) + + fmt.Println(rollappYHeight) + // wait until the packet is finalized on Rollapp 1 + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappY.ChainID, rollappYHeight, 500) require.NoError(t, err) require.True(t, isFinalized) - // Verify that the amount is returned to the sender - testutil.AssertBalance(t, ctx, dymensionUser, dymensionUser.Denom, hub.GrpcAddr, dymensionOrigBal) - // Verify that the amount is not received by the receiver - testutil.AssertBalance(t, ctx, rollappXUser, rollappX.Denom, rollappX.GrpcAddr, rollappXOrigBal) + // rolly currently don't support eibc + testutil.AssertBalance(t, ctx, rollappYUser, hubIBCDenom, rollappY.GrpcAddr, transferAmount) + testutil.AssertBalance(t, ctx, dymensionUser, rollappYIBCDenom, hub.GrpcAddr, transferAmount) } From e98ee73fa8fdf5689eabef80226689710b2b738a Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Mon, 5 Aug 2024 17:41:06 +0700 Subject: [PATCH 5/7] fix delayed tests --- live-tests/delayed_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/live-tests/delayed_test.go b/live-tests/delayed_test.go index 520b03e0..a584c702 100644 --- a/live-tests/delayed_test.go +++ b/live-tests/delayed_test.go @@ -83,7 +83,7 @@ func TestDelayackRollappToHubNoFinalizedRolX_Live(t *testing.T) { } var options ibc.TransferOptions - cosmos.SendIBCTransfer(rollappX, channelIDRollappXDym, rollappXUser.Address, transferData, rolxFee, options) + _, 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)) @@ -101,7 +101,7 @@ func TestDelayackRollappToHubNoFinalizedRolX_Live(t *testing.T) { defer wg.Done() ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() - timeout := time.After(500 * time.Second) // Set a timeout for the whole check + timeout := time.After(400 * time.Second) // Set a timeout for the whole check for { select { @@ -210,7 +210,7 @@ func TestDelayackRollappToHubRolX_Live(t *testing.T) { } var options ibc.TransferOptions - cosmos.SendIBCTransfer(rollappX, channelIDRollappXDym, rollappXUser.Address, transferData, rolxFee, options) + _, 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)) @@ -219,7 +219,7 @@ func TestDelayackRollappToHubRolX_Live(t *testing.T) { require.NoError(t, err) fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 1000) require.NoError(t, err) require.True(t, isFinalized) From c5bc7b3af01e3214f0a9a34d143b9db62cda88d5 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Wed, 7 Aug 2024 11:20:35 +0700 Subject: [PATCH 6/7] minor --- Makefile | 2 +- go.mod | 4 ++-- go.sum | 6 ++++-- live-tests/eibc_fulfillment_test.go | 19 +++++++++++-------- live-tests/ibc_transfer_test.go | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index bed5521f..c7163b2f 100644 --- a/Makefile +++ b/Makefile @@ -561,7 +561,7 @@ 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-rolx: clean-e2e-live - cd live-tests && go test -timeout=25m -race -v -run TestEIBCFulfillRolX_Live . + cd live-tests && go test -timeout=35m -race -v -run TestEIBCFulfillRolX_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 . diff --git a/go.mod b/go.mod index 60f440a1..ed04ce85 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ replace ( ) require ( - github.com/decentrio/e2e-testing-live v0.0.0-20240805103419-201590f9f6c2 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4 + github.com/decentrio/e2e-testing-live v0.0.0-20240805104706-dc8d537e8007 + github.com/decentrio/rollup-e2e-testing v0.0.0-20240806082831-1e499ecbb2fc github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240717194206-54c0fca5fada ) diff --git a/go.sum b/go.sum index 772f1b21..7f3a7a1b 100644 --- a/go.sum +++ b/go.sum @@ -382,10 +382,12 @@ 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-20240805103419-201590f9f6c2 h1:Y5eaScVSArrG3EHeqMi3tnxx4vdTF6mwhnQTWNr1WHM= -github.com/decentrio/e2e-testing-live v0.0.0-20240805103419-201590f9f6c2/go.mod h1:qLIf3XX6bQsQlmVqhbNOiLc/ONeA0NDiPmpsrljJkXc= +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-20240718115231-5ffec3805af4 h1:ZZFkAHWyK8KEF/tsyNIQ3xIhQHr2hAFyz0KE4iJM1q0= github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4/go.mod h1:NwTceYVxAaIZI65g/PdibVnGRMXuZzqzhDIkWsqJaQM= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240806082831-1e499ecbb2fc h1:Zl+RTLm1RgS0VtCesOhh+umQ7N6SkfF1mMZ8TODc/68= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240806082831-1e499ecbb2fc/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= diff --git a/live-tests/eibc_fulfillment_test.go b/live-tests/eibc_fulfillment_test.go index dc27795d..0680eafa 100644 --- a/live-tests/eibc_fulfillment_test.go +++ b/live-tests/eibc_fulfillment_test.go @@ -93,10 +93,13 @@ func TestEIBCFulfillRolX_Live(t *testing.T) { require.NoError(t, err) fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 600) require.NoError(t, err) require.True(t, isFinalized) + // wait rollapp few more blocks for some reason + testutil.WaitForBlocks(ctx, 5, rollappX) + // TODO: Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := transferDataRollAppXToMm.Amount balance, err := marketMaker.GetBalance(ctx, rollappXIBCDenom, hub.GrpcAddr) @@ -120,18 +123,18 @@ func TestEIBCFulfillRolX_Live(t *testing.T) { cosmos.SendIBCTransfer(rollappX, channelIDRollappXDym, rollappXUser.Address, transferDataRollAppXToHub, rolxFee, options) require.NoError(t, err) - encoding := encodingConfig() - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 10, false, encoding.InterfaceRegistry) - require.NoError(t, err) - for i, eibcEvent := range eibcEvents { - fmt.Println(i, "EIBC Event:", eibcEvent) - } - testutil.WaitForBlocks(ctx, 10, hub) // Check non-fulfill testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, math.ZeroInt()) + // get eIbc event + encoding := encodingConfig() + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 30, true, encoding.InterfaceRegistry) + require.NoError(t, err) + for i, eibcEvent := range eibcEvents { + fmt.Println(i, "EIBC Event:", eibcEvent) + } // fulfill demand orders from rollapp 1 for _, eibcEvent := range eibcEvents { diff --git a/live-tests/ibc_transfer_test.go b/live-tests/ibc_transfer_test.go index 5f08e223..814869a9 100644 --- a/live-tests/ibc_transfer_test.go +++ b/live-tests/ibc_transfer_test.go @@ -119,7 +119,7 @@ func TestIBCTransferRolX_Live(t *testing.T) { fmt.Println(rollappXHeight) // wait until the packet is finalized on Rollapp 1 - isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 500) + isFinalized, err := hub.WaitUntilRollappHeightIsFinalized(ctx, rollappX.ChainID, rollappXHeight, 600) require.NoError(t, err) require.True(t, isFinalized) From 1e94a9924560f06b7fba1638eac6bf6194e8dec6 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Wed, 7 Aug 2024 15:29:06 +0700 Subject: [PATCH 7/7] minor --- go.mod | 2 +- go.sum | 6 ++---- live-tests/eibc_fulfillment_test.go | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index ed04ce85..70902cb4 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ replace ( require ( github.com/decentrio/e2e-testing-live v0.0.0-20240805104706-dc8d537e8007 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240806082831-1e499ecbb2fc + github.com/decentrio/rollup-e2e-testing v0.0.0-20240807082808-165b0678bfbb github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240717194206-54c0fca5fada ) diff --git a/go.sum b/go.sum index 7f3a7a1b..a6fb8e8f 100644 --- a/go.sum +++ b/go.sum @@ -384,10 +384,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 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-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-20240718115231-5ffec3805af4 h1:ZZFkAHWyK8KEF/tsyNIQ3xIhQHr2hAFyz0KE4iJM1q0= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240718115231-5ffec3805af4/go.mod h1:NwTceYVxAaIZI65g/PdibVnGRMXuZzqzhDIkWsqJaQM= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240806082831-1e499ecbb2fc h1:Zl+RTLm1RgS0VtCesOhh+umQ7N6SkfF1mMZ8TODc/68= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240806082831-1e499ecbb2fc/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= +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= diff --git a/live-tests/eibc_fulfillment_test.go b/live-tests/eibc_fulfillment_test.go index 0680eafa..f3295b48 100644 --- a/live-tests/eibc_fulfillment_test.go +++ b/live-tests/eibc_fulfillment_test.go @@ -98,7 +98,7 @@ func TestEIBCFulfillRolX_Live(t *testing.T) { require.True(t, isFinalized) // wait rollapp few more blocks for some reason - testutil.WaitForBlocks(ctx, 5, rollappX) + testutil.WaitForBlocks(ctx, 10, hub) // TODO: Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := transferDataRollAppXToMm.Amount @@ -123,7 +123,6 @@ func TestEIBCFulfillRolX_Live(t *testing.T) { cosmos.SendIBCTransfer(rollappX, channelIDRollappXDym, rollappXUser.Address, transferDataRollAppXToHub, rolxFee, options) require.NoError(t, err) - testutil.WaitForBlocks(ctx, 10, hub) // Check non-fulfill testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, math.ZeroInt()) @@ -139,7 +138,7 @@ func TestEIBCFulfillRolX_Live(t *testing.T) { // fulfill demand orders from rollapp 1 for _, eibcEvent := range eibcEvents { re := regexp.MustCompile(`^\d+`) - if re.ReplaceAllString(eibcEvent.Price, "") == rollappXIBCDenom && eibcEvent.PacketStatus == "PENDING" { + if re.ReplaceAllString(eibcEvent.Price, "") == rollappXIBCDenom && eibcEvent.PacketStatus == "PENDING"{ fmt.Println("EIBC Event:", eibcEvent) _, err := cosmos.FullfillDemandOrder(&hub, eibcEvent.ID, marketMaker.Address, dymFee) require.NoError(t, err)