Skip to content

Commit 14da4dc

Browse files
Add tests/signer/commands/shutdown.rs
Co-authored-by: Nikos Baxevanis <[email protected]>
1 parent 2b64f5d commit 14da4dc

File tree

1 file changed

+44
-0
lines changed
  • testnet/stacks-node/src/tests/signer/commands

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
use super::context::{SignerTestContext, SignerTestState};
2+
use crate::tests::signer::v0::MultipleMinerTest;
3+
use madhouse::{Command, CommandWrapper};
4+
use proptest::prelude::{Just, Strategy};
5+
use std::sync::{Arc, Mutex};
6+
7+
pub struct ShutdownMinersCommand {
8+
miners: Arc<Mutex<MultipleMinerTest>>,
9+
}
10+
11+
impl ShutdownMinersCommand {
12+
pub fn new(miners: Arc<Mutex<MultipleMinerTest>>) -> Self {
13+
Self { miners }
14+
}
15+
}
16+
17+
impl Command<SignerTestState, SignerTestContext> for ShutdownMinersCommand {
18+
fn check(&self, _state: &SignerTestState) -> bool {
19+
println!("Checking: Shutting down miners. Result: {:?}", true);
20+
true
21+
}
22+
23+
fn apply(&self, _state: &mut SignerTestState) {
24+
println!("Applying: Shutting down miners");
25+
26+
if let Ok(miners_arc) = Arc::try_unwrap(self.miners.clone()) {
27+
if let Ok(miners) = miners_arc.into_inner() {
28+
miners.shutdown();
29+
}
30+
}
31+
}
32+
33+
fn label(&self) -> String {
34+
"SHUTDOWN_MINERS".to_string()
35+
}
36+
37+
fn build(
38+
ctx: Arc<SignerTestContext>,
39+
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
40+
Just(CommandWrapper::new(ShutdownMinersCommand::new(
41+
ctx.miners.clone(),
42+
)))
43+
}
44+
}

0 commit comments

Comments
 (0)