diff --git a/tests/admc_test.go b/tests/admc_test.go index 3908a0a7..ac41c6ef 100644 --- a/tests/admc_test.go +++ b/tests/admc_test.go @@ -114,6 +114,19 @@ 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" + + 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 @@ -304,6 +317,19 @@ 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" + + 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 @@ -572,6 +598,19 @@ 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" + + 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 @@ -846,6 +885,19 @@ 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" + + 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 @@ -1036,6 +1088,19 @@ 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" + + 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 @@ -1301,6 +1366,19 @@ 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" + + 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 @@ -1600,6 +1678,19 @@ 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" + + 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 @@ -1820,6 +1911,19 @@ 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" + + 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/automated_denommetadata_test.go b/tests/automated_denommetadata_test.go index 8afffca3..4d3f1765 100644 --- a/tests/automated_denommetadata_test.go +++ b/tests/automated_denommetadata_test.go @@ -178,6 +178,32 @@ 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" + + 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) + + 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 +503,19 @@ 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" + + 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) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -788,6 +827,32 @@ 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" + + 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) + + 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 +1192,32 @@ 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" + + 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) + + 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 +1487,19 @@ 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" + + 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 @@ -1609,6 +1713,19 @@ 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" + + 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 @@ -1696,7 +1813,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 +1822,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..9234e143 100644 --- a/tests/bridging_fee_test.go +++ b/tests/bridging_fee_test.go @@ -311,6 +311,32 @@ 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" + + 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) + + 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..9cd15cf1 100644 --- a/tests/canonical_light_client_test.go +++ b/tests/canonical_light_client_test.go @@ -350,6 +350,19 @@ 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" + + 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) + // 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 0982e0d0..92add0b7 100644 --- a/tests/eibc_ack_error_test.go +++ b/tests/eibc_ack_error_test.go @@ -171,6 +171,35 @@ 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" + + 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) + + 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) @@ -656,6 +685,32 @@ 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" + + 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) + + 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) @@ -1116,6 +1171,32 @@ 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" + + 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) + + 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) @@ -1606,6 +1687,32 @@ 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" + + 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) + + 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) @@ -1733,11 +1840,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) @@ -1768,8 +1870,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(), @@ -1790,6 +1893,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, @@ -1812,10 +1916,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) @@ -1836,16 +1939,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) @@ -1853,7 +1964,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) @@ -1862,7 +1973,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) @@ -1894,7 +2005,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) @@ -1919,7 +2030,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) }) @@ -2083,6 +2194,32 @@ 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" + + 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) + + 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) @@ -2361,7 +2498,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) @@ -2371,7 +2508,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) @@ -2541,6 +2678,32 @@ 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" + + 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) + + 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..b101cd73 100644 --- a/tests/eibc_client_test.go +++ b/tests/eibc_client_test.go @@ -387,6 +387,19 @@ 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" + + 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 @@ -958,6 +971,19 @@ 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" + + 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/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index 8cdc8080..3a26e8c9 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -131,6 +131,19 @@ 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" + + 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/eibc_fee_market_test.go b/tests/eibc_fee_market_test.go index b4abc5d8..24a25376 100644 --- a/tests/eibc_fee_market_test.go +++ b/tests/eibc_fee_market_test.go @@ -155,6 +155,32 @@ 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" + + 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) + + 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 +554,32 @@ 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" + + 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) + + 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 +684,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 +694,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 +757,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 +770,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 +794,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 +953,32 @@ 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" + + 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) + + 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 +1260,32 @@ 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" + + 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) + + 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 +1359,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 +1369,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 +1411,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..a59bb082 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -131,6 +131,19 @@ 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" + + 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/eibc_feemarket_test.go b/tests/eibc_feemarket_test.go index c2df3f48..8dddae77 100644 --- a/tests/eibc_feemarket_test.go +++ b/tests/eibc_feemarket_test.go @@ -167,6 +167,32 @@ 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" + + 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) + + 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 +521,32 @@ 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" + + 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) + + 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 +614,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 +624,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 +705,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 +715,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 +889,32 @@ 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" + + 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) + + 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 +1241,32 @@ 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" + + 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) + + 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 +1335,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 +1345,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 +1419,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 +1429,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 +1561,19 @@ 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" + + 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 @@ -1727,6 +1844,19 @@ 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" + + 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 @@ -1874,7 +2004,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 +2014,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 +2149,19 @@ 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" + + 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 @@ -2259,6 +2402,19 @@ 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" + + 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 @@ -2325,7 +2481,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 +2522,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..de3980d2 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -172,6 +172,32 @@ 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" + + 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) + + 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 +651,32 @@ 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" + + 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) + + 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 +818,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 +828,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 +909,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 +923,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 +930,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 +948,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 +1144,32 @@ 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" + + 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) + + 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 +1494,32 @@ 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" + + 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) + + 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 +1588,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 +1598,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 +1612,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 +1629,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 +1641,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 +1662,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 +1670,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 +1688,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 +1854,32 @@ 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" + + 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) + + 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 +2308,32 @@ 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" + + 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) + + 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 +2786,32 @@ 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" + + 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) + + 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 +2976,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 +2986,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 +2995,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 +3037,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 +3061,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 +3240,32 @@ 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" + + 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) + + 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 +3538,32 @@ 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" + + 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) + + 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..4a9598aa 100644 --- a/tests/eibc_invariant_test.go +++ b/tests/eibc_invariant_test.go @@ -136,6 +136,19 @@ 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" + + 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, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains @@ -521,6 +534,32 @@ 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" + + 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) + + 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 +645,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 +655,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 +730,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 +740,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..07cbe7cc 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -132,6 +132,19 @@ 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" + + 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/eibc_not_fulfillment_test.go b/tests/eibc_not_fulfillment_test.go index 3d3050af..b79fbe7c 100644 --- a/tests/eibc_not_fulfillment_test.go +++ b/tests/eibc_not_fulfillment_test.go @@ -169,6 +169,32 @@ 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" + + 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) + + 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 +506,32 @@ 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" + + 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) + + 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..d5cb6714 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -170,6 +170,32 @@ 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" + + 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) + + 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 +492,32 @@ 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" + + 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) + + 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..83088411 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -131,6 +131,19 @@ 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" + + 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 @@ -488,6 +501,19 @@ 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" + + 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) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) @@ -910,6 +936,32 @@ 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" + + 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) + + 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 +1171,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 +1181,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 5a2b45ff..c1450a9f 100644 --- a/tests/erc20_ibc_transfer_test.go +++ b/tests/erc20_ibc_transfer_test.go @@ -138,6 +138,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) @@ -430,6 +433,9 @@ func TestERC20RollAppToHubNewRegister_EVM(t *testing.T) { keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() keyPath := keyDir + "/sequencer_keys" + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + 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 6be0b019..59021483 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -176,6 +176,32 @@ 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" + + 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) + + 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 +587,32 @@ 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" + + 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) + + 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 +989,32 @@ 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" + + 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) + + 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 +1516,32 @@ 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" + + 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) + + 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 +1994,19 @@ 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" + + 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) // Start both relayers @@ -2264,6 +2381,19 @@ 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" + + 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) // Start both relayers @@ -2690,6 +2820,32 @@ 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" + + 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) + + 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 +3226,32 @@ 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" + + 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) + + 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 +3632,32 @@ 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" + + 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) + + 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 +4113,32 @@ 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" + + 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) + + 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 +4556,19 @@ 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" + + 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) // Start both relayers @@ -4669,6 +4916,19 @@ 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" + + 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) // Start both relayers @@ -5016,6 +5276,19 @@ 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" + + 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) // Start both relayers @@ -5378,6 +5651,19 @@ 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" + + 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) // 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..8e265b06 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,19 @@ 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" + + 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 @@ -269,6 +283,19 @@ 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" + + 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 @@ -422,6 +449,19 @@ 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" + + 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 @@ -606,6 +646,19 @@ 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" + + 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 @@ -1007,6 +1060,19 @@ 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" + + 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 @@ -1150,6 +1216,19 @@ 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" + + 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 @@ -1321,6 +1400,19 @@ 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" + + 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) channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) @@ -1510,6 +1602,19 @@ 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" + + 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 @@ -1659,6 +1764,19 @@ 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" + + 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 @@ -1826,6 +1944,19 @@ 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" + + 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 @@ -1917,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", @@ -2031,6 +2166,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) @@ -2121,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", @@ -2234,6 +2379,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..877d7806 100644 --- a/tests/hardfork_test.go +++ b/tests/hardfork_test.go @@ -202,6 +202,19 @@ 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" + + 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) @@ -352,6 +365,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) @@ -463,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", @@ -578,6 +598,22 @@ 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) + + 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 +1080,19 @@ 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" + + 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/ibc_finalize_block_test.go b/tests/ibc_finalize_block_test.go index 9c1e331a..8a673bd2 100644 --- a/tests/ibc_finalize_block_test.go +++ b/tests/ibc_finalize_block_test.go @@ -118,6 +118,19 @@ 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" + + 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 @@ -388,6 +401,19 @@ 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" + + 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, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) @@ -564,6 +590,19 @@ 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" + + 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 @@ -796,6 +835,19 @@ 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" + + 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 @@ -1071,6 +1123,19 @@ 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" + + 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, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) @@ -1248,6 +1313,19 @@ 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" + + 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_grace_period_test.go b/tests/ibc_grace_period_test.go index ca448618..f17a4e16 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -168,6 +168,32 @@ 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" + + 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) + + 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 +523,32 @@ 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" + + 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) + + 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 +881,32 @@ 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" + + 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) + + 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 +1183,32 @@ 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" + + 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) + + 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 +1478,32 @@ 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" + + 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) + + 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 +1830,32 @@ 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" + + 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) + + 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..cd8b84fe 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -130,6 +130,19 @@ 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" + + 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 @@ -253,6 +266,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 +462,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..62dc6789 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -198,6 +198,19 @@ 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" + + 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 @@ -396,6 +409,19 @@ 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" + + 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/rollapp_invariant_test.go b/tests/rollapp_invariant_test.go index add26cb4..6020c05c 100644 --- a/tests/rollapp_invariant_test.go +++ b/tests/rollapp_invariant_test.go @@ -163,6 +163,32 @@ 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" + + 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) + + 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 +441,32 @@ 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" + + 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) + + 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..cce66811 100644 --- a/tests/rollapp_state_update_test.go +++ b/tests/rollapp_state_update_test.go @@ -184,6 +184,32 @@ 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" + + 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) + + 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 +422,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 +444,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 +529,32 @@ 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" + + 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) + + 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 +890,32 @@ 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" + + 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) + + 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 +1158,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 +1180,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 +1265,32 @@ 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" + + 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) + + 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 +1613,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 +1810,32 @@ 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" + + 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) + + 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 +1949,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 +2067,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 +2078,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 +2177,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 +2204,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 +2229,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 +2238,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 +2295,32 @@ 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" + + 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) + + 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 +2340,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 +2356,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 +2431,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 +2458,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..650f44aa 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,19 @@ 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" + + 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 @@ -902,6 +410,19 @@ 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" + + 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/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index 6c623c51..ef2d1c4d 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -223,6 +223,19 @@ 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" + + 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) @@ -632,6 +645,19 @@ 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" + + 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) @@ -790,7 +816,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 +893,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..2800c51c 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-rollappwasm_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 @@ -2812,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) @@ -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) - // 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)) + + // 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, + } - // // Get the IBC denom - // dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - // dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).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, 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) + // 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) + + 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(250 * 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) + + 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) + + // Start full node + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) + + err = rollapp1.Validators[0].StartContainer(ctx) + require.NoError(t, err) + + 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) - // // 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 + 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) - // // 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)) + // Check IBC after switch + 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).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)) + res, 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 res.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() - // // 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, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) - // 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 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)) + + // 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() + resp, 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 resp.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) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.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() - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + 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) - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + for _, network := range containerJSON.NetworkSettings.Networks { + ipAddress = network.IPAddress + break // Assuming we only need the IP from the first network + } - // // wait until the packet is finalized - // isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - // require.NoError(t, err) - // require.True(t, isFinalized) + 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) - // // 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() + rollapp1HomeDir = strings.Split(rollapp1.Validators[0].HomeDir(), "/") + rollapp1FolderName = rollapp1HomeDir[len(rollapp1HomeDir)-1] - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + file, err = os.Open(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) + lines = []string{} + scanner = bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } - // // Compose an IBC transfer and send from dymension -> rollapp - // transferData = ibc.WalletData{ - // Address: rollappUserAddr, - // Denom: dymension.Config().Denom, - // Amount: transferAmount, - // } + 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 Hub -> rollapp - // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - // require.NoError(t, err) + output = strings.Join(lines, "\n") + file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() - // // Assert balance was updated on the hub - // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + _, err = file.Write([]byte(output)) + require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - // require.NoError(t, err) + // Start full node + err = rollapp1.Validators[0].StopContainer(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() + err = rollapp1.Validators[0].StartContainer(ctx) + 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) + time.Sleep(100 * time.Second) + + 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, + } - // // Get the IBC denom - // dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - // dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).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, 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) + // 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) 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) @@ -6307,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", @@ -6486,6 +6985,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 +7217,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, 10, 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 1247d1c9..f7c65bb3 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", @@ -280,6 +284,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..0b1050e9 100644 --- a/tests/time_upgrade_test.go +++ b/tests/time_upgrade_test.go @@ -198,6 +198,19 @@ 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" + + 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 @@ -243,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) @@ -263,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, } @@ -524,6 +529,19 @@ 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" + + 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 @@ -571,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) @@ -591,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 93992e68..b5f73121 100644 --- a/tests/zero_fee_relay_test.go +++ b/tests/zero_fee_relay_test.go @@ -130,6 +130,19 @@ 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" + + 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 @@ -457,6 +470,19 @@ 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" + + 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) @@ -570,6 +596,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)