diff --git a/go.mod b/go.mod index 3ee782f1..6bfacddb 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/ibc-go/v6 v6.2.1 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240401062200-380e8b9d21f4 + github.com/decentrio/rollup-e2e-testing v0.0.0-20240412081042-4e7422935539 github.com/dymensionxyz/dymension-rdk v1.1.0-beta github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd github.com/evmos/ethermint v0.22.0 diff --git a/go.sum b/go.sum index d1151ddc..c96da9b4 100644 --- a/go.sum +++ b/go.sum @@ -330,8 +330,8 @@ github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnG github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240401062200-380e8b9d21f4 h1:VR2rKvHs7T8zql2cmZts6PEbdWEzeRVODtOwaNS0ZkM= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240401062200-380e8b9d21f4/go.mod h1:Hy/8P41OEKrlAatPG5NcD/BOWTa2s+laECwpZpmA9f0= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240412081042-4e7422935539 h1:gZlOCdIqYIPq6sl97RJGpwaQDv9Nijgo8p6ygZqP8L8= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240412081042-4e7422935539/go.mod h1:Hy/8P41OEKrlAatPG5NcD/BOWTa2s+laECwpZpmA9f0= 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/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 66bba163..0c800a36 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -38,6 +38,7 @@ func TestEIBCFulfillment_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides const BLOCK_FINALITY_PERIOD = 80 @@ -113,7 +114,7 @@ func TestEIBCFulfillment_EVM(t *testing.T) { r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), ).Build(t, client, "relayer", network) - const ibcPath = "ibc-path" + ic := test.NewSetup(). AddRollUp(dymension, rollapp1). AddRelayer(r, "relayer"). @@ -131,13 +132,34 @@ func TestEIBCFulfillment_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains @@ -290,6 +312,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides const BLOCK_FINALITY_PERIOD = 80 @@ -365,7 +388,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), ).Build(t, client, "relayer", network) - const ibcPath = "ibc-path" + ic := test.NewSetup(). AddRollUp(dymension, rollapp1). AddRelayer(r, "relayer"). @@ -383,13 +406,34 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 8cfec429..b8cfbea7 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -22,8 +22,6 @@ import ( "github.com/decentrio/rollup-e2e-testing/testutil" ) -const anotherIbcPath = "dymension-demo2" - var dymModifyGenesisKV = append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -48,6 +46,7 @@ func TestRollAppFreeze_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -135,13 +134,34 @@ func TestRollAppFreeze_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) @@ -223,7 +243,7 @@ func TestRollAppFreeze_EVM(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(rollapp1Clients)) - err = dymension.SubmitFraudProposal( + _, err = dymension.SubmitFraudProposal( ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fmt.Sprint(rollappHeight-2), @@ -288,6 +308,7 @@ func TestRollAppFreeze_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -374,13 +395,34 @@ func TestRollAppFreeze_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) @@ -473,7 +515,7 @@ func TestRollAppFreeze_Wasm(t *testing.T) { fraudHeight := fmt.Sprint(rollappHeight - 2) - err = dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, "07-tendermint-0", submitFraudStr, submitFraudStr, deposit) + _, err = dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, "07-tendermint-0", submitFraudStr, submitFraudStr, deposit) require.NoError(t, err) err = dymension.VoteOnProposalAllValidators(ctx, "2", cosmos.ProposalVoteYes) @@ -528,6 +570,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -537,6 +580,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { dymintTomlOverrides2["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides2["rollapp_id"] = "rollappevm_12345-1" dymintTomlOverrides2["gas_prices"] = "0adym" + dymintTomlOverrides2["empty_blocks_max_time"] = "3s" configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides2 // Create chain factory with dymension @@ -657,13 +701,58 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) + require.NoError(t, err) + + err = s.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) + require.NoError(t, err) + + err = s.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + s.UpdateClients(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = s.CreateConnections(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) + require.NoError(t, err) + + err = s.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) require.NoError(t, err) @@ -809,7 +898,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { } // Submit fraud proposal and all votes yes so the gov will pass and got executed. - err = dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) + _, err = dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) require.NoError(t, err) err = dymension.VoteOnProposalAllValidators(ctx, "2", cosmos.ProposalVoteYes) @@ -859,9 +948,14 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, dymension) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Get updated dym hub ibc denom balance dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) require.NoError(t, err) @@ -898,9 +992,14 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp2.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp2) + rollappHeight, err = rollapp2.GetNode().Height(ctx) require.NoError(t, err) + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + rollapp2UserUpdateBal, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, dymToRollapp2IbcDenom) require.NoError(t, err) @@ -920,7 +1019,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) @@ -945,6 +1044,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -954,6 +1054,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { dymintTomlOverrides2["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides2["rollapp_id"] = "rollappwasm_12345-1" dymintTomlOverrides2["gas_prices"] = "0adym" + dymintTomlOverrides2["empty_blocks_max_time"] = "3s" configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides2 // Create chain factory with dymension @@ -1074,16 +1175,58 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) require.NoError(t, err) + err = s.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) + require.NoError(t, err) + + err = s.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + s.UpdateClients(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = s.CreateConnections(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) + require.NoError(t, err) + + err = s.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + // Start both relayers err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) @@ -1225,7 +1368,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { } } // Submit fraud proposal and all votes yes so the gov will pass and got executed. - err = dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) + _, err = dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) require.NoError(t, err) err = dymension.VoteOnProposalAllValidators(ctx, "2", cosmos.ProposalVoteYes) @@ -1275,9 +1418,14 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, dymension) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Get updated dym hub ibc denom balance dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) require.NoError(t, err) @@ -1314,8 +1462,13 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp2.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp2) + rollappHeight, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) rollapp2UserUpdateBal, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, dymToRollapp2IbcDenom) require.NoError(t, err) @@ -1336,7 +1489,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index 37db2a44..b486eca0 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -34,6 +34,7 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" modifyGenesisKV := append( dymensionGenesisKV, @@ -127,13 +128,34 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains @@ -165,11 +187,6 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { Amount: transferAmount, } - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 3, rollapp1) - require.NoError(t, err) - rollapp := rollappParam{ rollappID: rollapp1.Config().ChainID, channelID: channel.ChannelID, @@ -180,16 +197,29 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { // Compose an IBC transfer and send from Hub -> rollapp _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) - err = testutil.WaitForBlocks(ctx, 10, rollapp1) + err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Assert balance was updated on the Rollapp testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) @@ -213,16 +243,20 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // Assert funds are waiting testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) - // Wait a 40 blocks - err = testutil.WaitForBlocks(ctx, 40, dymension, rollapp1) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) // Assert balance was updated on the Hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) @@ -252,6 +286,7 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" modifyGenesisKV := append( dymensionGenesisKV, @@ -345,13 +380,34 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains @@ -383,11 +439,6 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { Amount: transferAmount, } - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) - require.NoError(t, err) - rollapp := rollappParam{ rollappID: rollapp1.Config().ChainID, channelID: channel.ChannelID, @@ -405,9 +456,20 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) - err = testutil.WaitForBlocks(ctx, 10, rollapp1) + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Assert balance was updated on the Rollapp testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) @@ -431,16 +493,20 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // Assert funds are waiting testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) - // Wait a 40 blocks - err = testutil.WaitForBlocks(ctx, 40, dymension, rollapp1) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) // Assert balance was updated on the Hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) diff --git a/tests/ibc_pfm_test.go b/tests/ibc_pfm_test.go index 5bdf6ee3..7975cb0e 100644 --- a/tests/ibc_pfm_test.go +++ b/tests/ibc_pfm_test.go @@ -35,6 +35,7 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -109,13 +110,13 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { Chain1: dymension, Chain2: rollapp1, Relayer: r, - Path: pathHubToRollApp, + Path: ibcPath, }). AddLink(test.InterchainLink{ Chain1: dymension, Chain2: gaia, Relayer: r2, - Path: pathDymToGaia, + Path: ibcPath, }) rep := testreporter.NewNopReporter() @@ -125,7 +126,7 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) @@ -135,6 +136,54 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { _ = ic.Close() }) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) + require.NoError(t, err) + + r2.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -165,10 +214,10 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { require.NotEmpty(t, channGaiaDym.ChannelID) // Start the relayer and set the cleanup function. - err = r.StartRelayer(ctx, eRep, pathHubToRollApp) + err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.StartRelayer(ctx, eRep, pathDymToGaia) + err = r2.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) t.Cleanup( @@ -257,7 +306,15 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 40, rollapp1, gaia) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) @@ -279,6 +336,7 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -353,13 +411,13 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { Chain1: dymension, Chain2: rollapp1, Relayer: r, - Path: pathHubToRollApp, + Path: ibcPath, }). AddLink(test.InterchainLink{ Chain1: dymension, Chain2: gaia, Relayer: r2, - Path: pathDymToGaia, + Path: ibcPath, }) rep := testreporter.NewNopReporter() @@ -369,7 +427,7 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) @@ -379,6 +437,54 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { _ = ic.Close() }) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) + require.NoError(t, err) + + r2.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -409,10 +515,10 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { require.NotEmpty(t, channGaiaDym.ChannelID) // Start the relayer and set the cleanup function. - err = r.StartRelayer(ctx, eRep, pathHubToRollApp) + err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.StartRelayer(ctx, eRep, pathDymToGaia) + err = r2.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) t.Cleanup( @@ -501,7 +607,15 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 40, rollapp1, gaia) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index 57ad3404..a697c62a 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -35,10 +35,11 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" modifyGenesisKV := append(dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "100", + Value: "60", }) configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -133,13 +134,13 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { Chain1: dymension, Chain2: rollapp1, Relayer: r, - Path: pathHubToRollApp, + Path: ibcPath, }). AddLink(test.InterchainLink{ Chain1: dymension, Chain2: gaia, Relayer: r2, - Path: pathDymToGaia, + Path: ibcPath, }) rep := testreporter.NewNopReporter() @@ -149,7 +150,7 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) @@ -159,6 +160,54 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { _ = ic.Close() }) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) + require.NoError(t, err) + + r2.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -189,10 +238,10 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { require.NotEmpty(t, channGaiaDym.ChannelID) // Start the relayer and set the cleanup function. - err = r.StartRelayer(ctx, eRep, pathHubToRollApp) + err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.StartRelayer(ctx, eRep, pathDymToGaia) + err = r2.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) t.Cleanup( @@ -281,7 +330,7 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 50, rollapp1) + err = testutil.WaitForBlocks(ctx, 20, rollapp1) require.NoError(t, err) rollAppBalance, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) @@ -298,7 +347,15 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { require.True(t, dymBalance.Equal(zeroBal)) require.True(t, gaiaBalance.Equal(zeroBal)) - err = testutil.WaitForBlocks(ctx, 100, rollapp1) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) require.NoError(t, err) gaiaBalance, err = gaia.GetBalance(ctx, gaiaUserAddr, secondHopIBCDenom) @@ -320,10 +377,11 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" modifyGenesisKV := append(dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "100", + Value: "60", }) configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -418,13 +476,13 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { Chain1: dymension, Chain2: rollapp1, Relayer: r, - Path: pathHubToRollApp, + Path: ibcPath, }). AddLink(test.InterchainLink{ Chain1: dymension, Chain2: gaia, Relayer: r2, - Path: pathDymToGaia, + Path: ibcPath, }) rep := testreporter.NewNopReporter() @@ -434,7 +492,7 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) @@ -444,6 +502,54 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { _ = ic.Close() }) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) + require.NoError(t, err) + + r2.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -474,10 +580,10 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { require.NotEmpty(t, channGaiaDym.ChannelID) // Start the relayer and set the cleanup function. - err = r.StartRelayer(ctx, eRep, pathHubToRollApp) + err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.StartRelayer(ctx, eRep, pathDymToGaia) + err = r2.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) t.Cleanup( @@ -566,7 +672,7 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 50, rollapp1) + err = testutil.WaitForBlocks(ctx, 20, rollapp1) require.NoError(t, err) rollAppBalance, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) @@ -583,7 +689,15 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { require.True(t, dymBalance.Equal(zeroBal)) require.True(t, gaiaBalance.Equal(zeroBal)) - err = testutil.WaitForBlocks(ctx, 100, rollapp1) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) require.NoError(t, err) gaiaBalance, err = gaia.GetBalance(ctx, gaiaUserAddr, secondHopIBCDenom) diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index cc3ef402..b9736d87 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -36,6 +36,7 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides const BLOCK_FINALITY_PERIOD = 10 @@ -110,7 +111,6 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), ).Build(t, client, "relayer", network) - const ibcPath = "ibc-path" ic := test.NewSetup(). AddRollUp(dymension, rollapp1). AddRelayer(r, "relayer"). @@ -128,13 +128,34 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains @@ -188,8 +209,13 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) // Stop relayer after relaying err = r.StopRelayer(ctx, eRep) @@ -224,15 +250,18 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight // in order to trigger ibc timeout or else it will trigger callback - err = testutil.WaitForBlocks(ctx, 5, rollapp1) - require.NoError(t, err) err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 40, dymension, rollapp1) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) @@ -261,6 +290,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides const BLOCK_FINALITY_PERIOD = 10 @@ -334,7 +364,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), ).Build(t, client, "relayer", network) - const ibcPath = "ibc-path" + ic := test.NewSetup(). AddRollUp(dymension, rollapp1). AddRelayer(r, "relayer"). @@ -352,13 +382,34 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains @@ -412,9 +463,14 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Stop relayer after relaying err = r.StopRelayer(ctx, eRep) require.NoError(t, err, "an error occurred while stopping the relayer") @@ -448,14 +504,17 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight // in order to trigger ibc timeout or else it will trigger callback - err = testutil.WaitForBlocks(ctx, 5, rollapp1) - require.NoError(t, err) err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 40, dymension, rollapp1) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index d775fef9..09fc3a7f 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -19,8 +19,6 @@ import ( "github.com/decentrio/rollup-e2e-testing/testutil" ) -const ibcPath = "dymension-demo" - // TestIBCTransferSuccess ensure that the transfer between Hub and Rollapp is accurate. func TestIBCTransferSuccess_EVM(t *testing.T) { if testing.Short() { @@ -35,6 +33,7 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -105,13 +104,34 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains @@ -139,20 +159,6 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) require.NoError(t, err) - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) - require.NoError(t, err) - - t.Cleanup( - func() { - err := r.StopRelayer(ctx, eRep) - if err != nil { - t.Logf("an error occurred while stopping the relayer: %s", err) - } - }, - ) - rollapp := rollappParam{ rollappID: rollapp1.Config().ChainID, channelID: channel.ChannelID, @@ -172,11 +178,25 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { // Compose an IBC transfer and send from Hub -> rollapp _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + err = r.StopRelayer(ctx, eRep) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) @@ -198,8 +218,18 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -224,6 +254,7 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -294,13 +325,53 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + // done := make(chan bool) + // go func() { + // err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + // require.NoError(t, err) + + // done <- true + // }() + + // select { + // case <-done: + // fmt.Println("Channel created") + // case <-time.After(1 * time.Minute): + // err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + // require.NoError(t, err) + // } + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains @@ -328,20 +399,6 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) require.NoError(t, err) - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) - require.NoError(t, err) - - t.Cleanup( - func() { - err := r.StopRelayer(ctx, eRep) - if err != nil { - t.Logf("an error occurred while stopping the relayer: %s", err) - } - }, - ) - rollapp := rollappParam{ rollappID: rollapp1.Config().ChainID, channelID: channel.ChannelID, @@ -364,9 +421,22 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) + require.NoError(t, err) + + err = r.StopRelayer(ctx, eRep) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -387,8 +457,19 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index 080840f2..28e72722 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -35,6 +35,7 @@ func TestRollappGenesisEvent_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -107,13 +108,34 @@ func TestRollappGenesisEvent_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + walletAmount := math.NewInt(1_000_000_000_000) // Create some user accounts on both chains diff --git a/tests/setup.go b/tests/setup.go index 912bbe2e..f817cb49 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -38,6 +38,9 @@ type ForwardMetadata struct { RefundSequence *uint64 `json:"refund_sequence,omitempty"` } +const ibcPath = "dymension-demo" +const anotherIbcPath = "dymension-demo2" + var ( DymensionMainRepo = "ghcr.io/dymensionxyz/dymension" @@ -112,10 +115,6 @@ var ( ConfigFileOverrides: nil, } - // IBC Path - pathHubToRollApp = "hub-path" - pathDymToGaia = "dym-gaia" - rollappEVMGenesisKV = []cosmos.GenesisKV{ { Key: "app_state.mint.params.mint_denom", diff --git a/tests/tx_batch_finalization_test.go b/tests/tx_batch_finalization_test.go index b66aca50..6f486082 100644 --- a/tests/tx_batch_finalization_test.go +++ b/tests/tx_batch_finalization_test.go @@ -41,6 +41,7 @@ func TestBatchFinalization_EVM(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" const BLOCK_FINALITY_PERIOD = 50 modifyGenesisKV := append( @@ -124,7 +125,7 @@ func TestBatchFinalization_EVM(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), @@ -183,6 +184,7 @@ func TestBatchFinalization_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" const BLOCK_FINALITY_PERIOD = 50 modifyGenesisKV := append( @@ -266,7 +268,7 @@ func TestBatchFinalization_Wasm(t *testing.T) { TestName: t.Name(), Client: client, NetworkID: network, - SkipPathCreation: false, + SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),