diff --git a/crates/node/src/shell/testing/node.rs b/crates/node/src/shell/testing/node.rs index e8029b3d87e..3d6db6a0d19 100644 --- a/crates/node/src/shell/testing/node.rs +++ b/crates/node/src/shell/testing/node.rs @@ -246,19 +246,27 @@ pub enum NodeResults { Failed(ResultCode), } -// TODO: wrap `MockNode` in a single `Arc` -// FIXME: look at this todo, not sure it's correct though -#[derive(Clone)] -pub struct MockNode { - pub shell: Arc>>, - pub test_dir: Arc, - pub tx_result_codes: Arc>>, - pub tx_results: Arc>>>, - pub blocks: Arc>>, - pub services: Arc, +pub struct InnerMockNode { + pub shell: Mutex>, + pub test_dir: SalvageableTestDir, + pub tx_result_codes: Mutex>, + pub tx_results: Mutex>>, + pub blocks: Mutex>, + pub services: MockServices, pub auto_drive_services: bool, } +#[derive(Clone)] +pub struct MockNode(pub Arc); + +impl Deref for MockNode { + type Target = Arc; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + pub struct SalvageableTestDir { pub test_dir: ManuallyDrop, pub keep_temp: bool, diff --git a/crates/tests/src/integration/setup.rs b/crates/tests/src/integration/setup.rs index 187aa13c9c3..7490505a1dc 100644 --- a/crates/tests/src/integration/setup.rs +++ b/crates/tests/src/integration/setup.rs @@ -19,8 +19,8 @@ use namada_apps_lib::wallet::pre_genesis; use namada_core::chain::ChainIdPrefix; use namada_core::collections::HashMap; use namada_node::shell::testing::node::{ - mock_services, MockNode, MockServicesCfg, MockServicesController, - MockServicesPackage, SalvageableTestDir, + mock_services, InnerMockNode, MockNode, MockServicesCfg, + MockServicesController, MockServicesPackage, SalvageableTestDir, }; use namada_node::shell::testing::utils::TestDir; use namada_node::shell::Shell; @@ -202,8 +202,8 @@ fn create_node( shell_handlers, controller, } = mock_services(services_cfg); - let node = MockNode { - shell: Arc::new(Mutex::new(Shell::new( + let node = MockNode(Arc::new(InnerMockNode { + shell: Mutex::new(Shell::new( config::Ledger::new( global_args.base_dir, chain_id.clone(), @@ -218,17 +218,17 @@ fn create_node( None, 50 * 1024 * 1024, // 50 kiB 50 * 1024 * 1024, // 50 kiB - ))), - test_dir: Arc::new(SalvageableTestDir { + )), + test_dir: SalvageableTestDir { keep_temp, test_dir: ManuallyDrop::new(test_dir), - }), - services: Arc::new(services), - tx_result_codes: Arc::new(Mutex::new(vec![])), - tx_results: Arc::new(Mutex::new(vec![])), - blocks: Arc::new(Mutex::new(HashMap::new())), + }, + services, + tx_result_codes: Mutex::new(vec![]), + tx_results: Mutex::new(vec![]), + blocks: Mutex::new(HashMap::new()), auto_drive_services, - }; + })); let init_req = namada_apps_lib::tendermint::abci::request::InitChain { time: Timestamp {