Skip to content

Commit 7a08605

Browse files
committed
Accept extra_args on node restart
1 parent af85eae commit 7a08605

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

src/bitcoin.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
time::{Duration, Instant},
88
};
99

10-
use anyhow::{anyhow, bail, Context};
10+
use anyhow::{bail, Context};
1111
use async_trait::async_trait;
1212
use bitcoin::Address;
1313
use bitcoincore_rpc::{json::AddressType::Bech32m, Auth, Client, RpcApi};
@@ -283,7 +283,11 @@ impl Restart for BitcoinNode {
283283
}
284284
}
285285

286-
async fn start(&mut self, config: Option<Self::Config>) -> Result<()> {
286+
async fn start(
287+
&mut self,
288+
config: Option<Self::Config>,
289+
_extra_args: Option<Vec<String>>,
290+
) -> Result<()> {
287291
if let Some(config) = config {
288292
self.config = config;
289293
}

src/config/test_case.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::{env, path::PathBuf, time::Duration};
22

33
use tempfile::TempDir;
44

5-
use crate::utils::generate_test_id;
6-
75
use super::CitreaMode;
6+
use crate::utils::generate_test_id;
87

98
#[derive(Clone, Default)]
109
pub struct TestCaseEnv {

src/node.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ where
125125
})
126126
}
127127

128-
fn spawn(config: &C) -> Result<SpawnOutput> {
128+
fn spawn(config: &C, extra_args: Option<Vec<String>>) -> Result<SpawnOutput> {
129129
let citrea = get_citrea_path()?;
130130

131131
let kind = C::node_kind();
@@ -145,6 +145,7 @@ where
145145

146146
Command::new(citrea)
147147
.args(get_citrea_args(config))
148+
.args(extra_args.unwrap_or_default())
148149
.envs(config.env())
149150
.stdout(Stdio::from(stdout_file))
150151
.stderr(Stdio::from(stderr_file))
@@ -191,7 +192,7 @@ where
191192
async fn spawn(config: &Self::Config, docker: &Arc<Option<DockerEnv>>) -> Result<SpawnOutput> {
192193
match docker.as_ref() {
193194
Some(docker) if docker.citrea() => docker.spawn(config.to_owned().into()).await,
194-
_ => Self::spawn(config),
195+
_ => Self::spawn(config, None),
195196
}
196197
}
197198

@@ -251,7 +252,11 @@ where
251252
Ok(())
252253
}
253254

254-
async fn start(&mut self, new_config: Option<Self::Config>) -> Result<()> {
255+
async fn start(
256+
&mut self,
257+
new_config: Option<Self::Config>,
258+
extra_args: Option<Vec<String>>,
259+
) -> Result<()> {
255260
let config = self.config_mut();
256261

257262
if let Some(new_config) = new_config {
@@ -272,7 +277,7 @@ where
272277
copy_directory(old_dir, &new_dir)?;
273278
config.set_dir(new_dir);
274279

275-
*self.spawn_output() = Self::spawn(config)?;
280+
*self.spawn_output() = Self::spawn(config, extra_args)?;
276281
self.wait_for_ready(None).await
277282
}
278283
}

src/traits.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,19 @@ pub trait NodeT: Send {
6868
#[async_trait]
6969
pub trait Restart: NodeT + Send {
7070
async fn wait_until_stopped(&mut self) -> Result<()>;
71-
async fn start(&mut self, new_config: Option<Self::Config>) -> Result<()>;
71+
async fn start(
72+
&mut self,
73+
new_config: Option<Self::Config>,
74+
extra_args: Option<Vec<String>>,
75+
) -> Result<()>;
7276

7377
// Default implementation to support waiting for node to be fully shutdown and brough back up with new config.
74-
async fn restart(&mut self, new_config: Option<Self::Config>) -> Result<()> {
78+
async fn restart(
79+
&mut self,
80+
new_config: Option<Self::Config>,
81+
extra_args: Option<Vec<String>>,
82+
) -> Result<()> {
7583
self.wait_until_stopped().await?;
76-
self.start(new_config).await
84+
self.start(new_config, extra_args).await
7785
}
7886
}

tests/bitcoin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl TestCase for RestartBitcoinTest {
108108
assert_eq!(info.txindex, None);
109109

110110
// Restart node with txindex
111-
da.restart(Some(new_conf)).await?;
111+
da.restart(Some(new_conf), None).await?;
112112

113113
let block_after = da.get_block_count().await?;
114114
let info = da.get_index_info().await?;

0 commit comments

Comments
 (0)