From dffe1cbc86a7323ac76fa2ab50e828414765de8c Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 22 Apr 2022 12:48:32 +0200 Subject: [PATCH] Simplify bootstrap function arguments with default-able options (#2078) * Refactor bootstrap chain and foreign client code * Introduce BootstrapChannel/ConnectionOptions * Use builder pattern for bootstrap option types --- .../src/tests/client_expiration.rs | 28 +- .../src/bootstrap/binary/chain.rs | 303 ++++++------------ .../src/bootstrap/binary/channel.rs | 71 ++-- .../src/bootstrap/binary/connection.rs | 34 +- .../src/bootstrap/nary/chain.rs | 7 +- .../src/bootstrap/nary/channel.rs | 13 +- .../src/bootstrap/nary/connection.rs | 12 +- .../src/framework/binary/chain.rs | 18 +- .../src/framework/binary/channel.rs | 15 +- .../src/framework/binary/connection.rs | 12 +- 10 files changed, 235 insertions(+), 278 deletions(-) diff --git a/tools/integration-test/src/tests/client_expiration.rs b/tools/integration-test/src/tests/client_expiration.rs index 57b57da9bb..10dcfe0d24 100644 --- a/tools/integration-test/src/tests/client_expiration.rs +++ b/tools/integration-test/src/tests/client_expiration.rs @@ -3,11 +3,9 @@ use std::thread::sleep; use ibc::core::ics03_connection::connection::State as ConnectionState; use ibc::core::ics04_channel::channel::State as ChannelState; -use ibc::core::ics04_channel::Version as ChannelVersion; -use ibc_relayer::config::default::connection_delay as default_connection_delay; use ibc_relayer::config::{self, Config, ModeConfig}; -use ibc_test_framework::bootstrap::binary::chain::ForeignClientBuilder; +use ibc_test_framework::bootstrap::binary::chain::bootstrap_foreign_client_pair; use ibc_test_framework::bootstrap::binary::channel::{ bootstrap_channel_with_chains, bootstrap_channel_with_connection, }; @@ -140,7 +138,7 @@ impl BinaryChainTest for ChannelExpirationTest { let connection = { let _refresh_tasks = spawn_refresh_client_tasks(&chains.foreign_clients)?; - bootstrap_connection(&chains.foreign_clients, default_connection_delay(), false)? + bootstrap_connection(&chains.foreign_clients, Default::default())? }; wait_for_client_expiry(); @@ -214,9 +212,11 @@ impl BinaryChainTest for ChannelExpirationTest { "Trying to create new channel and worker after previous connection worker failed" ); - let foreign_clients_2 = ForeignClientBuilder::new(&chains.handle_a, &chains.handle_b) - .pair() - .bootstrap()?; + let foreign_clients_2 = bootstrap_foreign_client_pair( + &chains.handle_a, + &chains.handle_b, + Default::default(), + )?; // Need to spawn refresh client for new clients to make sure they don't expire @@ -282,10 +282,8 @@ impl BinaryChainTest for PacketExpirationTest { &chains, &PortId::transfer(), &PortId::transfer(), - Order::Unordered, - ChannelVersion::ics20(), - default_connection_delay(), - false, + Default::default(), + Default::default(), )? }; @@ -367,14 +365,14 @@ impl BinaryChainTest for CreateOnExpiredClientTest { let connection = { let _refresh_tasks = spawn_refresh_client_tasks(&chains.foreign_clients)?; - bootstrap_connection(&chains.foreign_clients, default_connection_delay(), false)? + bootstrap_connection(&chains.foreign_clients, Default::default())? }; wait_for_client_expiry(); info!("trying to bootstrap connection after IBC client is expired"); - let res = bootstrap_connection(&chains.foreign_clients, default_connection_delay(), false); + let res = bootstrap_connection(&chains.foreign_clients, Default::default()); match res { Ok(_) => { @@ -397,9 +395,7 @@ impl BinaryChainTest for CreateOnExpiredClientTest { connection, &DualTagged::new(&PortId::transfer()), &DualTagged::new(&PortId::transfer()), - Order::Unordered, - ChannelVersion::ics20(), - false, + Default::default(), ); match res { diff --git a/tools/test-framework/src/bootstrap/binary/chain.rs b/tools/test-framework/src/bootstrap/binary/chain.rs index ff8991d2ee..ac85b78837 100644 --- a/tools/test-framework/src/bootstrap/binary/chain.rs +++ b/tools/test-framework/src/bootstrap/binary/chain.rs @@ -26,223 +26,95 @@ use crate::types::tagged::*; use crate::types::wallet::{TestWallets, Wallet}; use crate::util::random::random_u64_range; -/// A builder to bootstrap two relayer chain handles with connected -/// foreign clients. -pub struct Builder<'config> { - test_config: &'config TestConfig, - node_a: FullNode, - node_b: FullNode, - client_options_a_to_b: ClientOptions, - client_options_b_to_a: ClientOptions, +#[derive(Default)] +pub struct BootstrapClientOptions { + pub client_options_a_to_b: ClientOptions, + pub client_options_b_to_a: ClientOptions, } -impl<'config> Builder<'config> { - /// Initializes the builder with two [`FullNode`] values representing two different - /// running full nodes, to bootstrap chain A and chain B respectively. - pub fn with_node_pair( - test_config: &'config TestConfig, - node_a: FullNode, - node_b: FullNode, - ) -> Self { - Self { - test_config, - node_a, - node_b, - client_options_a_to_b: Default::default(), - client_options_b_to_a: Default::default(), - } - } - - /// Work similary to [`with_node_pair`][wnp], but bootstraps a - /// single chain to be connected with itself. - /// - /// Self-connected chains are in fact allowed in IBC. Although we do not - /// have a clear use case for it yet, it is important to verify that - /// tests that pass with two connected chains should also pass with - /// self-connected chains. - /// - /// [wnp]: Builder::with_node_pair - /// - pub fn self_connected(test_config: &'config TestConfig, node: FullNode) -> Self { - let node1 = node.clone(); - Self::with_node_pair(test_config, node, node1) - } - - /// Overrides options for the foreign client connecting chain A to chain B. - pub fn client_options_a_to_b(mut self, options: ClientOptions) -> Self { - self.client_options_a_to_b = options; - self - } - - /// Overrides options for the foreign client connecting chain B to chain A. - pub fn client_options_b_to_a(mut self, options: ClientOptions) -> Self { - self.client_options_b_to_a = options; - self - } - - /// Bootstraps two relayer chain handles with connected foreign clients. - /// - /// Returns a tuple consisting of the [`RelayerDriver`] and a - /// [`ConnectedChains`] object that contains the given - /// full nodes together with the corresponding two [`ChainHandle`]s and - /// [`ForeignClient`]s. - pub fn bootstrap( - self, - ) -> Result< - ( - RelayerDriver, - ConnectedChains, - ), - Error, - > { - self.bootstrap_with_config(|_| {}) - } - - /// Bootstraps two relayer chain handles with connected foreign clients. - /// - /// Returns a tuple consisting of the [`RelayerDriver`] and a - /// [`ConnectedChains`] object that contains the given - /// full nodes together with the corresponding two [`ChainHandle`]s and - /// [`ForeignClient`]s. - /// - /// This method gives the caller a way to modify the relayer configuration - /// that is pre-generated from the configurations of the full nodes. - pub fn bootstrap_with_config( - self, - config_modifier: impl FnOnce(&mut Config), - ) -> Result< - ( - RelayerDriver, - ConnectedChains, - ), - Error, - > { - let mut config = Config::default(); - - add_chain_config(&mut config, &self.node_a)?; - add_chain_config(&mut config, &self.node_b)?; - - config_modifier(&mut config); - - let config_path = self.test_config.chain_store_dir.join("relayer-config.toml"); - - save_relayer_config(&config, &config_path)?; - - let registry = new_registry(config.clone()); - - // Pass in unique closure expressions `||{}` as the first argument so that - // the returned chains are considered different types by Rust. - // See [`spawn_chain_handle`] for more details. - let handle_a = spawn_chain_handle(|| {}, ®istry, &self.node_a)?; - let handle_b = spawn_chain_handle(|| {}, ®istry, &self.node_b)?; - - if self.test_config.bootstrap_with_random_ids { - pad_client_ids(&handle_a, &handle_b)?; - pad_client_ids(&handle_b, &handle_a)?; - } - - let foreign_clients = ForeignClientBuilder::new(&handle_a, &handle_b) - .client_options(self.client_options_a_to_b) - .pair() - .client_options(self.client_options_b_to_a) - .bootstrap()?; - - let relayer = RelayerDriver { - config_path, - config, - registry, - hang_on_fail: self.test_config.hang_on_fail, - }; - - let chains = ConnectedChains::new( - handle_a, - handle_b, - MonoTagged::new(self.node_a), - MonoTagged::new(self.node_b), - foreign_clients, - ); - - Ok((relayer, chains)) - } -} +/// Bootstraps two relayer chain handles with connected foreign clients. +/// +/// Returns a tuple consisting of the [`RelayerDriver`] and a +/// [`ConnectedChains`] object that contains the given +/// full nodes together with the corresponding two [`ChainHandle`]s and +/// [`ForeignClient`]s. +pub fn bootstrap_chains_with_full_nodes( + test_config: &TestConfig, + node_a: FullNode, + node_b: FullNode, + options: BootstrapClientOptions, + config_modifier: impl FnOnce(&mut Config), +) -> Result< + ( + RelayerDriver, + ConnectedChains, + ), + Error, +> { + let mut config = Config::default(); -pub fn pad_client_ids( - chain_a: &ChainA, - chain_b: &ChainB, -) -> Result<(), Error> { - let foreign_client = - ForeignClient::restore(ClientId::default(), chain_b.clone(), chain_a.clone()); + add_chain_config(&mut config, &node_a)?; + add_chain_config(&mut config, &node_b)?; - for i in 0..random_u64_range(1, 6) { - debug!("creating new client id {} on chain {}", i + 1, chain_b.id()); - foreign_client.build_create_client_and_send(Default::default())?; - } + config_modifier(&mut config); - Ok(()) -} + let config_path = test_config.chain_store_dir.join("relayer-config.toml"); -pub struct ForeignClientBuilder<'a, ChainA: ChainHandle, ChainB: ChainHandle> { - chain_a: &'a ChainA, - chain_b: &'a ChainB, - client_options: ClientOptions, -} + save_relayer_config(&config, &config_path)?; -pub struct ForeignClientPairBuilder<'a, ChainA: ChainHandle, ChainB: ChainHandle> { - a_to_b: ForeignClientBuilder<'a, ChainA, ChainB>, - b_to_a_client_options: ClientOptions, -} + let registry = new_registry(config.clone()); -impl<'a, ChainA: ChainHandle, ChainB: ChainHandle> ForeignClientBuilder<'a, ChainA, ChainB> { - pub fn new(chain_a: &'a ChainA, chain_b: &'a ChainB) -> Self { - Self { - chain_a, - chain_b, - client_options: Default::default(), - } - } + // Pass in unique closure expressions `||{}` as the first argument so that + // the returned chains are considered different types by Rust. + // See [`spawn_chain_handle`] for more details. + let handle_a = spawn_chain_handle(|| {}, ®istry, &node_a)?; + let handle_b = spawn_chain_handle(|| {}, ®istry, &node_b)?; - pub fn client_options(mut self, settings: ClientOptions) -> Self { - self.client_options = settings; - self + if test_config.bootstrap_with_random_ids { + pad_client_ids(&handle_a, &handle_b)?; + pad_client_ids(&handle_b, &handle_a)?; } - /// Bootstrap a foreign client from `ChainA` to `ChainB`, i.e. the foreign - /// client collects information from `ChainA` and submits them as transactions - /// to `ChainB`. - /// - /// The returned `ForeignClient` is tagged in contravariant ordering, i.e. - /// `ChainB` then `ChainB`, because `ForeignClient` takes the the destination - /// chain in the first position. - pub fn bootstrap(self) -> Result, Error> { - bootstrap_foreign_client(self.chain_a, self.chain_b, self.client_options) - } + let foreign_clients = bootstrap_foreign_client_pair(&handle_a, &handle_b, options)?; + + let relayer = RelayerDriver { + config_path, + config, + registry, + hang_on_fail: test_config.hang_on_fail, + }; + + let chains = ConnectedChains::new( + handle_a, + handle_b, + MonoTagged::new(node_a), + MonoTagged::new(node_b), + foreign_clients, + ); - /// Continues the builder composition for a pair of clients in both directions. - pub fn pair(self) -> ForeignClientPairBuilder<'a, ChainA, ChainB> { - ForeignClientPairBuilder { - a_to_b: self, - b_to_a_client_options: Default::default(), - } - } + Ok((relayer, chains)) } -impl<'a, ChainA: ChainHandle, ChainB: ChainHandle> ForeignClientPairBuilder<'a, ChainA, ChainB> { - /// Overrides the settings for a client in the reverse direction (B to A). - pub fn client_options(mut self, settings: ClientOptions) -> Self { - self.b_to_a_client_options = settings; - self - } - - pub fn bootstrap(self) -> Result, Error> { - let chain_a = self.a_to_b.chain_a; - let chain_b = self.a_to_b.chain_b; - let client_a_to_b = bootstrap_foreign_client(chain_a, chain_b, self.a_to_b.client_options)?; - let client_b_to_a = bootstrap_foreign_client(chain_b, chain_a, self.b_to_a_client_options)?; - Ok(ForeignClientPair::new(client_a_to_b, client_b_to_a)) - } +/// Bootstraps two relayer chain handles with connected foreign clients. +/// +/// Returns a tuple consisting of the [`RelayerDriver`] and a +/// [`ConnectedChains`] object that contains the given +/// full nodes together with the corresponding two [`ChainHandle`]s and +/// [`ForeignClient`]s. +/// +/// This method gives the caller a way to modify the relayer configuration +/// that is pre-generated from the configurations of the full nodes. +pub fn bootstrap_foreign_client_pair( + chain_a: &ChainA, + chain_b: &ChainB, + options: BootstrapClientOptions, +) -> Result, Error> { + let client_a_to_b = bootstrap_foreign_client(chain_a, chain_b, options.client_options_a_to_b)?; + let client_b_to_a = bootstrap_foreign_client(chain_b, chain_a, options.client_options_b_to_a)?; + Ok(ForeignClientPair::new(client_a_to_b, client_b_to_a)) } -fn bootstrap_foreign_client( +pub fn bootstrap_foreign_client( chain_a: &ChainA, chain_b: &ChainB, client_options: ClientOptions, @@ -268,6 +140,21 @@ fn bootstrap_foreign_client( )) } +pub fn pad_client_ids( + chain_a: &ChainA, + chain_b: &ChainB, +) -> Result<(), Error> { + let foreign_client = + ForeignClient::restore(ClientId::default(), chain_b.clone(), chain_a.clone()); + + for i in 0..random_u64_range(1, 6) { + debug!("creating new client id {} on chain {}", i + 1, chain_b.id()); + foreign_client.build_create_client_and_send(Default::default())?; + } + + Ok(()) +} + /** Spawn a new chain handle using the given [`SharedRegistry`] and [`FullNode`]. @@ -385,3 +272,17 @@ pub fn save_relayer_config(config: &Config, config_path: &Path) -> Result<(), Er Ok(()) } + +impl BootstrapClientOptions { + /// Overrides options for the foreign client connecting chain A to chain B. + pub fn client_options_a_to_b(mut self, options: ClientOptions) -> Self { + self.client_options_a_to_b = options; + self + } + + /// Overrides options for the foreign client connecting chain B to chain A. + pub fn client_options_b_to_a(mut self, options: ClientOptions) -> Self { + self.client_options_b_to_a = options; + self + } +} diff --git a/tools/test-framework/src/bootstrap/binary/channel.rs b/tools/test-framework/src/bootstrap/binary/channel.rs index 6399c5852f..0a8b46b4bb 100644 --- a/tools/test-framework/src/bootstrap/binary/channel.rs +++ b/tools/test-framework/src/bootstrap/binary/channel.rs @@ -2,7 +2,6 @@ Helper functions for bootstrapping a channel between two chains. */ -use core::time::Duration; use eyre::{eyre, Report as Error}; use ibc::core::ics04_channel::channel::Order; use ibc::core::ics04_channel::Version; @@ -11,7 +10,7 @@ use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::channel::{Channel, ChannelSide}; use tracing::{debug, info}; -use super::connection::bootstrap_connection; +use super::connection::{bootstrap_connection, BootstrapConnectionOptions}; use crate::types::binary::chains::ConnectedChains; use crate::types::binary::channel::ConnectedChannel; use crate::types::binary::connection::ConnectedConnection; @@ -20,6 +19,12 @@ use crate::types::id::TaggedPortIdRef; use crate::types::tagged::*; use crate::util::random::random_u64_range; +pub struct BootstrapChannelOptions { + pub order: Order, + pub version: Version, + pub bootstrap_with_random_ids: bool, +} + /** Create a new [`ConnectedChannel`] based on the provided [`ConnectedChains`]. @@ -30,19 +35,15 @@ pub fn bootstrap_channel_with_chains( chains: &ConnectedChains, port_a: &PortId, port_b: &PortId, - order: Order, - version: Version, - connection_delay: Duration, - bootstrap_with_random_ids: bool, + connection_options: BootstrapConnectionOptions, + channel_options: BootstrapChannelOptions, ) -> Result, Error> { let channel = bootstrap_channel( &chains.foreign_clients, &DualTagged::new(port_a), &DualTagged::new(port_b), - order, - version, - connection_delay, - bootstrap_with_random_ids, + connection_options, + channel_options, )?; Ok(channel) @@ -56,13 +57,10 @@ pub fn bootstrap_channel( foreign_clients: &ForeignClientPair, port_a: &TaggedPortIdRef, port_b: &TaggedPortIdRef, - order: Order, - version: Version, - connection_delay: Duration, - bootstrap_with_random_ids: bool, + connection_options: BootstrapConnectionOptions, + channel_options: BootstrapChannelOptions, ) -> Result, Error> { - let connection = - bootstrap_connection(foreign_clients, connection_delay, bootstrap_with_random_ids)?; + let connection = bootstrap_connection(foreign_clients, connection_options)?; bootstrap_channel_with_connection( &foreign_clients.handle_a(), @@ -70,9 +68,7 @@ pub fn bootstrap_channel( connection, port_a, port_b, - order, - version, - bootstrap_with_random_ids, + channel_options, ) } @@ -85,21 +81,19 @@ pub fn bootstrap_channel_with_connection, port_a: &TaggedPortIdRef, port_b: &TaggedPortIdRef, - order: Order, - version: Version, - bootstrap_with_random_ids: bool, + options: BootstrapChannelOptions, ) -> Result, Error> { - if bootstrap_with_random_ids { + if options.bootstrap_with_random_ids { pad_channel_id(chain_a, chain_b, &connection, port_a)?; pad_channel_id(chain_b, chain_a, &connection.clone().flip(), port_b)?; } let channel = Channel::new( connection.connection.clone(), - order, + options.order, port_a.0.clone(), port_b.0.clone(), - Some(version), + Some(options.version), )?; let channel_id_a = *channel @@ -188,3 +182,30 @@ pub fn pad_channel_id( Ok(()) } + +impl Default for BootstrapChannelOptions { + fn default() -> Self { + Self { + order: Order::Unordered, + version: Version::ics20(), + bootstrap_with_random_ids: false, + } + } +} + +impl BootstrapChannelOptions { + pub fn order(mut self, order: Order) -> Self { + self.order = order; + self + } + + pub fn version(mut self, version: Version) -> Self { + self.version = version; + self + } + + pub fn bootstrap_with_random_ids(mut self, bootstrap_with_random_ids: bool) -> Self { + self.bootstrap_with_random_ids = bootstrap_with_random_ids; + self + } +} diff --git a/tools/test-framework/src/bootstrap/binary/connection.rs b/tools/test-framework/src/bootstrap/binary/connection.rs index 858ce1bb73..942c1b068b 100644 --- a/tools/test-framework/src/bootstrap/binary/connection.rs +++ b/tools/test-framework/src/bootstrap/binary/connection.rs @@ -6,6 +6,7 @@ use core::time::Duration; use eyre::{eyre, Report as Error}; use ibc::timestamp::ZERO_DURATION; use ibc_relayer::chain::handle::ChainHandle; +use ibc_relayer::config::default::connection_delay as default_connection_delay; use ibc_relayer::connection::{Connection, ConnectionSide}; use tracing::{debug, info}; @@ -16,14 +17,18 @@ use crate::types::binary::foreign_client::ForeignClientPair; use crate::types::id::TaggedClientIdRef; use crate::util::random::random_u64_range; +pub struct BootstrapConnectionOptions { + pub connection_delay: Duration, + pub bootstrap_with_random_ids: bool, +} + /** Create a new [`ConnectedConnection`] using the foreign clients with initialized client IDs. */ pub fn bootstrap_connection( foreign_clients: &ForeignClientPair, - connection_delay: Duration, - bootstrap_with_random_ids: bool, + options: BootstrapConnectionOptions, ) -> Result, Error> { let chain_a = foreign_clients.handle_a(); let chain_b = foreign_clients.handle_b(); @@ -31,7 +36,7 @@ pub fn bootstrap_connection( let client_id_a = foreign_clients.client_id_a(); let client_id_b = foreign_clients.client_id_b(); - if bootstrap_with_random_ids { + if options.bootstrap_with_random_ids { pad_connection_id(&chain_a, &chain_b, &client_id_a, &client_id_b)?; pad_connection_id(&chain_b, &chain_a, &client_id_b, &client_id_a)?; } @@ -39,7 +44,7 @@ pub fn bootstrap_connection( let connection = Connection::new( foreign_clients.client_b_to_a.clone(), foreign_clients.client_a_to_b.clone(), - connection_delay, + options.connection_delay, )?; let connection_id_a = connection @@ -104,3 +109,24 @@ pub fn pad_connection_id( Ok(()) } + +impl Default for BootstrapConnectionOptions { + fn default() -> Self { + Self { + connection_delay: default_connection_delay(), + bootstrap_with_random_ids: false, + } + } +} + +impl BootstrapConnectionOptions { + pub fn connection_delay(mut self, connection_delay: Duration) -> Self { + self.connection_delay = connection_delay; + self + } + + pub fn bootstrap_with_random_ids(mut self, bootstrap_with_random_ids: bool) -> Self { + self.bootstrap_with_random_ids = bootstrap_with_random_ids; + self + } +} diff --git a/tools/test-framework/src/bootstrap/nary/chain.rs b/tools/test-framework/src/bootstrap/nary/chain.rs index 5b001ae319..30b2188266 100644 --- a/tools/test-framework/src/bootstrap/nary/chain.rs +++ b/tools/test-framework/src/bootstrap/nary/chain.rs @@ -9,8 +9,8 @@ use ibc_relayer::foreign_client::ForeignClient; use ibc_relayer::registry::SharedRegistry; use crate::bootstrap::binary::chain::{ - add_chain_config, add_keys_to_chain_handle, new_registry, save_relayer_config, - ForeignClientBuilder, + add_chain_config, add_keys_to_chain_handle, bootstrap_foreign_client, new_registry, + save_relayer_config, }; use crate::error::{handle_generic_error, Error}; use crate::relayer::driver::RelayerDriver; @@ -84,7 +84,8 @@ pub fn boostrap_chains_with_any_nodes( let mut foreign_clients_b = Vec::new(); for handle_b in chain_handles.iter() { - let foreign_client = ForeignClientBuilder::new(handle_a, handle_b).bootstrap()?; + let foreign_client = bootstrap_foreign_client(handle_a, handle_b, Default::default())?; + foreign_clients_b.push(foreign_client); } diff --git a/tools/test-framework/src/bootstrap/nary/channel.rs b/tools/test-framework/src/bootstrap/nary/channel.rs index ac3a58e36e..ff04920983 100644 --- a/tools/test-framework/src/bootstrap/nary/channel.rs +++ b/tools/test-framework/src/bootstrap/nary/channel.rs @@ -5,11 +5,12 @@ use core::convert::TryInto; use core::time::Duration; use ibc::core::ics04_channel::channel::Order; -use ibc::core::ics04_channel::Version; use ibc::core::ics24_host::identifier::PortId; use ibc_relayer::chain::handle::ChainHandle; -use crate::bootstrap::binary::channel::bootstrap_channel_with_connection; +use crate::bootstrap::binary::channel::{ + bootstrap_channel_with_connection, BootstrapChannelOptions, +}; use crate::bootstrap::nary::connection::bootstrap_connections_dynamic; use crate::error::{handle_generic_error, Error}; use crate::types::binary::channel::ConnectedChannel; @@ -48,15 +49,17 @@ pub fn bootstrap_channels_with_connections_dynamic( let port_a = &ports[i][j]; let port_b = &ports[j][i]; + let bootstrap_options = BootstrapChannelOptions::default() + .order(order) + .bootstrap_with_random_ids(bootstrap_with_random_ids); + let channel = bootstrap_channel_with_connection( chain_a, chain_b, connection.clone(), &DualTagged::new(port_a), &DualTagged::new(port_b), - order, - Version::ics20(), - bootstrap_with_random_ids, + bootstrap_options, )?; channels_b.push(channel); diff --git a/tools/test-framework/src/bootstrap/nary/connection.rs b/tools/test-framework/src/bootstrap/nary/connection.rs index 78390afee5..932f9fc9be 100644 --- a/tools/test-framework/src/bootstrap/nary/connection.rs +++ b/tools/test-framework/src/bootstrap/nary/connection.rs @@ -7,7 +7,7 @@ use core::time::Duration; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::foreign_client::ForeignClient; -use crate::bootstrap::binary::connection::bootstrap_connection; +use crate::bootstrap::binary::connection::{bootstrap_connection, BootstrapConnectionOptions}; use crate::error::Error; use crate::types::binary::connection::ConnectedConnection; use crate::types::binary::foreign_client::ForeignClientPair; @@ -39,11 +39,11 @@ pub fn bootstrap_connections_dynamic( let foreign_clients = ForeignClientPair::new(foreign_client.clone(), counter_foreign_client.clone()); - let connection = bootstrap_connection( - &foreign_clients, - connection_delay, - bootstrap_with_random_ids, - )?; + let bootstrap_options = BootstrapConnectionOptions::default() + .connection_delay(connection_delay) + .bootstrap_with_random_ids(bootstrap_with_random_ids); + + let connection = bootstrap_connection(&foreign_clients, bootstrap_options)?; connections_b.push(connection); } else { diff --git a/tools/test-framework/src/framework/binary/chain.rs b/tools/test-framework/src/framework/binary/chain.rs index 9f299f0061..4a342a2c7f 100644 --- a/tools/test-framework/src/framework/binary/chain.rs +++ b/tools/test-framework/src/framework/binary/chain.rs @@ -8,7 +8,7 @@ use ibc_relayer::config::Config; use ibc_relayer::foreign_client::CreateOptions as ClientOptions; use tracing::info; -use crate::bootstrap::binary::chain::Builder; +use crate::bootstrap::binary::chain::{bootstrap_chains_with_full_nodes, BootstrapClientOptions}; use crate::error::Error; use crate::framework::base::{HasOverrides, TestConfigOverride}; use crate::framework::binary::node::{ @@ -203,12 +203,20 @@ where { fn run(&self, config: &TestConfig, node_a: FullNode, node_b: FullNode) -> Result<(), Error> { let overrides = self.test.get_overrides(); - let (relayer, chains) = Builder::with_node_pair(config, node_a, node_b) + + let bootstrap_options = BootstrapClientOptions::default() .client_options_a_to_b(overrides.client_options_a_to_b()) - .client_options_b_to_a(overrides.client_options_b_to_a()) - .bootstrap_with_config(|config| { + .client_options_b_to_a(overrides.client_options_b_to_a()); + + let (relayer, chains) = bootstrap_chains_with_full_nodes( + config, + node_a, + node_b, + bootstrap_options, + |config| { overrides.modify_relayer_config(config); - })?; + }, + )?; let env_path = config.chain_store_dir.join("binary-chains.env"); diff --git a/tools/test-framework/src/framework/binary/channel.rs b/tools/test-framework/src/framework/binary/channel.rs index 01f32b26ac..e25822c785 100644 --- a/tools/test-framework/src/framework/binary/channel.rs +++ b/tools/test-framework/src/framework/binary/channel.rs @@ -10,7 +10,9 @@ use ibc::core::ics24_host::identifier::PortId; use ibc_relayer::chain::handle::ChainHandle; use tracing::info; -use crate::bootstrap::binary::channel::bootstrap_channel_with_connection; +use crate::bootstrap::binary::channel::{ + bootstrap_channel_with_connection, BootstrapChannelOptions, +}; use crate::error::Error; use crate::framework::base::{HasOverrides, TestConfigOverride}; use crate::framework::binary::chain::{ @@ -196,8 +198,11 @@ where let port_a = overrides.channel_port_a(); let port_b = overrides.channel_port_b(); - let order = overrides.channel_order(); - let version = overrides.channel_version(); + + let bootstrap_options = BootstrapChannelOptions::default() + .order(overrides.channel_order()) + .version(overrides.channel_version()) + .bootstrap_with_random_ids(config.bootstrap_with_random_ids); let channels = bootstrap_channel_with_connection( &chains.handle_a, @@ -205,9 +210,7 @@ where connection, &DualTagged::new(port_a).as_ref(), &DualTagged::new(port_b).as_ref(), - order, - version, - config.bootstrap_with_random_ids, + bootstrap_options, )?; let env_path = config.chain_store_dir.join("binary-channels.env"); diff --git a/tools/test-framework/src/framework/binary/connection.rs b/tools/test-framework/src/framework/binary/connection.rs index 5534926f38..9e96a7665e 100644 --- a/tools/test-framework/src/framework/binary/connection.rs +++ b/tools/test-framework/src/framework/binary/connection.rs @@ -8,7 +8,7 @@ use core::time::Duration; use ibc_relayer::chain::handle::ChainHandle; use tracing::info; -use crate::bootstrap::binary::connection::bootstrap_connection; +use crate::bootstrap::binary::connection::{bootstrap_connection, BootstrapConnectionOptions}; use crate::error::Error; use crate::framework::base::HasOverrides; use crate::framework::base::TestConfigOverride; @@ -154,13 +154,11 @@ where relayer: RelayerDriver, chains: ConnectedChains, ) -> Result<(), Error> { - let connection_delay = self.get_overrides().connection_delay(); + let bootstrap_options = BootstrapConnectionOptions::default() + .connection_delay(self.get_overrides().connection_delay()) + .bootstrap_with_random_ids(config.bootstrap_with_random_ids); - let connection = bootstrap_connection( - &chains.foreign_clients, - connection_delay, - config.bootstrap_with_random_ids, - )?; + let connection = bootstrap_connection(&chains.foreign_clients, bootstrap_options)?; let env_path = config.chain_store_dir.join("binary-connections.env");