Skip to content

Commit

Permalink
Use legacy message register interchain account in tests only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ljoss17 committed Aug 14, 2024
1 parent 97897d1 commit 247ddfe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
6 changes: 3 additions & 3 deletions tools/integration-test/src/tests/ica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use ibc_relayer_types::tx_msg::Msg;

use ibc_test_framework::chain::{
config::add_allow_message_interchainaccounts,
ext::ica::{register_interchain_account, register_ordered_interchain_account},
ext::ica::{register_ordered_interchain_account, register_unordered_interchain_account},
};
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::{
Expand Down Expand Up @@ -99,7 +99,7 @@ impl BinaryConnectionTest for IcaFilterTestAllow {
// Register an interchain account on behalf of
// controller wallet `user1` where the counterparty chain is the interchain accounts host.
let (wallet, channel_id, port_id) =
register_interchain_account(&chains.node_a, chains.handle_a(), &connection)?;
register_unordered_interchain_account(&chains.node_a, chains.handle_a(), &connection)?;

// Check that the corresponding ICA channel is eventually established.
let _counterparty_channel_id = assert_eventually_channel_established(
Expand Down Expand Up @@ -211,7 +211,7 @@ impl BinaryConnectionTest for IcaFilterTestDeny {
// Register an interchain account on behalf of controller wallet `user1`
// where the counterparty chain is the interchain accounts host.
let (_, channel_id, port_id) =
register_interchain_account(&chains.node_a, chains.handle_a(), &connection)?;
register_unordered_interchain_account(&chains.node_a, chains.handle_a(), &connection)?;

// Wait a bit, the relayer will refuse to complete the channel handshake
// because the port is explicitly disallowed by the filter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use ibc_relayer_types::signer::Signer;
use ibc_relayer_types::timestamp::Timestamp;
use ibc_relayer_types::tx_msg::Msg;
use ibc_test_framework::chain::config::add_allow_message_interchainaccounts;
use ibc_test_framework::chain::ext::ica::register_interchain_account;
use ibc_test_framework::chain::ext::ica::register_ordered_interchain_account;
use ibc_test_framework::framework::binary::channel::run_binary_interchain_security_channel_test;
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::assert_eventually_channel_established;
Expand Down Expand Up @@ -74,8 +74,11 @@ impl BinaryChannelTest for IcaOrderedChannelTest {
let fee_denom_a: MonoTagged<ChainA, Denom> =
MonoTagged::new(Denom::base(config.native_token(0)));
let connection_b_to_a = channel.connection.clone().flip();
let (wallet, channel_id, port_id) =
register_interchain_account(&chains.node_b, chains.handle_b(), &connection_b_to_a)?;
let (wallet, channel_id, port_id) = register_ordered_interchain_account(
&chains.node_b,
chains.handle_b(),
&connection_b_to_a,
)?;

relayer.with_supervisor(|| {
// Check that the corresponding ICA channel is eventually established.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ibc_relayer_types::signer::Signer;
use ibc_relayer_types::timestamp::Timestamp;
use ibc_relayer_types::tx_msg::Msg;
use ibc_test_framework::chain::config::add_allow_message_interchainaccounts;
use ibc_test_framework::chain::ext::ica::register_interchain_account;
use ibc_test_framework::chain::ext::ica::register_unordered_interchain_account;
use ibc_test_framework::framework::binary::channel::run_binary_interchain_security_channel_test;
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::assert_eventually_channel_established;
Expand Down Expand Up @@ -57,8 +57,11 @@ impl BinaryChannelTest for InterchainSecurityIcaTransferTest {
let fee_denom_a: MonoTagged<ChainA, Denom> =
MonoTagged::new(Denom::base(config.native_token(0)));
let connection_b_to_a = channel.connection.clone().flip();
let (wallet, channel_id, port_id) =
register_interchain_account(&chains.node_b, chains.handle_b(), &connection_b_to_a)?;
let (wallet, channel_id, port_id) = register_unordered_interchain_account(
&chains.node_b,
chains.handle_b(),
&connection_b_to_a,
)?;

// Check that the corresponding ICA channel is eventually established.
let _counterparty_channel_id = assert_eventually_channel_established(
Expand Down
25 changes: 18 additions & 7 deletions tools/test-framework/src/chain/ext/ica.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use ibc_relayer::upgrade_chain::requires_legacy_upgrade_proposal;
use serde_json::json;

use ibc_relayer::chain::tracking::TrackedMsgs;
Expand Down Expand Up @@ -63,7 +64,7 @@ impl<'a, Chain: Send> InterchainAccountMethodsExt<Chain> for MonoTagged<Chain, &
}

#[allow(clippy::type_complexity)]
pub fn register_interchain_account<Chain: ChainHandle, Counterparty: ChainHandle>(
pub fn register_unordered_interchain_account<Chain: ChainHandle, Counterparty: ChainHandle>(
chain: &MonoTagged<Chain, FullNode>,
handle: &Chain,
connection: &ConnectedConnection<Chain, Counterparty>,
Expand All @@ -87,14 +88,24 @@ pub fn register_interchain_account<Chain: ChainHandle, Counterparty: ChainHandle
"host_connection_id": connection.connection_id_b.0
});

let msg = LegacyMsgRegisterInterchainAccount {
owner,
connection_id: connection.connection_id_a.0.clone(),
version: Version::new(version_obj.to_string()),
let msg_any = if requires_legacy_upgrade_proposal(handle.clone()) {
let msg = LegacyMsgRegisterInterchainAccount {
owner,
connection_id: connection.connection_id_a.0.clone(),
version: Version::new(version_obj.to_string()),
};

msg.to_any()
} else {
let msg = MsgRegisterInterchainAccount {
owner,
connection_id: connection.connection_id_a.0.clone(),
version: Version::new(version_obj.to_string()),
ordering: Ordering::Ordered,
};
msg.to_any()
};

let msg_any = msg.to_any();

let tm = TrackedMsgs::new_static(vec![msg_any], "RegisterInterchainAccount");

let events = handle
Expand Down

0 comments on commit 247ddfe

Please sign in to comment.