diff --git a/src/bitcoin.rs b/src/bitcoin.rs index f41953c..dea6065 100644 --- a/src/bitcoin.rs +++ b/src/bitcoin.rs @@ -198,8 +198,8 @@ impl NodeT for BitcoinNode { async fn spawn(config: &Self::Config, docker: &Arc>) -> Result { match docker.as_ref() { - Some(docker) => docker.spawn(config.into()).await, - None => Self::spawn(config), + Some(docker) if docker.bitcoin() => docker.spawn(config.into()).await, + _ => Self::spawn(config), } } diff --git a/src/config/docker.rs b/src/config/docker.rs index 93dfa82..22814a3 100644 --- a/src/config/docker.rs +++ b/src/config/docker.rs @@ -75,12 +75,10 @@ where ports: vec![config.rollup.rpc.bind_port], image: config.docker_image.clone().unwrap_or_else(|| { let base_img = DEFAULT_CITREA_DOCKER_IMAGE; - let img = match std::env::var("SHORT_PREFIX") { + match std::env::var("SHORT_PREFIX") { Ok(v) if v == "1" || v == "true" => format!("{base_img}-short-prefix"), _ => base_img.to_string(), - }; - println!("img : {:?}", img); - img + } }), cmd: args, log_path: config.dir.join("stdout.log"), diff --git a/src/docker.rs b/src/docker.rs index 9da4d78..06a991f 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -18,7 +18,7 @@ use futures::StreamExt; use tokio::{fs::File, io::AsyncWriteExt, sync::Mutex, task::JoinHandle}; use tracing::{debug, error, info}; -use crate::node::NodeKind; +use crate::{config::TestCaseDockerConfig, node::NodeKind}; use super::{config::DockerConfig, traits::SpawnOutput, utils::generate_test_id}; @@ -40,10 +40,11 @@ pub struct DockerEnv { id: String, volumes: Mutex>, container_ids: Mutex>, + test_case_config: TestCaseDockerConfig, } impl DockerEnv { - pub async fn new() -> Result { + pub async fn new(test_case_config: TestCaseDockerConfig) -> Result { let docker = Docker::connect_with_local_defaults().context("Failed to connect to Docker")?; let test_id = generate_test_id(); @@ -55,6 +56,7 @@ impl DockerEnv { id: test_id, volumes: Mutex::new(HashSet::new()), container_ids: Mutex::new(HashSet::new()), + test_case_config, }) } @@ -339,4 +341,14 @@ impl DockerEnv { Ok(()) } + + // Should run bitcoin in docker + pub fn bitcoin(&self) -> bool { + self.test_case_config.bitcoin + } + + // Should run citrea in docker + pub fn citrea(&self) -> bool { + self.test_case_config.citrea + } } diff --git a/src/framework.rs b/src/framework.rs index 64fc881..cc16d4e 100644 --- a/src/framework.rs +++ b/src/framework.rs @@ -72,7 +72,7 @@ impl TestFramework { let test_case = T::test_config(); let docker = if test_case.docker.enabled() { - Some(DockerEnv::new().await?) + Some(DockerEnv::new(test_case.docker.clone()).await?) } else { None }; @@ -285,21 +285,21 @@ impl TestFramework { }); } - if let Some(docker) = docker.as_ref() { - bitcoin_confs[0].docker_host = Some(docker.get_hostname(&NodeKind::Bitcoin)); - } + bitcoin_confs[0].docker_host = docker + .as_ref() + .and_then(|d| d.citrea().then(|| d.get_hostname(&NodeKind::Bitcoin))); // Target first bitcoin node as DA for now let da_config: BitcoinServiceConfig = bitcoin_confs[0].clone().into(); let runner_bind_host = match docker.as_ref() { - Some(d) => d.get_hostname(&NodeKind::Sequencer), - None => sequencer_rollup.rpc.bind_host.clone(), + Some(d) if d.citrea() => d.get_hostname(&NodeKind::Sequencer), + _ => sequencer_rollup.rpc.bind_host.clone(), }; let bind_host = match docker.as_ref() { - Some(_) => "0.0.0.0".to_string(), - None => sequencer_rollup.rpc.bind_host.clone(), + Some(d) if d.citrea() => "0.0.0.0".to_string(), + _ => sequencer_rollup.rpc.bind_host.clone(), }; let sequencer_rollup = { diff --git a/src/node.rs b/src/node.rs index d89236a..5abc49b 100644 --- a/src/node.rs +++ b/src/node.rs @@ -164,8 +164,8 @@ where async fn spawn(config: &Self::Config, docker: &Arc>) -> Result { match docker.as_ref() { - Some(docker) => docker.spawn(config.to_owned().into()).await, - None => Self::spawn(config), + Some(docker) if docker.citrea() => docker.spawn(config.to_owned().into()).await, + _ => Self::spawn(config), } }