Skip to content

Commit 4588a1f

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

File tree

1 file changed

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

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
use super::context::{SignerTestContext, SignerTestState};
2+
use madhouse::{Command, CommandWrapper};
3+
use proptest::prelude::{Just, Strategy};
4+
use std::sync::Arc;
5+
6+
pub struct StallMiningCommand;
7+
8+
impl Command<SignerTestState, SignerTestContext> for StallMiningCommand {
9+
fn check(&self, state: &SignerTestState) -> bool {
10+
println!(
11+
"Checking: Stalling mining. Result: {:?}",
12+
!state.mining_stalled
13+
);
14+
!state.mining_stalled
15+
}
16+
17+
fn apply(&self, state: &mut SignerTestState) {
18+
println!("Applying: Stalling mining");
19+
crate::tests::signer::v0::test_mine_stall_set(true);
20+
state.mining_stalled = true;
21+
}
22+
23+
fn label(&self) -> String {
24+
"STALL_MINING".to_string()
25+
}
26+
27+
fn build(
28+
_ctx: Arc<SignerTestContext>,
29+
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
30+
Just(CommandWrapper::new(StallMiningCommand))
31+
}
32+
}
33+
34+
pub struct RecoverFromStallCommand;
35+
36+
impl Command<SignerTestState, SignerTestContext> for RecoverFromStallCommand {
37+
fn check(&self, state: &SignerTestState) -> bool {
38+
println!(
39+
"Checking: Recovering from mining stall. Result: {:?}",
40+
state.mining_stalled
41+
);
42+
state.mining_stalled
43+
}
44+
45+
fn apply(&self, state: &mut SignerTestState) {
46+
println!("Applying: Recovering from mining stall");
47+
crate::tests::signer::v0::test_mine_stall_set(false);
48+
state.mining_stalled = false;
49+
}
50+
51+
fn label(&self) -> String {
52+
"RECOVER_FROM_STALL".to_string()
53+
}
54+
55+
fn build(
56+
_ctx: Arc<SignerTestContext>,
57+
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
58+
Just(CommandWrapper::new(RecoverFromStallCommand))
59+
}
60+
}

0 commit comments

Comments
 (0)