From c5269d306cacfa733733bde23e2d325b56f2cb7e Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:16:15 +0700 Subject: [PATCH] chore: remove genesis account (#416) --- go.mod | 2 +- go.sum | 4 +- tests/admc_test.go | 8 +- tests/eibc_ack_error_test.go | 16 + tests/eibc_feemarket_test.go | 16 +- tests/eibc_fulfillment_test.go | 12 +- tests/eibc_invariant_test.go | 2 +- tests/genesis_transfer_test.go | 1274 ++++++++++++++++---------------- 8 files changed, 683 insertions(+), 651 deletions(-) diff --git a/go.mod b/go.mod index f5a322f0..026584ec 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/rollup-e2e-testing v0.0.0-20240915121335-ddec1ae61af9 + github.com/decentrio/rollup-e2e-testing v0.0.0-20240916050430-2e0921df7103 github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240911123104-4782bc4e587f github.com/dymensionxyz/dymint v1.2.0-rc01 ) diff --git a/go.sum b/go.sum index 94e515fa..57a98ba6 100644 --- a/go.sum +++ b/go.sum @@ -770,8 +770,8 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 h1:qWpUYGOsrSC+1Vmd2TjhbsSpntvvx9PsX3AoeMunFxc= github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869/go.mod h1:HZNYnPwmSxkwTPjSD5yolauc1Vx1ZzKL4FFMxTq4H5Y= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240915121335-ddec1ae61af9 h1:nLpSvNKjfhl2oG3T0ZDGkg0V82B2KD6pCdHz89bAjM4= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240915121335-ddec1ae61af9/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240916050430-2e0921df7103 h1:Oe4PR5yoyB1ALwi5CkN38M9VKHIIxWvvMbk/BORvMpQ= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240916050430-2e0921df7103/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/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= diff --git a/tests/admc_test.go b/tests/admc_test.go index 5f21a1e3..0144cd57 100644 --- a/tests/admc_test.go +++ b/tests/admc_test.go @@ -304,7 +304,7 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { resp, err := dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) - require.Equal(t, 2, len(resp.Metadatas)) + require.Equal(t, 1, len(resp.Metadatas)) // Send a normal ibc tx from RA -> Hub transferData := ibc.WalletData{ @@ -532,7 +532,7 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { resp, err := dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) - require.Equal(t, 2, len(resp.Metadatas)) + require.Equal(t, 1, len(resp.Metadatas)) // Send a normal ibc tx from RA -> Hub transferData := ibc.WalletData{ @@ -937,7 +937,7 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { resp, err := dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) - require.Equal(t, 2, len(resp.Metadatas)) + require.Equal(t, 1, len(resp.Metadatas)) // Send a normal ibc tx from RA -> Hub transferData := ibc.WalletData{ @@ -1162,7 +1162,7 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { resp, err := dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) - require.Equal(t, 2, len(resp.Metadatas)) + require.Equal(t, 1, len(resp.Metadatas)) // Send a normal ibc tx from RA -> Hub transferData := ibc.WalletData{ diff --git a/tests/eibc_ack_error_test.go b/tests/eibc_ack_error_test.go index 09fc3bcb..384680ea 100644 --- a/tests/eibc_ack_error_test.go +++ b/tests/eibc_ack_error_test.go @@ -687,6 +687,10 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, transferAmount) // end of preconditions @@ -1098,6 +1102,10 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, thirdPartyDenom, transferAmount) // user from rollapp1 should have funds to be able to make the ibc transfer transaction transferData = ibc.WalletData{ @@ -1888,6 +1896,10 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, transferAmount) // end of preconditions @@ -2253,6 +2265,10 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, thirdPartyDenom, transferAmount) // user from rollapp1 should have funds to be able to make the ibc transfer transaction transferData = ibc.WalletData{ diff --git a/tests/eibc_feemarket_test.go b/tests/eibc_feemarket_test.go index 847edb9c..284dae77 100644 --- a/tests/eibc_feemarket_test.go +++ b/tests/eibc_feemarket_test.go @@ -1918,7 +1918,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 80, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) fmt.Println("Event:", eibcEvents) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom)) @@ -1959,11 +1959,19 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_time"] = "20s" + dymintTomlOverrides["batch_submit_time"] = "50s" dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(100), + }, + ) + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -2009,7 +2017,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2141,7 +2149,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 50, false) require.NoError(t, err) fmt.Println("Event:", eibcEvents) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom)) diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 6d75c70a..8631f8fd 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -1419,6 +1419,14 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { maxIdleTime2 := "1s" configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(100), + }, + ) + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -1485,7 +1493,7 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1709,7 +1717,7 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { require.Equal(t, "PENDING", eibcEvents[1].PacketStatus) // fulfill demand order 2 - txhash, err = dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-2].OrderId, marketMakerAddr, eibcFee) + txhash, err = dymension.FullfillDemandOrder(ctx, eibcEvents[1].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) eibcEvent = getEibcEventFromTx(t, dymension, txhash) diff --git a/tests/eibc_invariant_test.go b/tests/eibc_invariant_test.go index 4a167f11..24ea7a20 100644 --- a/tests/eibc_invariant_test.go +++ b/tests/eibc_invariant_test.go @@ -210,7 +210,7 @@ func TestEIBCInvariant_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 10, dymension) + err = testutil.WaitForBlocks(ctx, 30, dymension) require.NoError(t, err) // Minus 0.1% of transfer amount for bridge fee diff --git a/tests/genesis_transfer_test.go b/tests/genesis_transfer_test.go index ad12f66b..cd858718 100644 --- a/tests/genesis_transfer_test.go +++ b/tests/genesis_transfer_test.go @@ -1,644 +1,644 @@ package tests -import ( - "context" - "fmt" - "testing" - - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - "github.com/stretchr/testify/require" - "go.uber.org/zap/zaptest" - - test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" - "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" - "github.com/decentrio/rollup-e2e-testing/ibc" - "github.com/decentrio/rollup-e2e-testing/relayer" - "github.com/decentrio/rollup-e2e-testing/testreporter" - "github.com/decentrio/rollup-e2e-testing/testutil" -) +// import ( +// "context" +// "fmt" +// "testing" + +// transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" +// "github.com/stretchr/testify/require" +// "go.uber.org/zap/zaptest" + +// test "github.com/decentrio/rollup-e2e-testing" +// "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" +// "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" +// "github.com/decentrio/rollup-e2e-testing/ibc" +// "github.com/decentrio/rollup-e2e-testing/relayer" +// "github.com/decentrio/rollup-e2e-testing/testreporter" +// "github.com/decentrio/rollup-e2e-testing/testutil" +// ) // TestGenesisTransfer_EVM -func TestGenesisTransferBridgeBlocking_EVM(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "3s" - dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_time"] = "50s" - dymintTomlOverrides["p2p_blocksync_enabled"] = "false" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppFn := 0 - numRollAppVals := 1 - - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ - { - Name: "rollapp1", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappevm_1234-1", - Images: []ibc.DockerImage{rollappEVMImage}, - Bin: "rollappd", - Bech32Prefix: "ethm", - Denom: "urax", - CoinType: "60", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, - { - Name: "dymension-hub", - ChainConfig: dymensionConfig, - NumValidators: &numHubVals, - NumFullNodes: &numHubFullNodes, - }, - }) - - // Get chains from the chain factory - chains, err := cf.Chains(t.Name()) - require.NoError(t, err) - - rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - dymension := chains[1].(*dym_hub.DymHub) - - // Relayer Factory - client, network := test.DockerSetup(t) - - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer", network) - - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) - - rep := testreporter.NewNopReporter() - eRep := rep.RelayerExecReporter(t) - - err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ - TestName: t.Name(), - Client: client, - NetworkID: network, - 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(), - }, nil, "", nil) - require.NoError(t, err) - - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Get our Bech32 encoded user addresses - dymensionUser, rollappUser := users[0], users[1] - - dymensionUserAddr := dymensionUser.FormattedAddress() - rollappUserAddr := rollappUser.FormattedAddress() - - 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) - - // Send a normal ibc tx from RA -> Hub - transferData := ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - // Compose an IBC transfer and send from dymension -> rollapp - transferData = ibc.WalletData{ - Address: rollappUserAddr, - Denom: dymension.Config().Denom, - Amount: transferAmount, - } - - // Compose an IBC transfer and send from Hub -> rollapp - _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - // Get the IBC denom - dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - - // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) - rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - - // after a while, refund token - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) - - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) -} - -func TestGenesisTransferBridgeBlocking_Wasm(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "3s" - dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_time"] = "50s" - dymintTomlOverrides["p2p_blocksync_enabled"] = "false" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppFn := 0 - numRollAppVals := 1 - - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ - { - Name: "rollapp1", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappwasm_1234-1", - Images: []ibc.DockerImage{rollappWasmImage}, - Bin: "rollappd", - Bech32Prefix: "rol", - Denom: "urax", - CoinType: "118", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), - ConfigFileOverrides: configFileOverrides, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, - { - Name: "dymension-hub", - ChainConfig: dymensionConfig, - NumValidators: &numHubVals, - NumFullNodes: &numHubFullNodes, - }, - }) - - // Get chains from the chain factory - chains, err := cf.Chains(t.Name()) - require.NoError(t, err) - - rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - dymension := chains[1].(*dym_hub.DymHub) - - // Relayer Factory - client, network := test.DockerSetup(t) - - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer", network) - - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) - - rep := testreporter.NewNopReporter() - eRep := rep.RelayerExecReporter(t) - - err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ - TestName: t.Name(), - Client: client, - NetworkID: network, - 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(), - }, nil, "", nil) - require.NoError(t, err) - - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Get our Bech32 encoded user addresses - dymensionUser, rollappUser := users[0], users[1] - - dymensionUserAddr := dymensionUser.FormattedAddress() - rollappUserAddr := rollappUser.FormattedAddress() - - 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) - - // Send a normal ibc tx from RA -> Hub - transferData := ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - // Compose an IBC transfer and send from dymension -> rollapp - transferData = ibc.WalletData{ - Address: rollappUserAddr, - Denom: dymension.Config().Denom, - Amount: transferAmount, - } - - // Compose an IBC transfer and send from Hub -> rollapp - _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - // Get the IBC denom - dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - - // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) - rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - - // after a while, refund token - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) - - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) -} - -func TestGenesisTransferConnectionBlock_EVM(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "3s" - dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_time"] = "50s" - dymintTomlOverrides["p2p_blocksync_enabled"] = "false" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppFn := 0 - numRollAppVals := 1 - - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ - { - Name: "rollapp1", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappevm_1234-1", - Images: []ibc.DockerImage{rollappEVMImage}, - Bin: "rollappd", - Bech32Prefix: "ethm", - Denom: "urax", - CoinType: "60", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, - { - Name: "dymension-hub", - ChainConfig: dymensionConfig, - NumValidators: &numHubVals, - NumFullNodes: &numHubFullNodes, - }, - }) - - // Get chains from the chain factory - chains, err := cf.Chains(t.Name()) - require.NoError(t, err) - - rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - dymension := chains[1].(*dym_hub.DymHub) - - // Relayer Factory - client, network := test.DockerSetup(t) - - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer", network) - - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) - - rep := testreporter.NewNopReporter() - eRep := rep.RelayerExecReporter(t) - - err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ - TestName: t.Name(), - Client: client, - NetworkID: network, - 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(), - }, nil, "", nil) - require.NoError(t, err) - - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Get our Bech32 encoded user addresses - dymensionUser, rollappUser := users[0], users[1] - - dymensionUserAddr := dymensionUser.FormattedAddress() - rollappUserAddr := rollappUser.FormattedAddress() - - 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, 10, dymension, rollapp1) - require.NoError(t, err) - - // Send a normal ibc tx from RA -> Hub - transferData := ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.NoError(t, err) - - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - - // 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, 10, dymension, rollapp1) - require.NoError(t, err) - - // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) - rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - - // Minus 0.1% of transfer amount for bridge fee - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - - // Try to open a connection with the relayer with RA as chainA - err = r.GeneratePath(ctx, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID, "demo-dymension") - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, "demo-dymension", ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 20, rollapp1, dymension) - require.NoError(t, err) - - err = r.CreateConnectionsWithNumberOfRetries(ctx, eRep, "demo-dymension", "3") - require.NoError(t, err) - - connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) - require.NoError(t, err) - require.Equal(t, 2, len(connections)) -} - -func TestGenesisTransferConnectionBlock_Wasm(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "3s" - dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_time"] = "50s" - dymintTomlOverrides["p2p_blocksync_enabled"] = "false" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppFn := 0 - numRollAppVals := 1 - - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ - { - Name: "rollapp1", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappwasm_1234-1", - Images: []ibc.DockerImage{rollappWasmImage}, - Bin: "rollappd", - Bech32Prefix: "rol", - Denom: "urax", - CoinType: "118", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), - ConfigFileOverrides: configFileOverrides, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, - { - Name: "dymension-hub", - ChainConfig: dymensionConfig, - NumValidators: &numHubVals, - NumFullNodes: &numHubFullNodes, - }, - }) - - // Get chains from the chain factory - chains, err := cf.Chains(t.Name()) - require.NoError(t, err) - - rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - dymension := chains[1].(*dym_hub.DymHub) - - // Relayer Factory - client, network := test.DockerSetup(t) - - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer", network) - - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) - - rep := testreporter.NewNopReporter() - eRep := rep.RelayerExecReporter(t) - - err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ - TestName: t.Name(), - Client: client, - NetworkID: network, - 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(), - }, nil, "", nil) - require.NoError(t, err) - - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Get our Bech32 encoded user addresses - dymensionUser, rollappUser := users[0], users[1] - - dymensionUserAddr := dymensionUser.FormattedAddress() - rollappUserAddr := rollappUser.FormattedAddress() - - 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, 10, dymension, rollapp1) - require.NoError(t, err) - - // Send a normal ibc tx from RA -> Hub - transferData := ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.NoError(t, err) - - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - - // 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, 10, dymension, rollapp1) - require.NoError(t, err) - - // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) - rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - - // Minus 0.1% of transfer amount for bridge fee - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - - // Try to open a connection with the relayer with RA as chainA - err = r.GeneratePath(ctx, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID, "demo-dymension") - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, "demo-dymension", ibc.DefaultClientOpts()) - require.NoError(t, err) +// func TestGenesisTransferBridgeBlocking_EVM(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } + +// ctx := context.Background() + +// configFileOverrides := make(map[string]any) +// dymintTomlOverrides := make(testutil.Toml) +// dymintTomlOverrides["settlement_layer"] = "dymension" +// dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) +// dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" +// dymintTomlOverrides["settlement_gas_prices"] = "0adym" +// dymintTomlOverrides["max_idle_time"] = "3s" +// dymintTomlOverrides["max_proof_time"] = "500ms" +// dymintTomlOverrides["batch_submit_time"] = "50s" +// dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + +// configFileOverrides["config/dymint.toml"] = dymintTomlOverrides +// // Create chain factory with dymension +// numHubVals := 1 +// numHubFullNodes := 1 +// numRollAppFn := 0 +// numRollAppVals := 1 + +// cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ +// { +// Name: "rollapp1", +// ChainConfig: ibc.ChainConfig{ +// Type: "rollapp-dym", +// Name: "rollapp-temp", +// ChainID: "rollappevm_1234-1", +// Images: []ibc.DockerImage{rollappEVMImage}, +// Bin: "rollappd", +// Bech32Prefix: "ethm", +// Denom: "urax", +// CoinType: "60", +// GasPrices: "0.0urax", +// GasAdjustment: 1.1, +// TrustingPeriod: "112h", +// EncodingConfig: encodingConfig(), +// NoHostMount: false, +// ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), +// ConfigFileOverrides: configFileOverrides, +// }, +// NumValidators: &numRollAppVals, +// NumFullNodes: &numRollAppFn, +// }, +// { +// Name: "dymension-hub", +// ChainConfig: dymensionConfig, +// NumValidators: &numHubVals, +// NumFullNodes: &numHubFullNodes, +// }, +// }) + +// // Get chains from the chain factory +// chains, err := cf.Chains(t.Name()) +// require.NoError(t, err) + +// rollapp1 := chains[0].(*dym_rollapp.DymRollApp) +// dymension := chains[1].(*dym_hub.DymHub) + +// // Relayer Factory +// client, network := test.DockerSetup(t) + +// r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), +// relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), +// ).Build(t, client, "relayer", network) + +// ic := test.NewSetup(). +// AddRollUp(dymension, rollapp1). +// AddRelayer(r, "relayer"). +// AddLink(test.InterchainLink{ +// Chain1: dymension, +// Chain2: rollapp1, +// Relayer: r, +// Path: ibcPath, +// }) + +// rep := testreporter.NewNopReporter() +// eRep := rep.RelayerExecReporter(t) + +// err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ +// TestName: t.Name(), +// Client: client, +// NetworkID: network, +// 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(), +// }, nil, "", nil) +// require.NoError(t, err) + +// CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + +// // Create some user accounts on both chains +// users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + +// // Get our Bech32 encoded user addresses +// dymensionUser, rollappUser := users[0], users[1] + +// dymensionUserAddr := dymensionUser.FormattedAddress() +// rollappUserAddr := rollappUser.FormattedAddress() + +// 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) + +// // Send a normal ibc tx from RA -> Hub +// transferData := ibc.WalletData{ +// Address: dymensionUserAddr, +// Denom: rollapp1.Config().Denom, +// Amount: transferAmount, +// } +// _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) +// require.Error(t, err) + +// // Compose an IBC transfer and send from dymension -> rollapp +// transferData = ibc.WalletData{ +// Address: rollappUserAddr, +// Denom: dymension.Config().Denom, +// Amount: transferAmount, +// } + +// // Compose an IBC transfer and send from Hub -> rollapp +// _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) +// require.Error(t, err) + +// err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Get the IBC denom +// dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) +// dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + +// // Get the IBC denom for urax on Hub +// rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) +// rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + +// // after a while, refund token +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) +// } + +// func TestGenesisTransferBridgeBlocking_Wasm(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } + +// ctx := context.Background() + +// configFileOverrides := make(map[string]any) +// dymintTomlOverrides := make(testutil.Toml) +// dymintTomlOverrides["settlement_layer"] = "dymension" +// dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) +// dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" +// dymintTomlOverrides["settlement_gas_prices"] = "0adym" +// dymintTomlOverrides["max_idle_time"] = "3s" +// dymintTomlOverrides["max_proof_time"] = "500ms" +// dymintTomlOverrides["batch_submit_time"] = "50s" +// dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + +// configFileOverrides["config/dymint.toml"] = dymintTomlOverrides +// // Create chain factory with dymension +// numHubVals := 1 +// numHubFullNodes := 1 +// numRollAppFn := 0 +// numRollAppVals := 1 + +// cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ +// { +// Name: "rollapp1", +// ChainConfig: ibc.ChainConfig{ +// Type: "rollapp-dym", +// Name: "rollapp-temp", +// ChainID: "rollappwasm_1234-1", +// Images: []ibc.DockerImage{rollappWasmImage}, +// Bin: "rollappd", +// Bech32Prefix: "rol", +// Denom: "urax", +// CoinType: "118", +// GasPrices: "0.0urax", +// GasAdjustment: 1.1, +// TrustingPeriod: "112h", +// EncodingConfig: encodingConfig(), +// NoHostMount: false, +// ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), +// ConfigFileOverrides: configFileOverrides, +// }, +// NumValidators: &numRollAppVals, +// NumFullNodes: &numRollAppFn, +// }, +// { +// Name: "dymension-hub", +// ChainConfig: dymensionConfig, +// NumValidators: &numHubVals, +// NumFullNodes: &numHubFullNodes, +// }, +// }) + +// // Get chains from the chain factory +// chains, err := cf.Chains(t.Name()) +// require.NoError(t, err) + +// rollapp1 := chains[0].(*dym_rollapp.DymRollApp) +// dymension := chains[1].(*dym_hub.DymHub) + +// // Relayer Factory +// client, network := test.DockerSetup(t) + +// r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), +// relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), +// ).Build(t, client, "relayer", network) + +// ic := test.NewSetup(). +// AddRollUp(dymension, rollapp1). +// AddRelayer(r, "relayer"). +// AddLink(test.InterchainLink{ +// Chain1: dymension, +// Chain2: rollapp1, +// Relayer: r, +// Path: ibcPath, +// }) + +// rep := testreporter.NewNopReporter() +// eRep := rep.RelayerExecReporter(t) + +// err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ +// TestName: t.Name(), +// Client: client, +// NetworkID: network, +// 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(), +// }, nil, "", nil) +// require.NoError(t, err) + +// CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + +// // Create some user accounts on both chains +// users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + +// // Get our Bech32 encoded user addresses +// dymensionUser, rollappUser := users[0], users[1] + +// dymensionUserAddr := dymensionUser.FormattedAddress() +// rollappUserAddr := rollappUser.FormattedAddress() + +// 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) + +// // Send a normal ibc tx from RA -> Hub +// transferData := ibc.WalletData{ +// Address: dymensionUserAddr, +// Denom: rollapp1.Config().Denom, +// Amount: transferAmount, +// } +// _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) +// require.Error(t, err) + +// // Compose an IBC transfer and send from dymension -> rollapp +// transferData = ibc.WalletData{ +// Address: rollappUserAddr, +// Denom: dymension.Config().Denom, +// Amount: transferAmount, +// } + +// // Compose an IBC transfer and send from Hub -> rollapp +// _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) +// require.Error(t, err) + +// err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Get the IBC denom +// dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) +// dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + +// // Get the IBC denom for urax on Hub +// rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) +// rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + +// // after a while, refund token +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) +// } + +// func TestGenesisTransferConnectionBlock_EVM(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } + +// ctx := context.Background() + +// configFileOverrides := make(map[string]any) +// dymintTomlOverrides := make(testutil.Toml) +// dymintTomlOverrides["settlement_layer"] = "dymension" +// dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) +// dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" +// dymintTomlOverrides["settlement_gas_prices"] = "0adym" +// dymintTomlOverrides["max_idle_time"] = "3s" +// dymintTomlOverrides["max_proof_time"] = "500ms" +// dymintTomlOverrides["batch_submit_time"] = "50s" +// dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + +// configFileOverrides["config/dymint.toml"] = dymintTomlOverrides +// // Create chain factory with dymension +// numHubVals := 1 +// numHubFullNodes := 1 +// numRollAppFn := 0 +// numRollAppVals := 1 + +// cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ +// { +// Name: "rollapp1", +// ChainConfig: ibc.ChainConfig{ +// Type: "rollapp-dym", +// Name: "rollapp-temp", +// ChainID: "rollappevm_1234-1", +// Images: []ibc.DockerImage{rollappEVMImage}, +// Bin: "rollappd", +// Bech32Prefix: "ethm", +// Denom: "urax", +// CoinType: "60", +// GasPrices: "0.0urax", +// GasAdjustment: 1.1, +// TrustingPeriod: "112h", +// EncodingConfig: encodingConfig(), +// NoHostMount: false, +// ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), +// ConfigFileOverrides: configFileOverrides, +// }, +// NumValidators: &numRollAppVals, +// NumFullNodes: &numRollAppFn, +// }, +// { +// Name: "dymension-hub", +// ChainConfig: dymensionConfig, +// NumValidators: &numHubVals, +// NumFullNodes: &numHubFullNodes, +// }, +// }) + +// // Get chains from the chain factory +// chains, err := cf.Chains(t.Name()) +// require.NoError(t, err) + +// rollapp1 := chains[0].(*dym_rollapp.DymRollApp) +// dymension := chains[1].(*dym_hub.DymHub) + +// // Relayer Factory +// client, network := test.DockerSetup(t) + +// r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), +// relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), +// ).Build(t, client, "relayer", network) + +// ic := test.NewSetup(). +// AddRollUp(dymension, rollapp1). +// AddRelayer(r, "relayer"). +// AddLink(test.InterchainLink{ +// Chain1: dymension, +// Chain2: rollapp1, +// Relayer: r, +// Path: ibcPath, +// }) + +// rep := testreporter.NewNopReporter() +// eRep := rep.RelayerExecReporter(t) + +// err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ +// TestName: t.Name(), +// Client: client, +// NetworkID: network, +// 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(), +// }, nil, "", nil) +// require.NoError(t, err) + +// CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + +// // Create some user accounts on both chains +// users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + +// // Get our Bech32 encoded user addresses +// dymensionUser, rollappUser := users[0], users[1] + +// dymensionUserAddr := dymensionUser.FormattedAddress() +// rollappUserAddr := rollappUser.FormattedAddress() + +// 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, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Send a normal ibc tx from RA -> Hub +// transferData := ibc.WalletData{ +// Address: dymensionUserAddr, +// Denom: rollapp1.Config().Denom, +// Amount: transferAmount, +// } +// _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) +// require.NoError(t, err) + +// rollappHeight, err := rollapp1.GetNode().Height(ctx) +// require.NoError(t, err) + +// // Assert balance was updated on the hub +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + +// // 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, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Get the IBC denom for urax on Hub +// rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) +// rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + +// // Minus 0.1% of transfer amount for bridge fee +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + +// // Try to open a connection with the relayer with RA as chainA +// err = r.GeneratePath(ctx, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID, "demo-dymension") +// require.NoError(t, err) + +// err = r.CreateClients(ctx, eRep, "demo-dymension", ibc.DefaultClientOpts()) +// require.NoError(t, err) + +// err = testutil.WaitForBlocks(ctx, 20, rollapp1, dymension) +// require.NoError(t, err) + +// err = r.CreateConnectionsWithNumberOfRetries(ctx, eRep, "demo-dymension", "3") +// require.NoError(t, err) + +// connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) +// require.NoError(t, err) +// require.Equal(t, 2, len(connections)) +// } + +// func TestGenesisTransferConnectionBlock_Wasm(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } + +// ctx := context.Background() + +// configFileOverrides := make(map[string]any) +// dymintTomlOverrides := make(testutil.Toml) +// dymintTomlOverrides["settlement_layer"] = "dymension" +// dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) +// dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" +// dymintTomlOverrides["settlement_gas_prices"] = "0adym" +// dymintTomlOverrides["max_idle_time"] = "3s" +// dymintTomlOverrides["max_proof_time"] = "500ms" +// dymintTomlOverrides["batch_submit_time"] = "50s" +// dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + +// configFileOverrides["config/dymint.toml"] = dymintTomlOverrides +// // Create chain factory with dymension +// numHubVals := 1 +// numHubFullNodes := 1 +// numRollAppFn := 0 +// numRollAppVals := 1 + +// cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ +// { +// Name: "rollapp1", +// ChainConfig: ibc.ChainConfig{ +// Type: "rollapp-dym", +// Name: "rollapp-temp", +// ChainID: "rollappwasm_1234-1", +// Images: []ibc.DockerImage{rollappWasmImage}, +// Bin: "rollappd", +// Bech32Prefix: "rol", +// Denom: "urax", +// CoinType: "118", +// GasPrices: "0.0urax", +// GasAdjustment: 1.1, +// TrustingPeriod: "112h", +// EncodingConfig: encodingConfig(), +// NoHostMount: false, +// ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), +// ConfigFileOverrides: configFileOverrides, +// }, +// NumValidators: &numRollAppVals, +// NumFullNodes: &numRollAppFn, +// }, +// { +// Name: "dymension-hub", +// ChainConfig: dymensionConfig, +// NumValidators: &numHubVals, +// NumFullNodes: &numHubFullNodes, +// }, +// }) + +// // Get chains from the chain factory +// chains, err := cf.Chains(t.Name()) +// require.NoError(t, err) + +// rollapp1 := chains[0].(*dym_rollapp.DymRollApp) +// dymension := chains[1].(*dym_hub.DymHub) + +// // Relayer Factory +// client, network := test.DockerSetup(t) + +// r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), +// relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), +// ).Build(t, client, "relayer", network) + +// ic := test.NewSetup(). +// AddRollUp(dymension, rollapp1). +// AddRelayer(r, "relayer"). +// AddLink(test.InterchainLink{ +// Chain1: dymension, +// Chain2: rollapp1, +// Relayer: r, +// Path: ibcPath, +// }) + +// rep := testreporter.NewNopReporter() +// eRep := rep.RelayerExecReporter(t) + +// err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ +// TestName: t.Name(), +// Client: client, +// NetworkID: network, +// 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(), +// }, nil, "", nil) +// require.NoError(t, err) + +// CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + +// // Create some user accounts on both chains +// users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + +// // Get our Bech32 encoded user addresses +// dymensionUser, rollappUser := users[0], users[1] + +// dymensionUserAddr := dymensionUser.FormattedAddress() +// rollappUserAddr := rollappUser.FormattedAddress() + +// 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, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Send a normal ibc tx from RA -> Hub +// transferData := ibc.WalletData{ +// Address: dymensionUserAddr, +// Denom: rollapp1.Config().Denom, +// Amount: transferAmount, +// } +// _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) +// require.NoError(t, err) + +// rollappHeight, err := rollapp1.GetNode().Height(ctx) +// require.NoError(t, err) + +// // Assert balance was updated on the hub +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + +// // 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, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Get the IBC denom for urax on Hub +// rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) +// rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + +// // Minus 0.1% of transfer amount for bridge fee +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + +// // Try to open a connection with the relayer with RA as chainA +// err = r.GeneratePath(ctx, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID, "demo-dymension") +// require.NoError(t, err) + +// err = r.CreateClients(ctx, eRep, "demo-dymension", ibc.DefaultClientOpts()) +// require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, rollapp1, dymension) - require.NoError(t, err) +// err = testutil.WaitForBlocks(ctx, 20, rollapp1, dymension) +// require.NoError(t, err) - err = r.CreateConnectionsWithNumberOfRetries(ctx, eRep, "demo-dymension", "3") - require.NoError(t, err) +// err = r.CreateConnectionsWithNumberOfRetries(ctx, eRep, "demo-dymension", "3") +// require.NoError(t, err) - connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) - require.NoError(t, err) - require.Equal(t, 2, len(connections)) -} +// connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) +// require.NoError(t, err) +// require.Equal(t, 2, len(connections)) +// }