From fe266528475e0aca27d74fc70dd063b65354ba8d Mon Sep 17 00:00:00 2001 From: David Boreham Date: Thu, 24 Jul 2025 19:47:53 -0600 Subject: [PATCH] Allow specification of the swarm directory by the caller --- .../smoke-test/src/smoke_test_environment.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/testsuite/smoke-test/src/smoke_test_environment.rs b/testsuite/smoke-test/src/smoke_test_environment.rs index a807b2dd4369..c9ef75f0df61 100644 --- a/testsuite/smoke-test/src/smoke_test_environment.rs +++ b/testsuite/smoke-test/src/smoke_test_environment.rs @@ -22,6 +22,7 @@ const SWARM_BUILD_NUM_RETRIES: u8 = 3; #[derive(Clone)] pub struct SwarmBuilder { local: bool, + swarm_dir: Option, num_validators: NonZeroUsize, num_fullnodes: usize, genesis_framework: Option, @@ -34,6 +35,7 @@ impl SwarmBuilder { pub fn new(local: bool, num_validators: usize) -> Self { Self { local, + swarm_dir: None, num_validators: NonZeroUsize::new(num_validators).unwrap(), num_fullnodes: 0, genesis_framework: None, @@ -84,19 +86,18 @@ impl SwarmBuilder { // TODO change to return Swarm trait // Add support for forge assert!(self.local); - static FACTORY: Lazy = - Lazy::new(|| LocalFactory::from_workspace(None).unwrap()); - let version = FACTORY.versions().max().unwrap(); + let factory = LocalFactory::from_workspace(self.swarm_dir.clone()).unwrap(); + let version = factory.versions().max().unwrap(); info!("Node finished compiling"); let slots = self.num_validators.get() * 2; - static ACTIVE_NODES: Lazy>> = Lazy::new(|| Arc::new(Mutex::new(0))); - let guard = ActiveNodesGuard::grab(slots, ACTIVE_NODES.clone()).await; + let active_nodes = Arc::new(Mutex::new(0)); + let guard = ActiveNodesGuard::grab(slots, active_nodes.clone()).await; let builder = self.clone(); let init_genesis_config = builder.init_genesis_config; - FACTORY + factory .new_swarm_with_version( OsRng, builder.num_validators, @@ -177,9 +178,10 @@ pub async fn new_local_swarm_with_diem(num_validators: usize) -> LocalSwarm { //////// 0L //////// // third party testsuites need to be able to start a swarm with // a pre-compiled move release bundle. -pub async fn new_local_swarm_with_release(num_validators: usize, release: ReleaseBundle) -> LocalSwarm { +pub async fn new_local_swarm_with_release(num_validators: usize, release: ReleaseBundle, swarm_dir: Option) -> LocalSwarm { let mut sw = SwarmBuilder { local: true, + swarm_dir, num_validators: NonZeroUsize::new(num_validators).unwrap(), num_fullnodes: 0, genesis_framework: Some(release),