From dc153542610fbda93cc532cdbf063dba7b251bc0 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 28 Nov 2024 19:37:24 +1100 Subject: [PATCH] add support for `--no-mine` with era-test-node --- src/node_bindings/era_test_node.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/node_bindings/era_test_node.rs b/src/node_bindings/era_test_node.rs index 19e6f81..14e34f4 100644 --- a/src/node_bindings/era_test_node.rs +++ b/src/node_bindings/era_test_node.rs @@ -152,6 +152,7 @@ pub struct EraTestNode { // // If the block_time is an integer, f64::to_string() will output without a decimal point // // which allows this to be backwards compatible. // block_time: Option, + no_mine: bool, chain_id: Option, // TODO // mnemonic: Option, @@ -234,6 +235,12 @@ impl EraTestNode { // self // } + /// Sets the no-mine status which will be used when the `era_test_node` instance is launched. + pub const fn no_mine(mut self) -> Self { + self.no_mine = true; + self + } + // TODO // /// Sets the block-time in sub-seconds which will be used when the `era_test_node` instance is launched. // /// Older versions of `era_test_node` do not support sub-second block times. @@ -319,6 +326,10 @@ impl EraTestNode { // cmd.arg("-b").arg(block_time.to_string()); // } + if self.no_mine { + cmd.arg("--no-mine"); + } + cmd.args(self.args); if let Some(fork) = self.fork { @@ -444,6 +455,11 @@ mod tests { // let _ = era_test_node.spawn(); // } + #[test] + fn can_launch_era_test_node_with_no_mine() { + let _ = EraTestNode::new().no_mine().spawn(); + } + // #[test] // fn can_launch_era_test_node_with_sub_seconds_block_time() { // let _ = EraTestNode::new().block_time_f64(0.5).spawn();