From 04e62873a7522232962c37de2b83599f2bdae93c Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Thu, 12 Dec 2024 21:38:13 +0700 Subject: [PATCH 1/2] Fix tests (#548) --- tests/admc_test.go | 80 + tests/automated_denommetadata_test.go | 105 +- tests/bridging_fee_test.go | 23 + tests/canonical_light_client_test.go | 10 + tests/data/config.yaml | 4 +- tests/eibc_ack_error_test.go | 176 +- tests/eibc_client_test.go | 20 + tests/eibc_corrupted_memo_test.go | 10 + tests/eibc_fee_market_test.go | 121 +- tests/eibc_fee_test.go | 10 + tests/eibc_feemarket_test.go | 164 +- tests/eibc_fulfillment_test.go | 285 ++- tests/eibc_invariant_test.go | 41 +- tests/eibc_nobalance_test.go | 10 + tests/eibc_not_fulfillment_test.go | 46 + tests/eibc_pfm_test.go | 46 + tests/eibc_timeout_test.go | 47 +- tests/erc20_ibc_transfer_test.go | 20 + tests/frozen_test.go | 244 +++ tests/fullnode_sync_gossip_test.go | 7 +- tests/fullnode_sync_test.go | 8 +- tests/genesis_bridge_test.go | 127 ++ tests/hardfork_test.go | 43 + tests/ibc_finalize_block_test.go | 60 + tests/ibc_grace_period_test.go | 138 ++ tests/ibc_timeout_test.go | 26 + tests/ibc_transfer_test.go | 20 + tests/rollapp_invariant_test.go | 46 + tests/rollapp_state_update_test.go | 347 ++-- tests/rollapp_upgrade_test.go | 525 +----- tests/sequencer_reward_address_test.go | 32 +- tests/sequencer_rotation_test.go | 2270 +++++++++++++++--------- tests/sequencer_test.go | 8 + tests/setup.go | 4 + tests/time_upgrade_test.go | 20 + tests/zero_fee_relay_test.go | 35 + 36 files changed, 3552 insertions(+), 1626 deletions(-) diff --git a/tests/admc_test.go b/tests/admc_test.go index 3908a0a7..a5fa6d98 100644 --- a/tests/admc_test.go +++ b/tests/admc_test.go @@ -114,6 +114,16 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -304,6 +314,16 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -572,6 +592,16 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -846,6 +876,16 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1036,6 +1076,16 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1301,6 +1351,16 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1600,6 +1660,16 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1820,6 +1890,16 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/automated_denommetadata_test.go b/tests/automated_denommetadata_test.go index 8afffca3..69be7328 100644 --- a/tests/automated_denommetadata_test.go +++ b/tests/automated_denommetadata_test.go @@ -178,6 +178,29 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -477,6 +500,16 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -788,6 +821,29 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -1127,6 +1183,29 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -1396,6 +1475,16 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1609,6 +1698,16 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1696,7 +1795,7 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { require.NoError(t, err) // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, zeroBal) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, math.NewInt(9999999999).MulRaw(1000000000000)) err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) @@ -1705,8 +1804,8 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, zeroBal) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, math.NewInt(9999999999).MulRaw(1000000000000)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(1000000000000)) // Rollapp record on the hub updated with new token metadata (”adym”) _, err = dymension.Validators[0].QueryDenomMetadata(ctx, "adym") diff --git a/tests/bridging_fee_test.go b/tests/bridging_fee_test.go index da25076a..dd75cbe1 100644 --- a/tests/bridging_fee_test.go +++ b/tests/bridging_fee_test.go @@ -311,6 +311,29 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) diff --git a/tests/canonical_light_client_test.go b/tests/canonical_light_client_test.go index 44dbe1ca..dd5e0ab4 100644 --- a/tests/canonical_light_client_test.go +++ b/tests/canonical_light_client_test.go @@ -350,6 +350,16 @@ func TestIBCTransferRA_3rdSameChainID_EVM(t *testing.T) { _ = ic.Close() }) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // create ibc path between dymension and gaia, and between dymension and rollapp1 CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) diff --git a/tests/data/config.yaml b/tests/data/config.yaml index cb6c6516..faf5c8db 100755 --- a/tests/data/config.yaml +++ b/tests/data/config.yaml @@ -14,7 +14,7 @@ rollapps: operator: account_name: operator keyring_backend: test - keyring_dir: /root/dymension-hub-23178b163d7657756ac67866264ed2fe170c844484f936b450812745a2bdf2931 + keyring_dir: /root/dymension-hub-2f33fad87cfda9a25dcc73a51d58fd07fe17be51a4503c84976b14a9d7634c43e group_id: 1 min_fee_share: "0.1" fulfillers: @@ -22,7 +22,7 @@ fulfillers: operator_address: "" policy_address: dym1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzs8ag8zm keyring_backend: test - keyring_dir: /root/dymension-hub-23178b163d7657756ac67866264ed2fe170c844484f936b450812745a2bdf2931 + keyring_dir: /root/dymension-hub-2f33fad87cfda9a25dcc73a51d58fd07fe17be51a4503c84976b14a9d7634c43e batch_size: 0 max_orders_per_tx: 5 validation: diff --git a/tests/eibc_ack_error_test.go b/tests/eibc_ack_error_test.go index 67216408..aa3420bf 100644 --- a/tests/eibc_ack_error_test.go +++ b/tests/eibc_ack_error_test.go @@ -173,6 +173,29 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -658,6 +681,29 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1118,6 +1164,29 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1651,6 +1720,29 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1778,11 +1870,6 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) for _, packet := range res.RollappPackets { - - proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) @@ -1813,8 +1900,9 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) + // // prop to disable ibc transfer on rollapp receiveEnableParams := json.RawMessage(`false`) _, err = dymension.GetNode().ParamChangeProposal(ctx, dymensionUser.KeyName(), @@ -1835,6 +1923,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err, "error fetching height") _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+30, "1", cosmos.ProposalStatusPassed) require.NoError(t, err, "proposal status did not change to passed") + // transferData = ibc.WalletData{ Address: dymensionUserAddr, @@ -1857,10 +1946,9 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) - rollappHeight, err = rollapp1.Height(ctx) + 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) @@ -1881,16 +1969,24 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { fmt.Println(txhash) } - ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+30, ibcTx.Packet) + ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+80, ibcTx.Packet) require.NoError(t, err) + fmt.Println("ack:", ack.Acknowledgement) + // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) - - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) // At the moment, the ack returned and the demand order status became "finalized" // We will execute the ibc transfer again and try to fulfill the demand order + balance, err = rollapp1.GetBalance(ctx, rollappUserAddr, dymensionIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of rollappUserAddr right before sending eIBC transfer (that fulfilled):", balance) + balance, err = rollapp1.GetBalance(ctx, rollappUserAddr, dymensionIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of moduleAccAddr right before sending eIBC transfer (that fulfilled):", balance) + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) @@ -1898,7 +1994,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) fmt.Println(eibcEvents) - require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") + require.Equal(t, eibcEvents[0].PacketStatus, "PENDING") // Get the balance of dymensionUserAddr and marketMakerAddr before fulfill the demand order dymensionUserBalance, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) @@ -1907,7 +2003,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].OrderId, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1939,7 +2035,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -1964,7 +2060,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.True(t, balance.Equal(expMmBalanceDymDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceDymDenom, balance)) // wait for a few blocks and check if the fund returns to rollapp - testutil.WaitForBlocks(ctx, 20, rollapp1) + testutil.WaitForBlocks(ctx, BLOCK_FINALITY_PERIOD+10, rollapp1) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) }) @@ -2128,6 +2224,29 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -2406,7 +2525,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -2416,7 +2535,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -2586,6 +2705,29 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) diff --git a/tests/eibc_client_test.go b/tests/eibc_client_test.go index 97323d61..42678423 100644 --- a/tests/eibc_client_test.go +++ b/tests/eibc_client_test.go @@ -387,6 +387,16 @@ func Test_EIBC_Client_Success_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -958,6 +968,16 @@ func Test_EIBC_Client_NoFulfillRollapp_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index 8cdc8080..c4a80213 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -131,6 +131,16 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/eibc_fee_market_test.go b/tests/eibc_fee_market_test.go index b4abc5d8..f4f5ccbd 100644 --- a/tests/eibc_fee_market_test.go +++ b/tests/eibc_fee_market_test.go @@ -155,6 +155,29 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -528,6 +551,29 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -632,7 +678,7 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -642,7 +688,7 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -705,11 +751,8 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { require.Equal(t, true, fulfill_demand_order) // attempt to update the fee amount required by demand order that has already been fulfilled - txhash, err := dymension.UpdateDemandOrder(ctx, demand_order_id, dymensionUserAddr, eibcFee.MulRaw(2)) - require.NoError(t, err) - resp, err := dymension.GetTransaction(txhash) - require.NoError(t, err) - require.Equal(t, uint32(10), resp.Code) + _, err = dymension.UpdateDemandOrder(ctx, demand_order_id, dymensionUserAddr, eibcFee.MulRaw(2)) + require.Error(t, err) // wait a few blocks and verify sender received funds on the hub err = testutil.WaitForBlocks(ctx, 5, dymension) @@ -721,15 +764,15 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee), balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -745,6 +788,9 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { fmt.Println(txhash) } + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -901,6 +947,29 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1182,6 +1251,29 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1255,7 +1347,7 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -1265,7 +1357,7 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -1307,11 +1399,8 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { if re.ReplaceAllString(eibcEvent.Fee, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) // attempt to update the fee amount required by demand order with an unallowed signer - txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvent.OrderId, marketMakerAddr, eibcFee.MulRaw(2)) - require.NoError(t, err) - res, err := dymension.GetTransaction(txhash) - require.NoError(t, err) - require.Equal(t, uint32(4), res.Code) + _, err := dymension.UpdateDemandOrder(ctx, eibcEvent.OrderId, marketMakerAddr, eibcFee.MulRaw(2)) + require.Error(t, err) } } diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index f0f4e277..28a051bc 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -131,6 +131,16 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/eibc_feemarket_test.go b/tests/eibc_feemarket_test.go index c2df3f48..66333ddf 100644 --- a/tests/eibc_feemarket_test.go +++ b/tests/eibc_feemarket_test.go @@ -167,6 +167,29 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -495,6 +518,29 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -562,7 +608,7 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -572,7 +618,7 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -653,7 +699,7 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -663,7 +709,7 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -837,6 +883,29 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1163,6 +1232,29 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1231,7 +1323,7 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -1241,7 +1333,7 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -1315,7 +1407,7 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -1325,7 +1417,7 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -1457,6 +1549,16 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1727,6 +1829,16 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1874,7 +1986,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -1884,7 +1996,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -2019,6 +2131,16 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -2259,6 +2381,16 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -2325,7 +2457,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { fmt.Println(txhash) } - err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) // Compose an IBC transfer and send from hub to rollapp @@ -2366,19 +2498,15 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 80, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 60, false) require.NoError(t, err) fmt.Println("Event:", eibcEvents) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom)) require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, dymension.Config().Denom)) // modify demand order with new fee - txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) - require.NoError(t, err) - - resp, err := dymension.GetTransaction(txhash) - require.NoError(t, err) - require.True(t, (resp.Code == uint32(4)) || (resp.Code == uint32(5))) + _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) + require.Error(t, err) t.Cleanup( func() { diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 18a32cc2..515ef95e 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -172,6 +172,29 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -625,6 +648,29 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -766,7 +812,7 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -776,7 +822,7 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -857,18 +903,12 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee), balance)) - // verify correct funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmount)).Add(eibcFee).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) + // wait until the packet is finalized on Rollapps + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) @@ -877,10 +917,6 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { require.NoError(t, err) for _, packet := range res.RollappPackets { - - proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) - require.NoError(t, err) require.True(t, isFinalized) txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) @@ -888,25 +924,15 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { fmt.Println(txhash) } - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferDataRollapp1.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) - - // user should have received funds upon grace period of IBC packet from rollapp 2 rollappHeight, err = rollapp2.GetNode().Height(ctx) require.NoError(t, err) + // wait until the packet is finalized on Rollapps isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -916,15 +942,22 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) } - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + // verify correct funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // user should have received funds upon grace period of IBC packet from rollapp 2 + err = testutil.WaitForBlocks(ctx, 10, rollapp2) + require.NoError(t, err) balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr for rollapp 2 ibc denom after grace period:", balance) @@ -1105,6 +1138,29 @@ func TestEIBCFulfillment_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1429,6 +1485,29 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1497,7 +1576,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -1507,7 +1586,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -1521,9 +1600,8 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() var options ibc.TransferOptions - // Minus 0.1% of transfer amount for bridge fee - expMmBalanceRollappDenom := transferAmount.Sub(transferAmount.Quo(math.NewInt(1000))) + expMmBalanceRollappDenom := transferData.Amount.Sub(transferAmount.Quo(math.NewInt(1000))) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after preconditions:", balance) @@ -1539,7 +1617,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { // set eIBC specific memo options.Memo = BuildEIbcMemo(eibcFee) - _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + _, err = rollapp1.SendIBCTransfer(ctx, dymChannels[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) @@ -1551,7 +1629,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[0]) + fmt.Println("Event:", eibcEvents) // fulfill demand order txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) @@ -1572,7 +1650,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee), balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address + // verify funds were deducted from market maker's wallet address rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1580,7 +1658,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -1598,7 +1676,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) @@ -1764,6 +1842,29 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -2192,6 +2293,29 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -2644,6 +2768,29 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -2808,7 +2955,7 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -2818,7 +2965,7 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -2827,12 +2974,11 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee + expBalance := transferData.Amount.Sub(transferData.Amount.Quo(math.NewInt(1000))) balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) require.NoError(t, err) - - // Minus 0.1% of transfer amount for bridge fee - require.True(t, balance.Equal(transferAmount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee), balance)) - + require.True(t, balance.Equal(expBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalance, balance)) // done preparation transferData = ibc.WalletData{ @@ -2870,15 +3016,15 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee), balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -2894,6 +3040,9 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { fmt.Println(txhash) } + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -3070,6 +3219,29 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -3342,6 +3514,29 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) diff --git a/tests/eibc_invariant_test.go b/tests/eibc_invariant_test.go index 5c963e93..1e48dbdb 100644 --- a/tests/eibc_invariant_test.go +++ b/tests/eibc_invariant_test.go @@ -136,6 +136,16 @@ func TestEIBCInvariant_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -521,6 +531,29 @@ func TestEIBCInvariant_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -606,7 +639,7 @@ func TestEIBCInvariant_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -616,7 +649,7 @@ func TestEIBCInvariant_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) @@ -691,7 +724,7 @@ func TestEIBCInvariant_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -701,7 +734,7 @@ func TestEIBCInvariant_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index 6dab8101..d3a8a131 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -132,6 +132,16 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/eibc_not_fulfillment_test.go b/tests/eibc_not_fulfillment_test.go index 3d3050af..959728cf 100644 --- a/tests/eibc_not_fulfillment_test.go +++ b/tests/eibc_not_fulfillment_test.go @@ -169,6 +169,29 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -480,6 +503,29 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index 31be72dc..80e8fdbc 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -170,6 +170,29 @@ func TestEIBCPFM_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -466,6 +489,29 @@ func TestEIBCPFM_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 65c4aec0..aa217885 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -131,6 +131,16 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -488,6 +498,16 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -910,6 +930,29 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -1119,7 +1162,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, marketMakerAddr) fmt.Println(res) require.NoError(t, err) @@ -1129,7 +1172,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + txhash, err := dymension.GetNode().FinalizePacket(ctx, marketMakerAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) require.NoError(t, err) fmt.Println(txhash) diff --git a/tests/erc20_ibc_transfer_test.go b/tests/erc20_ibc_transfer_test.go index 11d3f45a..74bf5417 100644 --- a/tests/erc20_ibc_transfer_test.go +++ b/tests/erc20_ibc_transfer_test.go @@ -131,6 +131,16 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -373,6 +383,16 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 6be0b019..5f8e9fa9 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -176,6 +176,29 @@ func TestRollAppFreeze_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -561,6 +584,29 @@ func TestRollAppFreeze_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -937,6 +983,29 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := s.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1438,6 +1507,29 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := s.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1890,6 +1982,16 @@ func TestPacketRollbacked_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Start both relayers @@ -2264,6 +2366,16 @@ func TestPacketRollbacked_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Start both relayers @@ -2690,6 +2802,29 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := s.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -3070,6 +3205,29 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := s.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -3450,6 +3608,29 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := s.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -3905,6 +4086,29 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := s.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -4322,6 +4526,16 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Start both relayers @@ -4669,6 +4883,16 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Start both relayers @@ -5016,6 +5240,16 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Start both relayers @@ -5378,6 +5612,16 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Start both relayers diff --git a/tests/fullnode_sync_gossip_test.go b/tests/fullnode_sync_gossip_test.go index 3ebb7169..cf6fa734 100644 --- a/tests/fullnode_sync_gossip_test.go +++ b/tests/fullnode_sync_gossip_test.go @@ -654,9 +654,8 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { err = rollapp1.FullNodes[0].StopContainer(ctx) require.NoError(t, err) - _ = rollapp1.FullNodes[0].StartContainer(ctx) - - time.Sleep(30 * time.Second) + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) rollappHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -668,7 +667,7 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { valHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) - //Poll until full node is sync + // Poll until full node is sync err = testutil.WaitForCondition( time.Minute*50, time.Second*5, // each epoch is 5 seconds diff --git a/tests/fullnode_sync_test.go b/tests/fullnode_sync_test.go index 9bc323a2..572e70c4 100644 --- a/tests/fullnode_sync_test.go +++ b/tests/fullnode_sync_test.go @@ -33,7 +33,7 @@ import ( // StartDA start grpc DALC server func StartDA(ctx context.Context, t *testing.T, client *client.Client, net string) { fmt.Println("Starting pull image ...") - out, err := client.ImagePull(ctx, "ghcr.io/decentrio/dymint:srene-hardfork-fix-arm", types.ImagePullOptions{}) + out, err := client.ImagePull(ctx, "ghcr.io/decentrio/dymint:srene-hardfork-fix", types.ImagePullOptions{}) require.NoError(t, err) defer out.Close() @@ -57,14 +57,14 @@ func StartDA(ctx context.Context, t *testing.T, client *client.Client, net strin DNS: []string{}, ExtraHosts: []string{"host.docker.internal:host-gateway"}, } - // time.Sleep(2 * time.Minute) + time.Sleep(2 * time.Minute) // Create the container fmt.Println("Creating container ...") resp, err := client.ContainerCreate( ctx, &container.Config{ - Image: "ghcr.io/decentrio/dymint:srene-hardfork-fix-arm", // Image to run - Tty: true, // Attach to a TTY + Image: "ghcr.io/decentrio/dymint:srene-hardfork-fix", // Image to run + Tty: true, // Attach to a TTY }, hostConfig, networkConfig, nil, "grpc-da-container", ) diff --git a/tests/genesis_bridge_test.go b/tests/genesis_bridge_test.go index 3a03a4ab..2dee3415 100644 --- a/tests/genesis_bridge_test.go +++ b/tests/genesis_bridge_test.go @@ -5,6 +5,7 @@ import ( "fmt" "strconv" "testing" + "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" @@ -116,6 +117,16 @@ func TestGenesisTransferBridgeBlocking_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -269,6 +280,16 @@ func TestGenesisTransferBridgeBlocking_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -422,6 +443,16 @@ func TestGenesisTransferConnectionBlock_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -606,6 +637,16 @@ func TestGenesisTransferConnectionBlock_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1007,6 +1048,16 @@ func TestGenesisBridgeNoRelayAck_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1150,6 +1201,16 @@ func TestGenesisBridgeNoRelayAck_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1321,6 +1382,16 @@ func TestGenesisBridgeBeforeChannelSet_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, "", rollappUserAddr, transferData, ibc.TransferOptions{}) require.Error(t, err, "IBC transfer should fail because the channel is not created yet") + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) @@ -1510,6 +1581,16 @@ func TestGenesisBridgeWithoutGenesisAcc_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, false) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1659,6 +1740,16 @@ func TestGenesisTransferBridgeUnBond_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1826,6 +1917,16 @@ func TestGenesisTransferBridgeUnBond_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -2031,6 +2132,19 @@ func TestGenTransferBridgeKickProposer_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2234,6 +2348,19 @@ func TestGenTransferBridgeKickProposer_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) diff --git a/tests/hardfork_test.go b/tests/hardfork_test.go index b90777f8..3cf9fb15 100644 --- a/tests/hardfork_test.go +++ b/tests/hardfork_test.go @@ -202,6 +202,16 @@ func TestHardForkDueToFraud_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -352,6 +362,16 @@ func TestHardForkDueToFraud_EVM(t *testing.T) { err = rollapp1.Validators[0].StartContainer(ctx) } + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + err = r.StopRelayer(ctx, eRep) require.NoError(t, err) @@ -578,6 +598,19 @@ func Test_HardFork_KickProposer_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1044,6 +1077,16 @@ func TestHardForkDueToDrs_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) diff --git a/tests/ibc_finalize_block_test.go b/tests/ibc_finalize_block_test.go index 9c1e331a..7179d994 100644 --- a/tests/ibc_finalize_block_test.go +++ b/tests/ibc_finalize_block_test.go @@ -118,6 +118,16 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -388,6 +398,16 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { require.NoError(t, err) require.Equal(t, walletAmount, rollappOrigBal) + wallet, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) @@ -564,6 +584,16 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -796,6 +826,16 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -1071,6 +1111,16 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, walletAmount, rollappOrigBal) + wallet, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) @@ -1248,6 +1298,16 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index ca448618..b00a17f4 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -168,6 +168,29 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -497,6 +520,29 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -829,6 +875,29 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1105,6 +1174,29 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1374,6 +1466,29 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1700,6 +1815,29 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index f343e8ed..d755d213 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -130,6 +130,16 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -253,6 +263,9 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 50, 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() @@ -446,6 +459,19 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index b5a39f46..25f972b9 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -198,6 +198,16 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -396,6 +406,16 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/rollapp_invariant_test.go b/tests/rollapp_invariant_test.go index add26cb4..cba8d36c 100644 --- a/tests/rollapp_invariant_test.go +++ b/tests/rollapp_invariant_test.go @@ -163,6 +163,29 @@ func TestRollappInvariant_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -415,6 +438,29 @@ func TestRollappInvariant_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) diff --git a/tests/rollapp_state_update_test.go b/tests/rollapp_state_update_test.go index a0c1720b..94598764 100644 --- a/tests/rollapp_state_update_test.go +++ b/tests/rollapp_state_update_test.go @@ -184,6 +184,29 @@ func Test_RollAppStateUpdateSuccess_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -396,7 +419,7 @@ func Test_RollAppStateUpdateSuccess_Wasm(t *testing.T) { ChainID: "rollappwasm_1234-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", - Bech32Prefix: "ethm", + Bech32Prefix: "rol", Denom: "urax", CoinType: "118", GasPrices: "0.0urax", @@ -418,7 +441,7 @@ func Test_RollAppStateUpdateSuccess_Wasm(t *testing.T) { ChainID: "decentrio_12345-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", - Bech32Prefix: "ethm", + Bech32Prefix: "rol", Denom: "urax", CoinType: "118", GasPrices: "0.0urax", @@ -503,6 +526,29 @@ func Test_RollAppStateUpdateSuccess_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -838,6 +884,29 @@ func Test_RollAppStateUpdateFail_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1080,7 +1149,7 @@ func Test_RollAppStateUpdateFail_Wasm(t *testing.T) { ChainID: "rollappwasm_1234-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", - Bech32Prefix: "ethm", + Bech32Prefix: "rol", Denom: "urax", CoinType: "118", GasPrices: "0.0urax", @@ -1102,7 +1171,7 @@ func Test_RollAppStateUpdateFail_Wasm(t *testing.T) { ChainID: "decentrio_12345-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", - Bech32Prefix: "ethm", + Bech32Prefix: "rol", Denom: "urax", CoinType: "118", GasPrices: "0.0urax", @@ -1187,6 +1256,29 @@ func Test_RollAppStateUpdateFail_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1509,6 +1601,16 @@ func Test_RollAppStateUpdateFail_Celes_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 8, celestia) require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -1696,6 +1798,29 @@ func Test_RollAppStateUpdateFail_Celes_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -1809,54 +1934,6 @@ func Test_RollAppStateUpdateFail_Celes_EVM(t *testing.T) { // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).MulRaw(2)) - oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) - require.NoError(t, err) - - // Access the index value - index := oldLatestIndex.StateIndex.Index - uintIndex, err := strconv.ParseUint(index, 10, 64) - require.NoError(t, err) - - targetIndex := uintIndex + 1 - - // Loop until the latest index updates - for { - oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) - require.NoError(t, err) - - index := oldLatestIndex.StateIndex.Index - uintIndex, err := strconv.ParseUint(index, 10, 64) - - require.NoError(t, err) - if uintIndex >= targetIndex { - break - } - } - - oldLatestHeight, err := dymension.GetNode().QueryLatestHeight(ctx, rollapp1.Config().ChainID) - require.NoError(t, err) - - // Access the height value - height := oldLatestHeight.Height - uintHeight, err := strconv.ParseUint(height, 10, 64) - require.NoError(t, err) - - targetHeight := uintHeight + 1 - - // Loop until the latest height updates - for { - oldLatestHeight, err := dymension.GetNode().QueryLatestHeight(ctx, rollapp1.Config().ChainID) - require.NoError(t, err) - - height := oldLatestHeight.Height - uintHeight, err := strconv.ParseUint(height, 10, 64) - - require.NoError(t, err) - if uintHeight >= targetHeight { - break - } - } - // Run invariant check CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } @@ -1975,7 +2052,7 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { // 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, false, 1179360, true) + }, nil, "", nil, true, 1179360, true) require.NoError(t, err) validator, err := celestia.GetNode().AccountKeyBech32(ctx, "validator") @@ -1986,6 +2063,36 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 8, celestia) require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -2055,9 +2162,6 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { fmt.Println("Err:", err) } - // _ = celestia.GetNode().StartCelestiaDaLightNode(ctx, nodeStore, coreIp, p2pNetwork, nil) - // require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, celestia) require.NoError(t, err) @@ -2085,10 +2189,10 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_1234-1", + ChainID: "rollappwasm_1234-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", - Bech32Prefix: "ethm", + Bech32Prefix: "rol", Denom: "urax", CoinType: "118", GasPrices: "0.0urax", @@ -2110,7 +2214,7 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { ChainID: "decentrio_12345-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", - Bech32Prefix: "ethm", + Bech32Prefix: "rol", Denom: "urax", CoinType: "118", GasPrices: "0.0urax", @@ -2119,7 +2223,7 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { EncodingConfig: encodingConfig(), NoHostMount: false, ModifyGenesis: modifyRollappWasmGenesis(modifyWasmGenesisKV), - ConfigFileOverrides: configFileOverrides2, + ConfigFileOverrides: configFileOverrides1, }, NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, @@ -2176,6 +2280,29 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet1, found := r1.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + wallet2, found := r2.GetWallet(rollapp2.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir() + require.NoError(t, err) + keyPath2 := keyDir2 + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) @@ -2195,10 +2322,10 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { dymensionUserAddr := dymensionUser.FormattedAddress() rollappUserAddr := rollappUser.FormattedAddress() - channel, err := ibc.GetTransferChannel(ctx, r1, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + channel, err := ibc.GetTransferChannel(ctx, r1, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) require.NoError(t, err) // Get ibc denom of rollapp on hub @@ -2211,78 +2338,63 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { Denom: rollapp1.Config().Denom, Amount: transferAmount, } - _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - rollappHeight, err := rollapp1.GetNode().Height(ctx) + // Stop DA + err = celestia.StopAllNodes(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)) + time.Sleep(60 * time.Second) - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) + // rollapp unhealty now so can not send ibc transfer + _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.Error(t, err) + fmt.Println(err) - res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) - fmt.Println(res) + // Restart DA + err = celestia.StartAllNodes(ctx) require.NoError(t, err) - for _, packet := range res.RollappPackets { + execIDResp, err = client.ContainerExecCreate(ctx, containerID, execConfig) + if err != nil { + fmt.Println("Err:", err) + } - proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) - require.NoError(t, err) + execID = execIDResp.ID - fmt.Println(txhash) + // Start the exec instance + execStartCheck = types.ExecStartCheck{ + Tty: false, } - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - // Minus 0.1% of transfer amount for bridge fee - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + if err := client.ContainerExecStart(ctx, execID, execStartCheck); err != nil { + fmt.Println("Err:", err) + } - err = dymension.StopAllNodes(ctx) + err = testutil.WaitForBlocks(ctx, 10, celestia) require.NoError(t, err) - time.Sleep(51 * time.Second) - - // rollapp unhealty now so can not send ibc transfer - _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - err = dymension.StartAllNodes(ctx) + // Rollapp resume produce blocks + err = testutil.WaitForBlocks(ctx, 2, rollapp1) require.NoError(t, err) - testutil.WaitForBlocks(ctx, 15, dymension, rollapp1) - - // send from rollapp to hub again and make sure new bridge fee is applied _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) + 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).Sub(transferData.Amount).Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferData.Amount)) // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) fmt.Println(res) require.NoError(t, err) @@ -2301,7 +2413,8 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Sub(bridgingFee).Sub(bridgingFee).Add(transferAmount).Add(transferAmount)) + // Minus 0.1% of transfer amount for bridge fee + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).MulRaw(2)) oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -2327,30 +2440,6 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { } } - oldLatestHeight, err := dymension.GetNode().QueryLatestHeight(ctx, rollapp1.Config().ChainID) - require.NoError(t, err) - - // Access the height value - height := oldLatestHeight.Height - uintHeight, err := strconv.ParseUint(height, 10, 64) - require.NoError(t, err) - - targetHeight := uintHeight + 1 - - // Loop until the latest height updates - for { - oldLatestHeight, err := dymension.GetNode().QueryLatestHeight(ctx, rollapp1.Config().ChainID) - require.NoError(t, err) - - height := oldLatestHeight.Height - uintHeight, err := strconv.ParseUint(height, 10, 64) - - require.NoError(t, err) - if uintHeight >= targetHeight { - break - } - } - // Run invariant check CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/rollapp_upgrade_test.go b/tests/rollapp_upgrade_test.go index a5dc52b9..a71d2ed4 100644 --- a/tests/rollapp_upgrade_test.go +++ b/tests/rollapp_upgrade_test.go @@ -20,511 +20,6 @@ import ( "go.uber.org/zap/zaptest" ) -// TestRollappUpgradeNonStateBreaking_EVM ensure that the non state breaking upgrade works properly. -func TestRollappUpgradeNonStateBreaking_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{preUpgradeRollappEVMImage}, - 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, false, 1179360, true) - 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() - - // Get original account balances - dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - require.NoError(t, err) - require.Equal(t, walletAmount, dymensionOrigBal) - - rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) - require.NoError(t, err) - require.Equal(t, walletAmount, rollappOrigBal) - - 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) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - 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) - - res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) - fmt.Println(res) - require.NoError(t, err) - - for _, packet := range res.RollappPackets { - - proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) - require.NoError(t, err) - - fmt.Println(txhash) - } - - // Switch to a new binary - err = rollapp1.StopAllNodes(ctx) - require.NoError(t, err, "error stopping node(s)") - - rollapp1.UpgradeVersion(ctx, client, RollappEVMMainRepo, rollappEVMVersion) - - err = rollapp1.StartAllNodes(ctx) - require.NoError(t, err, "error starting node(s)") - - // 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.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 - dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) - erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - require.NoError(t, err) - erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address - testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) - - transferData = ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - - // Compose an IBC transfer and send from rollapp -> Hub - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - 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).Sub(transferAmount)) - - // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) - fmt.Println(res) - require.NoError(t, err) - - for _, packet := range res.RollappPackets { - - proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) - require.NoError(t, err) - - fmt.Println(txhash) - } - - 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() - - // Assert funds were returned to the sender after the timeout has occured - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferAmount)) - // minus 0.1% of transfer amount for bridge fee - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) - // Run invariant check - CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) -} - -func TestRollappUpgradeNonStateBreaking_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{preUpgradeRollappWasmImage}, - 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, false, 1179360, true) - 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() - - // Get original account balances - dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - require.NoError(t, err) - require.Equal(t, walletAmount, dymensionOrigBal) - - rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) - require.NoError(t, err) - require.Equal(t, walletAmount, rollappOrigBal) - - 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) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - 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) - - res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) - fmt.Println(res) - require.NoError(t, err) - - for _, packet := range res.RollappPackets { - - proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) - require.NoError(t, err) - - fmt.Println(txhash) - } - - // Switch to a new binary - err = rollapp1.StopAllNodes(ctx) - require.NoError(t, err, "error stopping node(s)") - - err = r.StopRelayer(ctx, eRep) - require.NoError(t, err) - - rollapp1.UpgradeVersion(ctx, client, RollappWasmMainRepo, rollappWasmVersion) - - err = rollapp1.StartAllNodes(ctx) - require.NoError(t, err, "error starting node(s)") - - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - - transferData = ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - - // Compose an IBC transfer and send from rollapp -> Hub - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - 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).Sub(transferAmount)) - - // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - - res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) - fmt.Println(res) - require.NoError(t, err) - - for _, packet := range res.RollappPackets { - - proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) - require.NoError(t, err) - - fmt.Println(txhash) - } - - 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() - - // Assert funds were returned to the sender after the timeout has occured - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferAmount)) - // minus 0.1% of transfer amount for bridge fee - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) - - // 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.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 - dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) - - // Run invariant check - CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) -} - func TestRollapp_EVM_Upgrade(t *testing.T) { if testing.Short() { t.Skip() @@ -625,6 +120,16 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -902,6 +407,16 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index 6c623c51..7df0c5ad 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -223,6 +223,16 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -632,6 +642,16 @@ func Test_SeqRewardsAddress_Update_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -790,7 +810,7 @@ func Test_SeqRewardsAddress_Update_EVM(t *testing.T) { // err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) // require.NoError(t, err) - + lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) @@ -867,6 +887,16 @@ func Test_SeqRewardsAddress_Update_EVM(t *testing.T) { time.Sleep(120 * time.Second) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) diff --git a/tests/sequencer_rotation_test.go b/tests/sequencer_rotation_test.go index f28d3335..d94db30e 100644 --- a/tests/sequencer_rotation_test.go +++ b/tests/sequencer_rotation_test.go @@ -140,6 +140,19 @@ func Test_SeqRotation_OneSeq_DA_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -317,6 +330,16 @@ func Test_SeqRotation_OneSeq_DA_EVM(t *testing.T) { time.Sleep(100 * time.Second) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) @@ -366,37 +389,6 @@ func Test_SeqRotation_OneSeq_DA_EVM(t *testing.T) { rollappIBCDenom = transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) - - // Get original account balances - dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - require.NoError(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.NoError(t, err) - - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - - 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() - - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - require.NoError(t, err) - erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) } func Test_SeqRotation_OneSeq_DA_Wasm(t *testing.T) { @@ -512,94 +504,117 @@ func Test_SeqRotation_OneSeq_DA_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil, true, 1179360, true) + }, nil, "", nil, false, 1179360, true) + require.NoError(t, err) + + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) // Check IBC Transfer before switch - // CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + 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) + // 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] + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] - // dymensionUserAddr := dymensionUser.FormattedAddress() - // rollappUserAddr := rollappUser.FormattedAddress() + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() - // channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - // require.NoError(t, err) + 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 = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // 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, - // } + // Send a normal ibc tx from RA -> Hub + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // rollappHeight, err := rollapp1.GetNode().Height(ctx) - // 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)) + // 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) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) - // _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) - // require.NoError(t, err) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + 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() + for _, packet := range res.RollappPackets { - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) - // // Get original account balances - // dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // require.NoError(t, err) + fmt.Println(txhash) + } + + // 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() - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + // Compose an IBC transfer and send from dymension -> rollapp + transferData = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + 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() + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) @@ -619,6 +634,10 @@ func Test_SeqRotation_OneSeq_DA_Wasm(t *testing.T) { err = dymension.SendFunds(ctx, "faucet", fund) require.NoError(t, err) + resp0, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(resp0.Sequencers), 1, "should have 1 sequences") + // Wait a few blocks for relayer to start and for user accounts to be created err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) @@ -633,6 +652,14 @@ func Test_SeqRotation_OneSeq_DA_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, len(resp.Sequencers), 2, "should have 2 sequences") + nextProposer, err := dymension.GetNode().GetNextProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + require.NoError(t, err) + require.Equal(t, "sentinel", nextProposer.NextProposerAddr) + + currentProposer, err := dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + require.NoError(t, err) + require.Equal(t, resp0.Sequencers[0].Address, currentProposer.ProposerAddr) + // Unbond sequencer1 err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) require.NoError(t, err) @@ -644,97 +671,88 @@ func Test_SeqRotation_OneSeq_DA_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, "OPERATING_STATUS_BONDED", queryGetSequencerResponse.Sequencer.Status) - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) require.NoError(t, err) lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(180 * time.Second) + time.Sleep(200 * time.Second) - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + currentProposer, err = dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) - - // Chain halted - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.Error(t, err) - - time.Sleep(300 * time.Second) + require.NotEqual(t, resp0.Sequencers[0].Address, currentProposer.ProposerAddr) - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) + // currentProposer, err = dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + // require.NoError(t, err) + // println("checking new proposer: ", currentProposer.ProposerAddr) err = rollapp1.StopAllNodes(ctx) require.NoError(t, err) _ = rollapp1.StartAllNodes(ctx) - time.Sleep(30 * time.Second) + time.Sleep(100 * time.Second) - afterBlock, err := rollapp1.Height(ctx) - require.NoError(t, err) - require.True(t, afterBlock > lastBlock) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) - // // Check IBC after switch - // rollappHeight, err = rollapp1.GetNode().Height(ctx) - // require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Compose an IBC transfer and send from rollapp -> Hub + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } - // // wait until the packet is finalized - // isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - // require.NoError(t, err) - // require.True(t, isFinalized) + _, err = rollapp1.SendIBCTransferAfterHardFork(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) - // require.NoError(t, err) + 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() + // Check IBC after switch + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferData.Amount)) - // // Get original account balances - // dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // 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) - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + for _, packet := range res.RollappPackets { - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + fmt.Println(txhash) + } - // // 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() - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) } func Test_SeqRotation_NoSeq_DA_EVM(t *testing.T) { @@ -853,6 +871,19 @@ func Test_SeqRotation_NoSeq_DA_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1039,6 +1070,16 @@ func Test_SeqRotation_NoSeq_DA_EVM(t *testing.T) { time.Sleep(100 * time.Second) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) @@ -1082,45 +1123,14 @@ func Test_SeqRotation_NoSeq_DA_EVM(t *testing.T) { rollappIBCDenom = transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) +} - // Get original account balances - dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - require.NoError(t, err) - - // Compose an IBC transfer and send from dymension -> rollapp - transferData = ibc.WalletData{ - Address: rollappUserAddr, - Denom: dymension.Config().Denom, - Amount: transferAmount, +func Test_SeqRotation_NoSeq_DA_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() } - // 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, dymensionOrigBal.Sub(transferData.Amount)) - - 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() - - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - require.NoError(t, err) - erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) -} - -func Test_SeqRotation_NoSeq_DA_Wasm(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() + ctx := context.Background() // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" @@ -1228,94 +1238,117 @@ func Test_SeqRotation_NoSeq_DA_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil, true, 1179360, true) + }, nil, "", nil, false, 1179360, true) + require.NoError(t, err) + + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) // Check IBC Transfer before switch - // CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + 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) + // 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] + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] - // dymensionUserAddr := dymensionUser.FormattedAddress() - // rollappUserAddr := rollappUser.FormattedAddress() + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() - // channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - // require.NoError(t, err) + 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 = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // 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, - // } + // Send a normal ibc tx from RA -> Hub + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // rollappHeight, err := rollapp1.GetNode().Height(ctx) - // 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)) + // 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) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) - // _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) - // require.NoError(t, err) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) + + for _, packet := range res.RollappPackets { + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 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) - // rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + fmt.Println(txhash) + } - // // Get original account balances - // dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // 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() - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + // Compose an IBC transfer and send from dymension -> rollapp + transferData = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + // 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, dymensionOrigBal.Sub(transferData.Amount)) - // // Get the IBC denom - // dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - // dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) // Unbond sequencer1 err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) @@ -1334,22 +1367,8 @@ func Test_SeqRotation_NoSeq_DA_Wasm(t *testing.T) { lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(180 * time.Second) - - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) - - // Chain halted - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.Error(t, err) - time.Sleep(300 * time.Second) - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) - cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) require.NoError(t, err) @@ -1382,75 +1401,95 @@ func Test_SeqRotation_NoSeq_DA_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, len(resp.Sequencers), 2, "should have 2 sequences") - err = rollapp1.StopAllNodes(ctx) + rollapp1HomeDir := strings.Split(rollapp1.FullNodes[0].HomeDir(), "/") + rollapp1FolderName := rollapp1HomeDir[len(rollapp1HomeDir)-1] + + rollapp1ValHomeDir := strings.Split(rollapp1.Validators[0].HomeDir(), "/") + rollapp1ValFolderName := rollapp1ValHomeDir[len(rollapp1ValHomeDir)-1] + + err = os.RemoveAll(fmt.Sprintf("/tmp/%s/data", rollapp1FolderName)) require.NoError(t, err) - _ = rollapp1.StartAllNodes(ctx) + err = os.RemoveAll(fmt.Sprintf("/tmp/%s/data", rollapp1ValFolderName)) + require.NoError(t, err) - time.Sleep(30 * time.Second) + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) - afterBlock, err := rollapp1.Height(ctx) + err = rollapp1.Validators[0].StopContainer(ctx) require.NoError(t, err) - require.True(t, afterBlock > lastBlock) - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + err = rollapp1.FullNodes[0].StartContainer(ctx) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + if err != nil { + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) + err = rollapp1.FullNodes[0].StartContainer(ctx) + } - // // Check IBC after switch - // rollappHeight, err = rollapp1.GetNode().Height(ctx) - // require.NoError(t, err) + err = rollapp1.Validators[0].StartContainer(ctx) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + if err != nil { + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) + err = rollapp1.Validators[0].StartContainer(ctx) + } - // // wait until the packet is finalized - // isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - // require.NoError(t, err) - // require.True(t, isFinalized) + time.Sleep(100 * time.Second) - // _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) - // require.NoError(t, err) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) - // // 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() + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) - // // Get original account balances - // dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransferAfterHardFork(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Check IBC after switch + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // 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) + + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + 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() + for _, packet := range res.RollappPackets { - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) + + fmt.Println(txhash) + } + + // 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) } func Test_SeqRotation_NoSeq_P2P_EVM(t *testing.T) { @@ -1643,6 +1682,19 @@ func Test_SeqRotation_NoSeq_P2P_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1765,6 +1817,10 @@ func Test_SeqRotation_NoSeq_P2P_EVM(t *testing.T) { lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), lastBlock, 300) + require.NoError(t, err) + require.True(t, isFinalized) + time.Sleep(200 * time.Second) err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) @@ -1908,6 +1964,16 @@ func Test_SeqRotation_NoSeq_P2P_EVM(t *testing.T) { time.Sleep(100 * time.Second) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) @@ -2183,6 +2249,19 @@ func Test_SeqRotation_NoSeq_P2P_Wasm(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2275,16 +2354,6 @@ func Test_SeqRotation_NoSeq_P2P_Wasm(t *testing.T) { 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() - - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) - // Get the IBC denom for the token on RollApp var dymensionTokenDenom, dymensionIBCDenom string dymensionTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) @@ -2313,22 +2382,21 @@ func Test_SeqRotation_NoSeq_P2P_Wasm(t *testing.T) { lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(180 * time.Second) - - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), lastBlock, 300) require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) - - // Chain halted - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.Error(t, err) + require.True(t, isFinalized) time.Sleep(300 * time.Second) + err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) + require.NoError(t, err) + queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) require.NoError(t, err) require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) + time.Sleep(100 * time.Second) + cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) require.NoError(t, err) @@ -2361,30 +2429,138 @@ func Test_SeqRotation_NoSeq_P2P_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, len(resp.Sequencers), 2, "should have 2 sequences") - err = rollapp1.StopAllNodes(ctx) + err = testutil.WaitForBlocks(ctx, 20, dymension) require.NoError(t, err) - _ = rollapp1.StartAllNodes(ctx) + // Start full node + rollapp1ValHomeDir := strings.Split(rollapp1.Validators[0].HomeDir(), "/") + rollapp1ValFolderName := rollapp1ValHomeDir[len(rollapp1ValHomeDir)-1] - time.Sleep(30 * time.Second) + err = os.RemoveAll(fmt.Sprintf("/tmp/%s/data", rollapp1FolderName)) + require.NoError(t, err) - afterBlock, err := rollapp1.Height(ctx) + err = os.RemoveAll(fmt.Sprintf("/tmp/%s/data", rollapp1ValFolderName)) require.NoError(t, err) - require.True(t, afterBlock > lastBlock) - // Compose an IBC transfer and send from rollapp -> Hub - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + err = rollapp1.FullNodes[0].StopContainer(ctx) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + err = rollapp1.Validators[0].StopContainer(ctx) require.NoError(t, err) - // Check IBC after switch - rollappHeight, err = rollapp1.GetNode().Height(ctx) + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + err = rollapp1.Validators[0].StartContainer(ctx) + + if err != nil { + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) + err = rollapp1.Validators[0].StartContainer(ctx) + require.NoError(t, err) + } + + containerID = fmt.Sprintf("ra-rollappevm_1234-1-fn-0-%s", t.Name()) + + // Get the container details + containerJSON, err = client.ContainerInspect(context.Background(), containerID) + require.NoError(t, err) + + for _, network := range containerJSON.NetworkSettings.Networks { + ipAddress = network.IPAddress + break // Assuming we only need the IP from the first network + } + + nodeId, err = rollapp1.FullNodes[0].GetNodeId(ctx) + require.NoError(t, err) + nodeId = strings.TrimRight(nodeId, "\n") + p2p_bootstrap_node = fmt.Sprintf("/ip4/%s/tcp/26656/p2p/%s", ipAddress, nodeId) + + rollapp1HomeDir = strings.Split(rollapp1.Validators[0].HomeDir(), "/") + rollapp1FolderName = rollapp1HomeDir[len(rollapp1HomeDir)-1] + + file, err = os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + lines = []string{} + scanner = bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + + for i, line := range lines { + if strings.HasPrefix(line, "p2p_bootstrap_nodes =") { + lines[i] = fmt.Sprintf("p2p_bootstrap_nodes = \"%s\"", p2p_bootstrap_node) + } + } + + output = strings.Join(lines, "\n") + file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + _, err = file.Write([]byte(output)) + require.NoError(t, err) + + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) + + err = rollapp1.Validators[0].StartContainer(ctx) + require.NoError(t, err) + + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) + + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) + + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + err = rollapp1.Validators[0].StartContainer(ctx) + require.NoError(t, err) + + err = r.StopRelayer(ctx, eRep) + require.NoError(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + time.Sleep(100 * time.Second) + + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) + + // Compose an IBC transfer and send from rollapp -> Hub + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Check IBC after switch + 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)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferData.Amount)) // wait until the packet is finalized isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) @@ -2414,7 +2590,7 @@ func Test_SeqRotation_NoSeq_P2P_Wasm(t *testing.T) { rollappTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom = transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) // Get original account balances dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) @@ -2438,25 +2614,11 @@ func Test_SeqRotation_NoSeq_P2P_Wasm(t *testing.T) { 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() - - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) - - // Get the IBC denom for the token on RollApp dymensionTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom = transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - // Assert the balance on Dymension after sending the tokens testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - - // Query the balance of rollappUserAddr on RollApp - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) - + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount.MulRaw(2)) } func Test_SqcRotation_OneSqc_P2P_EVM(t *testing.T) { @@ -2476,7 +2638,6 @@ func Test_SqcRotation_OneSqc_P2P_EVM(t *testing.T) { dymintTomlOverrides["max_proof_time"] = "500ms" dymintTomlOverrides["batch_submit_time"] = "50s" dymintTomlOverrides["p2p_blocksync_enabled"] = "true" - dymintTomlOverrides["da_config"] = "{\"host\":\"grpc-da-container\",\"port\": 7980}" configFileOverrides := make(map[string]any) @@ -2649,6 +2810,19 @@ func Test_SqcRotation_OneSqc_P2P_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2795,7 +2969,7 @@ func Test_SqcRotation_OneSqc_P2P_EVM(t *testing.T) { erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) - err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) // Unbond sequencer1 @@ -2875,6 +3049,16 @@ func Test_SqcRotation_OneSqc_P2P_EVM(t *testing.T) { time.Sleep(120 * time.Second) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) @@ -2919,7 +3103,7 @@ func Test_SqcRotation_OneSqc_P2P_EVM(t *testing.T) { fmt.Println(txhash) } - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp1) require.NoError(t, err) // Get the IBC denom for urax on Hub @@ -3149,11 +3333,30 @@ func Test_SqcRotation_OneSqc_P2P_Wasm(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch 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) + 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() cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) @@ -3173,6 +3376,10 @@ func Test_SqcRotation_OneSqc_P2P_Wasm(t *testing.T) { err = dymension.SendFunds(ctx, "faucet", fund) require.NoError(t, err) + resp0, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(resp0.Sequencers), 1, "should have 1 sequences") + // Wait a few blocks for relayer to start and for user accounts to be created err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) @@ -3187,14 +3394,16 @@ func Test_SqcRotation_OneSqc_P2P_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, len(resp.Sequencers), 2, "should have 2 sequences") - // Get our Bech32 encoded user addresses - // dymensionUser, rollappUser := users[0], users[1] + nextProposer, err := dymension.GetNode().GetNextProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + require.NoError(t, err) + require.Equal(t, "sentinel", nextProposer.NextProposerAddr) - // dymensionUserAddr := dymensionUser.FormattedAddress() - // rollappUserAddr := rollappUser.FormattedAddress() + currentProposer, err := dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + require.NoError(t, err) + require.Equal(t, resp0.Sequencers[0].Address, currentProposer.ProposerAddr) - // channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - // require.NoError(t, err) + 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) @@ -3202,64 +3411,86 @@ func Test_SqcRotation_OneSqc_P2P_Wasm(t *testing.T) { 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, - // } + // Send a normal ibc tx from RA -> Hub + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // rollappHeight, err := rollapp1.GetNode().Height(ctx) - // 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)) + // 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) + // 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) - // rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + for _, packet := range res.RollappPackets { - // // Get original account balances - // dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // require.NoError(t, err) + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + fmt.Println(txhash) + } - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + 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() - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(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.NoError(t, err) - // // Get the IBC denom - // dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - // dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) // Unbond sequencer1 err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) @@ -3272,91 +3503,160 @@ func Test_SqcRotation_OneSqc_P2P_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, "OPERATING_STATUS_BONDED", queryGetSequencerResponse.Sequencer.Status) - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(180 * time.Second) - - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) - - // Chain halted - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.Error(t, err) - - time.Sleep(300 * time.Second) + time.Sleep(200 * time.Second) - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + currentProposer, err = dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) + require.NotEqual(t, resp0.Sequencers[0].Address, currentProposer.ProposerAddr) err = rollapp1.StopAllNodes(ctx) require.NoError(t, err) _ = rollapp1.StartAllNodes(ctx) - time.Sleep(30 * time.Second) + containerID = fmt.Sprintf("ra-rollappwasm_1234-1-fn-0-%s", t.Name()) - afterBlock, err := rollapp1.Height(ctx) + // Get the container details + containerJSON, err = client.ContainerInspect(context.Background(), containerID) require.NoError(t, err) - require.True(t, afterBlock > lastBlock) - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + for _, network := range containerJSON.NetworkSettings.Networks { + ipAddress = network.IPAddress + break // Assuming we only need the IP from the first network + } - // // Check IBC after switch - // rollappHeight, err = rollapp1.GetNode().Height(ctx) - // require.NoError(t, err) + nodeId, err = rollapp1.FullNodes[0].GetNodeId(ctx) + require.NoError(t, err) + nodeId = strings.TrimRight(nodeId, "\n") + p2p_bootstrap_node = fmt.Sprintf("/ip4/%s/tcp/26656/p2p/%s", ipAddress, nodeId) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + rollapp1HomeDir = strings.Split(rollapp1.Validators[0].HomeDir(), "/") + rollapp1FolderName = rollapp1HomeDir[len(rollapp1HomeDir)-1] - // // wait until the packet is finalized - // isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - // require.NoError(t, err) - // require.True(t, isFinalized) + file, err = os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() - // // 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() + lines = []string{} + scanner = bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + + for i, line := range lines { + if strings.HasPrefix(line, "p2p_bootstrap_nodes =") { + lines[i] = fmt.Sprintf("p2p_bootstrap_nodes = \"%s\"", p2p_bootstrap_node) + } + } - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + output = strings.Join(lines, "\n") + file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() - // // Get original account balances - // dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // require.NoError(t, err) + _, err = file.Write([]byte(output)) + require.NoError(t, err) - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + // Start full node + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + err = rollapp1.Validators[0].StartContainer(ctx) + require.NoError(t, err) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + time.Sleep(120 * time.Second) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + 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() + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) + + // Compose an IBC transfer and send from rollapp -> 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) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Check IBC after switch + 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).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) + + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) + + for _, packet := range res.RollappPackets { + + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) + + fmt.Println(txhash) + } + + 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) + + // Get original account balances + dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(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.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + 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() + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount.MulRaw(2)) } func Test_SqcRotation_MulSqc_P2P_EVM(t *testing.T) { @@ -3582,6 +3882,19 @@ func Test_SqcRotation_MulSqc_P2P_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -3827,6 +4140,16 @@ func Test_SqcRotation_MulSqc_P2P_EVM(t *testing.T) { require.NoError(t, err) require.Equal(t, sequencer, currentProposer.ProposerAddr) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) @@ -4135,11 +4458,24 @@ func Test_SqcRotation_MulSqc_P2P_Wasm(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch 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) + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) @@ -4154,7 +4490,7 @@ func Test_SqcRotation_MulSqc_P2P_Wasm(t *testing.T) { fund := ibc.WalletData{ Address: sequencer, Denom: dymension.Config().Denom, - Amount: math.NewInt(10_000_000_000_000).MulRaw(100_000_000), + Amount: math.NewInt(10_000_000_100_000).MulRaw(100_000_000), } err = dymension.SendFunds(ctx, "faucet", fund) require.NoError(t, err) @@ -4163,7 +4499,7 @@ func Test_SqcRotation_MulSqc_P2P_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) - command := []string{"sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "100000000000000000000adym", rollapp1.GetSequencerKeyDir() + "/metadata_sequencer1.json", + command := []string{"sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "100000000000000100000adym", rollapp1.GetSequencerKeyDir() + "/metadata_sequencer1.json", "--broadcast-mode", "async", "--keyring-dir", rollapp1.FullNodes[0].HomeDir() + "/sequencer_keys"} _, err = dymension.FullNodes[0].ExecTx(ctx, "sequencer", command...) @@ -4176,11 +4512,11 @@ func Test_SqcRotation_MulSqc_P2P_Wasm(t *testing.T) { err = dymension.FullNodes[0].CreateKeyWithKeyDir(ctx, "sequencer", rollapp1.FullNodes[1].HomeDir()) require.NoError(t, err) - sequencer, err = dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.FullNodes[1].HomeDir()) + sequencer2, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.FullNodes[1].HomeDir()) require.NoError(t, err) fund = ibc.WalletData{ - Address: sequencer, + Address: sequencer2, Denom: dymension.Config().Denom, Amount: math.NewInt(10_000_000_000_000).MulRaw(100_000_000), } @@ -4202,78 +4538,97 @@ func Test_SqcRotation_MulSqc_P2P_Wasm(t *testing.T) { require.Equal(t, len(res.Sequencers), 3, "should have 3 sequences") // Get our Bech32 encoded user addresses - // dymensionUser, rollappUser := users[0], users[1] + dymensionUser, rollappUser := users[0], users[1] - // dymensionUserAddr := dymensionUser.FormattedAddress() - // rollappUserAddr := rollappUser.FormattedAddress() + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() - // channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - // require.NoError(t, err) + 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 = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // 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, - // } + // Send a normal ibc tx from RA -> Hub + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) - // rollappHeight, err := rollapp1.GetNode().Height(ctx) - // require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + 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)) - // // 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() + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + resp, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) - // // Get original account balances - // dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // require.NoError(t, err) + for _, packet := range resp.RollappPackets { - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + fmt.Println(txhash) + } - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - // // Get the IBC denom - // dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - // dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + // 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.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) // Unbond sequencer1 err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) @@ -4292,85 +4647,162 @@ func Test_SqcRotation_MulSqc_P2P_Wasm(t *testing.T) { lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(180 * time.Second) - - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) - - // Chain halted - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.Error(t, err) - - time.Sleep(300 * time.Second) - - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) + time.Sleep(200 * time.Second) err = rollapp1.StopAllNodes(ctx) require.NoError(t, err) _ = rollapp1.StartAllNodes(ctx) - time.Sleep(30 * time.Second) + containerID = fmt.Sprintf("ra-rollappwasm_1234-1-fn-0-%s", t.Name()) - afterBlock, err := rollapp1.Height(ctx) + // Get the container details + containerJSON, err = client.ContainerInspect(context.Background(), containerID) require.NoError(t, err) - require.True(t, afterBlock > lastBlock) - - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) - // // Check IBC after switch - // rollappHeight, err = rollapp1.GetNode().Height(ctx) - // require.NoError(t, err) + for _, network := range containerJSON.NetworkSettings.Networks { + ipAddress = network.IPAddress + break // Assuming we only need the IP from the first network + } - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + nodeId, err = rollapp1.FullNodes[0].GetNodeId(ctx) + require.NoError(t, err) + nodeId = strings.TrimRight(nodeId, "\n") + p2p_bootstrap_node = fmt.Sprintf("/ip4/%s/tcp/26656/p2p/%s", ipAddress, nodeId) - // // wait until the packet is finalized - // isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - // require.NoError(t, err) - // require.True(t, isFinalized) + rollapp1HomeDir = strings.Split(rollapp1.Validators[0].HomeDir(), "/") + rollapp1FolderName = rollapp1HomeDir[len(rollapp1HomeDir)-1] - // // 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() + file, err = os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + lines = []string{} + scanner = bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } - // // Get original account balances - // dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // require.NoError(t, err) + for i, line := range lines { + if strings.HasPrefix(line, "p2p_bootstrap_nodes =") { + lines[i] = fmt.Sprintf("p2p_bootstrap_nodes = \"%s\"", p2p_bootstrap_node) + } + } - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + output = strings.Join(lines, "\n") + file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + _, err = file.Write([]byte(output)) + require.NoError(t, err) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + // Start full node + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + err = rollapp1.Validators[0].StartContainer(ctx) + 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() + time.Sleep(100 * time.Second) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + currentProposer, err := dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + require.NoError(t, err) + require.Equal(t, sequencer, currentProposer.ProposerAddr) + + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransferAfterHardFork(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + + // Check IBC after switch + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).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) + + resp, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) + + for _, packet := range resp.RollappPackets { + + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) + + fmt.Println(txhash) + } + + 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) + + // Get original account balances + dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(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.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount.MulRaw(2)) } func Test_SeqRotation_MulSeq_DA_EVM(t *testing.T) { @@ -4489,6 +4921,19 @@ func Test_SeqRotation_MulSeq_DA_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -4682,6 +5127,16 @@ func Test_SeqRotation_MulSeq_DA_EVM(t *testing.T) { time.Sleep(100 * time.Second) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) @@ -4845,94 +5300,117 @@ func Test_SeqRotation_MulSeq_DA_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil, true, 1179360, true) + }, nil, "", nil, false, 1179360, true) + require.NoError(t, err) + + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) // Check IBC Transfer before switch - // CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + 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) + // 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] + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] - // dymensionUserAddr := dymensionUser.FormattedAddress() - // rollappUserAddr := rollappUser.FormattedAddress() + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() - // channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - // require.NoError(t, err) + 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 = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // 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, - // } + // Send a normal ibc tx from RA -> Hub + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // rollappHeight, err := rollapp1.FullNodes[0].Height(ctx) - // 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)) + // 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) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) - // _, err = dymension.FullNodes[0].FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) - // require.NoError(t, err) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + 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() + for _, packet := range res.RollappPackets { - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) - // // Get original account balances - // dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // require.NoError(t, err) + fmt.Println(txhash) + } - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + // 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() - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(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.NoError(t, err) - // // Get the IBC denom - // dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - // dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) @@ -4947,7 +5425,7 @@ func Test_SeqRotation_MulSeq_DA_Wasm(t *testing.T) { fund := ibc.WalletData{ Address: sequencer, Denom: dymension.Config().Denom, - Amount: math.NewInt(10_000_000_000_000).MulRaw(100_000_000), + Amount: math.NewInt(10_000_000_100_000).MulRaw(100_000_000), } err = dymension.SendFunds(ctx, "faucet", fund) require.NoError(t, err) @@ -4956,7 +5434,7 @@ func Test_SeqRotation_MulSeq_DA_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) - command := []string{"sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "100000000000000000000adym", rollapp1.GetSequencerKeyDir() + "/metadata_sequencer1.json", + command := []string{"sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "100000000000000100000adym", rollapp1.GetSequencerKeyDir() + "/metadata_sequencer1.json", "--broadcast-mode", "async", "--keyring-dir", rollapp1.FullNodes[0].HomeDir() + "/sequencer_keys"} _, err = dymension.FullNodes[0].ExecTx(ctx, "sequencer", command...) @@ -4990,9 +5468,15 @@ func Test_SeqRotation_MulSeq_DA_Wasm(t *testing.T) { _, err = dymension.FullNodes[0].ExecTx(ctx, "sequencer", command...) require.NoError(t, err) - res, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + err = testutil.WaitForBlocks(ctx, 2, dymension) + require.NoError(t, err) + + resp, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(resp.Sequencers), 3, "should have 3 sequences") + + err = testutil.WaitForBlocks(ctx, 2, dymension) require.NoError(t, err) - require.Equal(t, len(res.Sequencers), 3, "should have 3 sequences") // Unbond sequencer1 err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) @@ -5011,91 +5495,76 @@ func Test_SeqRotation_MulSeq_DA_Wasm(t *testing.T) { lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(180 * time.Second) - - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) + time.Sleep(200 * time.Second) // Chain halted - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.Error(t, err) - - time.Sleep(300 * time.Second) - - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) err = rollapp1.StopAllNodes(ctx) require.NoError(t, err) _ = rollapp1.StartAllNodes(ctx) - time.Sleep(30 * time.Second) + time.Sleep(100 * time.Second) - afterBlock, err := rollapp1.Height(ctx) - require.NoError(t, err) - require.True(t, afterBlock > lastBlock) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) - // // Check IBC after switch - // rollappHeight, err = rollapp1.GetNode().Height(ctx) - // require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Compose an IBC transfer and send from rollapp -> Hub + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } - // // wait until the packet is finalized - // isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - // require.NoError(t, err) - // require.True(t, isFinalized) + _, err = rollapp1.SendIBCTransferAfterHardFork(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // _, err = dymension.FullNodes[0].FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) - // require.NoError(t, err) + 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() + // Check IBC after switch + rollappHeight, err = rollapp1.FullNodes[0].Height(ctx) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferData.Amount)) - // // Get original account balances - // dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // 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) - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + res, err = dymension.FullNodes[0].QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + for _, packet := range res.RollappPackets { - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + fmt.Println(txhash) + } - // // 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() - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) } func Test_SeqRotation_HisSync_DA_EVM(t *testing.T) { @@ -5214,6 +5683,19 @@ func Test_SeqRotation_HisSync_DA_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -5375,6 +5857,16 @@ func Test_SeqRotation_HisSync_DA_EVM(t *testing.T) { time.Sleep(100 * time.Second) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) @@ -5425,37 +5917,6 @@ func Test_SeqRotation_HisSync_DA_EVM(t *testing.T) { rollappIBCDenom = transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - - // Get original account balances - dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - require.NoError(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.NoError(t, err) - - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - - 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() - - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - require.NoError(t, err) - erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) } func Test_SeqRotation_HisSync_DA_Wasm(t *testing.T) { @@ -5571,94 +6032,120 @@ func Test_SeqRotation_HisSync_DA_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil, true, 1179360, true) + }, nil, "", nil, false, 1179360, true) + require.NoError(t, err) + + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) // Check IBC Transfer before switch - // CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + 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) + // 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] + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] - // dymensionUserAddr := dymensionUser.FormattedAddress() - // rollappUserAddr := rollappUser.FormattedAddress() + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() - // channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - // require.NoError(t, err) + 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 = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // 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, - // } + // Send a normal ibc tx from RA -> Hub + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // rollappHeight, err := rollapp1.GetNode().Height(ctx) - // 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)) + // 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) + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) - // _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) - // require.NoError(t, err) + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) + + for _, packet := range res.RollappPackets { + + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + 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() + fmt.Println(txhash) + } - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) - // // Get original account balances - // dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // 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() - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + // Compose an IBC transfer and send from dymension -> rollapp + transferData = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + 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() + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferData.Amount) cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) @@ -5709,91 +6196,76 @@ func Test_SeqRotation_HisSync_DA_Wasm(t *testing.T) { lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(180 * time.Second) + time.Sleep(200 * time.Second) - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + // Chain halted + err = rollapp1.StopAllNodes(ctx) require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) - // Chain halted - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.Error(t, err) + _ = rollapp1.StartAllNodes(ctx) - time.Sleep(300 * time.Second) + time.Sleep(100 * time.Second) - queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) - require.NoError(t, err) - require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) - err = rollapp1.StopAllNodes(ctx) + err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) - _ = rollapp1.StartAllNodes(ctx) - - time.Sleep(30 * time.Second) + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) - // // Compose an IBC transfer and send from rollapp -> Hub - // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) - - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) - - // // Check IBC after switch - // rollappHeight, err = rollapp1.GetNode().Height(ctx) - // require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> Hub - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } - // // wait until the packet is finalized - // isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - // require.NoError(t, err) - // require.True(t, isFinalized) + _, err = rollapp1.GetNode().SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - // _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) - // require.NoError(t, err) + 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() + // Check IBC after switch + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - // // Get original account balances - // dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) - // 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) - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) - // // Compose an IBC transfer and send from Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + for _, packet := range res.RollappPackets { - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + fmt.Println(txhash) + } - // // 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() - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) - // erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") - // require.NoError(t, err) - // erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address - // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) } func Test_SqcRotation_HisSync_P2P_EVM(t *testing.T) { @@ -5986,6 +6458,19 @@ func Test_SqcRotation_HisSync_P2P_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -6193,6 +6678,16 @@ func Test_SqcRotation_HisSync_P2P_EVM(t *testing.T) { time.Sleep(100 * time.Second) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) @@ -6486,6 +6981,19 @@ func Test_SeqRotation_Forced_DA_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -6705,6 +7213,16 @@ func Test_SeqRotation_Forced_DA_EVM(t *testing.T) { require.NoError(t, err) require.Equal(t, "Active", clientStatus.Status) + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + err = r.StopRelayer(ctx, eRep) require.NoError(t, err) diff --git a/tests/sequencer_test.go b/tests/sequencer_test.go index 08292b95..59273507 100644 --- a/tests/sequencer_test.go +++ b/tests/sequencer_test.go @@ -426,6 +426,14 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 8, celestia) require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) + err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) diff --git a/tests/setup.go b/tests/setup.go index c39a2280..214aa505 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -280,6 +280,10 @@ var ( } rollappWasmGenesisKV = []cosmos.GenesisKV{ + { + Key: "app_state.rollappparams.params.drs_version", + Value: 2, + }, { Key: "app_state.gov.voting_params.voting_period", Value: "30s", diff --git a/tests/time_upgrade_test.go b/tests/time_upgrade_test.go index 3a3bf900..cb63afc7 100644 --- a/tests/time_upgrade_test.go +++ b/tests/time_upgrade_test.go @@ -198,6 +198,16 @@ func Test_TimeBaseUpgrade_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -524,6 +534,16 @@ func Test_TimeBaseUpgradeInPast_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains diff --git a/tests/zero_fee_relay_test.go b/tests/zero_fee_relay_test.go index 93992e68..94ff3932 100644 --- a/tests/zero_fee_relay_test.go +++ b/tests/zero_fee_relay_test.go @@ -130,6 +130,16 @@ func TestZeroFee_RelaySuccess_EVM(t *testing.T) { }, nil, "", nil, false, 1179360, true) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -457,6 +467,16 @@ func TestZeroFee_RotatedSequencer_EVM(t *testing.T) { }) require.NoError(t, err) + wallet, found := r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + keyPath := keyDir + "/sequencer_keys" + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) + require.NoError(t, err) + // Check IBC Transfer before switch CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -570,6 +590,21 @@ func TestZeroFee_RotatedSequencer_EVM(t *testing.T) { time.Sleep(120 * time.Second) + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + time.Sleep(60 * time.Second) + + wallet, found = r.GetWallet(rollapp1.Config().ChainID) + require.True(t, found) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + //Update white listed relayers + _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()+"/sequencer_keys", []string{wallet.FormattedAddress()}) + require.NoError(t, err) + afterBlock, err := rollapp1.Height(ctx) require.NoError(t, err) require.True(t, afterBlock > lastBlock) From 673219ef47e2de39a510ea5519d46c837280baa0 Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:46:08 +0700 Subject: [PATCH 2/2] Fix tests (#550) Co-authored-by: hungdinh82 --- tests/admc_test.go | 24 ++++++++++++ tests/automated_denommetadata_test.go | 18 +++++++++ tests/bridging_fee_test.go | 3 ++ tests/canonical_light_client_test.go | 3 ++ tests/eibc_ack_error_test.go | 21 +++++++++++ tests/eibc_client_test.go | 6 +++ tests/eibc_corrupted_memo_test.go | 3 ++ tests/eibc_fee_market_test.go | 12 ++++++ tests/eibc_fee_test.go | 3 ++ tests/eibc_feemarket_test.go | 24 ++++++++++++ tests/eibc_fulfillment_test.go | 27 ++++++++++++++ tests/eibc_invariant_test.go | 6 +++ tests/eibc_nobalance_test.go | 3 ++ tests/eibc_not_fulfillment_test.go | 6 +++ tests/eibc_pfm_test.go | 6 +++ tests/eibc_timeout_test.go | 9 +++++ tests/erc20_ibc_transfer_test.go | 6 +++ tests/frozen_test.go | 42 +++++++++++++++++++++ tests/genesis_bridge_test.go | 51 +++++++++++++++++++++----- tests/hardfork_test.go | 16 +++++--- tests/ibc_finalize_block_test.go | 18 +++++++++ tests/ibc_grace_period_test.go | 18 +++++++++ tests/ibc_timeout_test.go | 3 ++ tests/ibc_transfer_test.go | 6 +++ tests/rollapp_invariant_test.go | 6 +++ tests/rollapp_state_update_test.go | 18 +++++++++ tests/rollapp_upgrade_test.go | 6 +++ tests/sequencer_reward_address_test.go | 6 +++ tests/sequencer_rotation_test.go | 22 ++++++----- tests/setup.go | 4 ++ tests/time_upgrade_test.go | 46 +++++++++-------------- tests/zero_fee_relay_test.go | 6 +++ 32 files changed, 396 insertions(+), 52 deletions(-) diff --git a/tests/admc_test.go b/tests/admc_test.go index a5fa6d98..ac41c6ef 100644 --- a/tests/admc_test.go +++ b/tests/admc_test.go @@ -120,6 +120,9 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -320,6 +323,9 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -598,6 +604,9 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -882,6 +891,9 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1082,6 +1094,9 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1357,6 +1372,9 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1666,6 +1684,9 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1896,6 +1917,9 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/automated_denommetadata_test.go b/tests/automated_denommetadata_test.go index 69be7328..4d3f1765 100644 --- a/tests/automated_denommetadata_test.go +++ b/tests/automated_denommetadata_test.go @@ -191,6 +191,9 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -506,6 +509,9 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -834,6 +840,9 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1196,6 +1205,9 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1481,6 +1493,9 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1704,6 +1719,9 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/bridging_fee_test.go b/tests/bridging_fee_test.go index dd75cbe1..9234e143 100644 --- a/tests/bridging_fee_test.go +++ b/tests/bridging_fee_test.go @@ -324,6 +324,9 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/canonical_light_client_test.go b/tests/canonical_light_client_test.go index dd5e0ab4..9cd15cf1 100644 --- a/tests/canonical_light_client_test.go +++ b/tests/canonical_light_client_test.go @@ -356,6 +356,9 @@ func TestIBCTransferRA_3rdSameChainID_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_ack_error_test.go b/tests/eibc_ack_error_test.go index aa3420bf..39e2e4a1 100644 --- a/tests/eibc_ack_error_test.go +++ b/tests/eibc_ack_error_test.go @@ -186,6 +186,12 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -694,6 +700,9 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1177,6 +1186,9 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1733,6 +1745,9 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -2237,6 +2252,9 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -2718,6 +2736,9 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_client_test.go b/tests/eibc_client_test.go index 42678423..b101cd73 100644 --- a/tests/eibc_client_test.go +++ b/tests/eibc_client_test.go @@ -393,6 +393,9 @@ func Test_EIBC_Client_Success_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -974,6 +977,9 @@ func Test_EIBC_Client_NoFulfillRollapp_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index c4a80213..3a26e8c9 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -137,6 +137,9 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_fee_market_test.go b/tests/eibc_fee_market_test.go index f4f5ccbd..24a25376 100644 --- a/tests/eibc_fee_market_test.go +++ b/tests/eibc_fee_market_test.go @@ -168,6 +168,9 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -564,6 +567,9 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -960,6 +966,9 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1264,6 +1273,9 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index 28a051bc..a59bb082 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -137,6 +137,9 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_feemarket_test.go b/tests/eibc_feemarket_test.go index 66333ddf..8dddae77 100644 --- a/tests/eibc_feemarket_test.go +++ b/tests/eibc_feemarket_test.go @@ -180,6 +180,9 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -531,6 +534,9 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -896,6 +902,9 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1245,6 +1254,9 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1555,6 +1567,9 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1835,6 +1850,9 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -2137,6 +2155,9 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -2387,6 +2408,9 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 515ef95e..de3980d2 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -185,6 +185,9 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -661,6 +664,9 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1151,6 +1157,9 @@ func TestEIBCFulfillment_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1498,6 +1507,9 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1855,6 +1867,9 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -2306,6 +2321,9 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -2781,6 +2799,9 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -3232,6 +3253,9 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -3527,6 +3551,9 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_invariant_test.go b/tests/eibc_invariant_test.go index 1e48dbdb..4a9598aa 100644 --- a/tests/eibc_invariant_test.go +++ b/tests/eibc_invariant_test.go @@ -142,6 +142,9 @@ func TestEIBCInvariant_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -544,6 +547,9 @@ func TestEIBCInvariant_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index d3a8a131..07cbe7cc 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -138,6 +138,9 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_not_fulfillment_test.go b/tests/eibc_not_fulfillment_test.go index 959728cf..b79fbe7c 100644 --- a/tests/eibc_not_fulfillment_test.go +++ b/tests/eibc_not_fulfillment_test.go @@ -182,6 +182,9 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -516,6 +519,9 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index 80e8fdbc..d5cb6714 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -183,6 +183,9 @@ func TestEIBCPFM_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -502,6 +505,9 @@ func TestEIBCPFM_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index aa217885..83088411 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -137,6 +137,9 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -504,6 +507,9 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -943,6 +949,9 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/erc20_ibc_transfer_test.go b/tests/erc20_ibc_transfer_test.go index 74bf5417..a494cb14 100644 --- a/tests/erc20_ibc_transfer_test.go +++ b/tests/erc20_ibc_transfer_test.go @@ -137,6 +137,9 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -389,6 +392,9 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 5f8e9fa9..59021483 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -189,6 +189,9 @@ func TestRollAppFreeze_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -597,6 +600,9 @@ func TestRollAppFreeze_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -996,6 +1002,9 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1520,6 +1529,9 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1988,6 +2000,9 @@ func TestPacketRollbacked_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -2372,6 +2387,9 @@ func TestPacketRollbacked_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -2815,6 +2833,9 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -3218,6 +3239,9 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -3621,6 +3645,9 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -4099,6 +4126,9 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -4532,6 +4562,9 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -4889,6 +4922,9 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -5246,6 +5282,9 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -5618,6 +5657,9 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/genesis_bridge_test.go b/tests/genesis_bridge_test.go index 2dee3415..8e265b06 100644 --- a/tests/genesis_bridge_test.go +++ b/tests/genesis_bridge_test.go @@ -123,6 +123,9 @@ func TestGenesisTransferBridgeBlocking_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -286,6 +289,9 @@ func TestGenesisTransferBridgeBlocking_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -449,6 +455,9 @@ func TestGenesisTransferConnectionBlock_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -643,6 +652,9 @@ func TestGenesisTransferConnectionBlock_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1054,6 +1066,9 @@ func TestGenesisBridgeNoRelayAck_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1207,6 +1222,9 @@ func TestGenesisBridgeNoRelayAck_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1388,6 +1406,9 @@ func TestGenesisBridgeBeforeChannelSet_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1587,6 +1608,9 @@ func TestGenesisBridgeWithoutGenesisAcc_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1746,6 +1770,9 @@ func TestGenesisTransferBridgeUnBond_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1923,6 +1950,9 @@ func TestGenesisTransferBridgeUnBond_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -2018,12 +2048,16 @@ func TestGenTransferBridgeKickProposer_EVM(t *testing.T) { modifyHubGenesisKV := append( dymensionGenesisKV, + // cosmos.GenesisKV{ + // Key: "app_state.sequencer.params.kick_threshold", + // Value: map[string]interface{}{ + // "denom": "adym", + // "amount": "99999999999999999999", + // }, + // }, cosmos.GenesisKV{ - Key: "app_state.sequencer.params.kick_threshold", - Value: map[string]interface{}{ - "denom": "adym", - "amount": "99999999999999999999", - }, + Key: "app_state.sequencer.params.dishonor_kick_threshold", + Value: "1", }, cosmos.GenesisKV{ Key: "app_state.rollapp.params.liveness_slash_blocks", @@ -2235,11 +2269,8 @@ func TestGenTransferBridgeKickProposer_Wasm(t *testing.T) { modifyHubGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ - Key: "app_state.sequencer.params.kick_threshold", - Value: map[string]interface{}{ - "denom": "adym", - "amount": "99999999999999999999", - }, + Key: "app_state.sequencer.params.dishonor_kick_threshold", + Value: "1", }, cosmos.GenesisKV{ Key: "app_state.rollapp.params.liveness_slash_blocks", diff --git a/tests/hardfork_test.go b/tests/hardfork_test.go index 3cf9fb15..877d7806 100644 --- a/tests/hardfork_test.go +++ b/tests/hardfork_test.go @@ -208,6 +208,9 @@ func TestHardForkDueToFraud_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -483,11 +486,8 @@ func Test_HardFork_KickProposer_EVM(t *testing.T) { modifyHubGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ - Key: "app_state.sequencer.params.kick_threshold", - Value: map[string]interface{}{ - "denom": "adym", - "amount": "99999999999999999999", - }, + Key: "app_state.sequencer.params.dishonor_kick_threshold", + Value: "1", }, cosmos.GenesisKV{ Key: "app_state.rollapp.params.liveness_slash_blocks", @@ -607,6 +607,9 @@ func Test_HardFork_KickProposer_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1083,6 +1086,9 @@ func TestHardForkDueToDrs_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/ibc_finalize_block_test.go b/tests/ibc_finalize_block_test.go index 7179d994..8a673bd2 100644 --- a/tests/ibc_finalize_block_test.go +++ b/tests/ibc_finalize_block_test.go @@ -124,6 +124,9 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -404,6 +407,9 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -590,6 +596,9 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -832,6 +841,9 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1117,6 +1129,9 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -1304,6 +1319,9 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index b00a17f4..f17a4e16 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -181,6 +181,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -533,6 +536,9 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -888,6 +894,9 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1187,6 +1196,9 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1479,6 +1491,9 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1828,6 +1843,9 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index d755d213..cd8b84fe 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -136,6 +136,9 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index 25f972b9..62dc6789 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -204,6 +204,9 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -412,6 +415,9 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/rollapp_invariant_test.go b/tests/rollapp_invariant_test.go index cba8d36c..6020c05c 100644 --- a/tests/rollapp_invariant_test.go +++ b/tests/rollapp_invariant_test.go @@ -176,6 +176,9 @@ func TestRollappInvariant_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -451,6 +454,9 @@ func TestRollappInvariant_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/rollapp_state_update_test.go b/tests/rollapp_state_update_test.go index 94598764..cce66811 100644 --- a/tests/rollapp_state_update_test.go +++ b/tests/rollapp_state_update_test.go @@ -197,6 +197,9 @@ func Test_RollAppStateUpdateSuccess_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -539,6 +542,9 @@ func Test_RollAppStateUpdateSuccess_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -897,6 +903,9 @@ func Test_RollAppStateUpdateFail_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1269,6 +1278,9 @@ func Test_RollAppStateUpdateFail_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -1811,6 +1823,9 @@ func Test_RollAppStateUpdateFail_Celes_EVM(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) @@ -2293,6 +2308,9 @@ func Test_RollAppStateUpdateFail_Celes_Wasm(t *testing.T) { require.NoError(t, err) keyPath2 := keyDir2 + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/rollapp_upgrade_test.go b/tests/rollapp_upgrade_test.go index a71d2ed4..650f44aa 100644 --- a/tests/rollapp_upgrade_test.go +++ b/tests/rollapp_upgrade_test.go @@ -126,6 +126,9 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -413,6 +416,9 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index 7df0c5ad..ef2d1c4d 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -229,6 +229,9 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -648,6 +651,9 @@ func Test_SeqRewardsAddress_Update_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) diff --git a/tests/sequencer_rotation_test.go b/tests/sequencer_rotation_test.go index d94db30e..2800c51c 100644 --- a/tests/sequencer_rotation_test.go +++ b/tests/sequencer_rotation_test.go @@ -2460,7 +2460,7 @@ func Test_SeqRotation_NoSeq_P2P_Wasm(t *testing.T) { require.NoError(t, err) } - containerID = fmt.Sprintf("ra-rollappevm_1234-1-fn-0-%s", t.Name()) + containerID = fmt.Sprintf("ra-rollappwasm_1234-1-fn-0-%s", t.Name()) // Get the container details containerJSON, err = client.ContainerInspect(context.Background(), containerID) @@ -2986,7 +2986,7 @@ func Test_SqcRotation_OneSqc_P2P_EVM(t *testing.T) { lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(200 * time.Second) + time.Sleep(250 * time.Second) currentProposer, err = dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) require.NoError(t, err) @@ -3506,7 +3506,7 @@ func Test_SqcRotation_OneSqc_P2P_Wasm(t *testing.T) { lastBlock, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(200 * time.Second) + time.Sleep(250 * time.Second) currentProposer, err = dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) require.NoError(t, err) @@ -6802,12 +6802,16 @@ func Test_SeqRotation_Forced_DA_EVM(t *testing.T) { modifyHubGenesisKV := append( dymensionGenesisKV, + // cosmos.GenesisKV{ + // Key: "app_state.sequencer.params.kick_threshold", + // Value: map[string]interface{}{ + // "denom": "adym", + // "amount": "99999999999999999999", + // }, + // }, cosmos.GenesisKV{ - Key: "app_state.sequencer.params.kick_threshold", - Value: map[string]interface{}{ - "denom": "adym", - "amount": "99999999999999999999", - }, + Key: "app_state.sequencer.params.dishonor_kick_threshold", + Value: "1", }, cosmos.GenesisKV{ Key: "app_state.rollapp.params.liveness_slash_blocks", @@ -7216,7 +7220,7 @@ func Test_SeqRotation_Forced_DA_EVM(t *testing.T) { wallet, found = r.GetWallet(rollapp1.Config().ChainID) require.True(t, found) - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) //Update white listed relayers diff --git a/tests/setup.go b/tests/setup.go index 214aa505..e22c778d 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -200,6 +200,10 @@ var ( } rollappEVMGenesisKV = []cosmos.GenesisKV{ + { + Key: "app_state.rollappparams.params.drs_version", + Value: 2, + }, { Key: "consensus_params.block.max_gas", Value: "400000000", diff --git a/tests/time_upgrade_test.go b/tests/time_upgrade_test.go index cb63afc7..0b1050e9 100644 --- a/tests/time_upgrade_test.go +++ b/tests/time_upgrade_test.go @@ -204,6 +204,9 @@ func Test_TimeBaseUpgrade_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -253,17 +256,9 @@ func Test_TimeBaseUpgrade_EVM(t *testing.T) { fmt.Println("Upgrade Time:", upgradeTime) msg := map[string]interface{}{ "@type": "/rollapp.timeupgrade.types.MsgSoftwareUpgrade", - "original_upgrade": map[string]interface{}{ - "authority": "ethm10d07y265gmmuvt4z0w9aw880jnsr700jpva843", - "plan": map[string]interface{}{ - "name": "v0.2.1", - "time": "0001-01-01T00:00:00Z", - "height": haltHeight, - "info": "{}", - "upgraded_client_state": nil, - }, - }, - "upgrade_time": upgradeTime, + "authority": "ethm10d07y265gmmuvt4z0w9aw880jnsr700jpva843", + "drs": 2, + "upgrade_time": upgradeTime, } rawMsg, err := json.Marshal(msg) @@ -273,9 +268,9 @@ func Test_TimeBaseUpgrade_EVM(t *testing.T) { proposal := cosmos.TxProposalV1{ Deposit: "500000000000" + rollapp1.Config().Denom, - Title: "rollapp Upgrade 1", - Summary: "test", - Description: "First software upgrade", + Title: "Update Dymension to DRS-2", + Summary: "This proposal aims to upgrade the Dymension rollapp to DRS 2, implementing new features and improvements, with a scheduled upgrade time.", + Description: "Upgrade Dymension to DRS-2 version with scheduled upgrade time", Messages: []json.RawMessage{rawMsg}, Expedited: true, } @@ -540,6 +535,9 @@ func Test_TimeBaseUpgradeInPast_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -591,17 +589,9 @@ func Test_TimeBaseUpgradeInPast_EVM(t *testing.T) { fmt.Println("Upgrade Time:", upgradeTime) msg := map[string]interface{}{ "@type": "/rollapp.timeupgrade.types.MsgSoftwareUpgrade", - "original_upgrade": map[string]interface{}{ - "authority": "ethm10d07y265gmmuvt4z0w9aw880jnsr700jpva843", - "plan": map[string]interface{}{ - "name": "v0.2.1", - "time": "0001-01-01T00:00:00Z", - "height": "1800", - "info": "{}", - "upgraded_client_state": nil, - }, - }, - "upgrade_time": upgradeTime, + "authority": "ethm10d07y265gmmuvt4z0w9aw880jnsr700jpva843", + "drs": 2, + "upgrade_time": upgradeTime, } rawMsg, err := json.Marshal(msg) @@ -611,9 +601,9 @@ func Test_TimeBaseUpgradeInPast_EVM(t *testing.T) { proposal := cosmos.TxProposalV1{ Deposit: "500000000000" + rollapp1.Config().Denom, - Title: "rollapp Upgrade 1", - Summary: "test", - Description: "First software upgrade", + Title: "Update Dymension to DRS-2", + Summary: "This proposal aims to upgrade the Dymension rollapp to DRS 2, implementing new features and improvements, with a scheduled upgrade time.", + Description: "Upgrade Dymension to DRS-2 version with scheduled upgrade time", Messages: []json.RawMessage{rawMsg}, Expedited: true, } diff --git a/tests/zero_fee_relay_test.go b/tests/zero_fee_relay_test.go index 94ff3932..b5f73121 100644 --- a/tests/zero_fee_relay_test.go +++ b/tests/zero_fee_relay_test.go @@ -136,6 +136,9 @@ func TestZeroFee_RelaySuccess_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err) @@ -473,6 +476,9 @@ func TestZeroFee_RotatedSequencer_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + //Update white listed relayers _, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()}) require.NoError(t, err)