Skip to content

Commit d075341

Browse files
Add tests/signer/commands/context.rs
Co-authored-by: Nikos Baxevanis <[email protected]>
1 parent a080ceb commit d075341

File tree

1 file changed

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

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
use crate::tests::signer::v0::MultipleMinerTest;
2+
use madhouse::{State, TestContext};
3+
use std::fmt::Debug;
4+
use std::sync::{Arc, Mutex};
5+
use std::time::Duration;
6+
7+
pub struct SignerTestContext {
8+
pub miners: Arc<Mutex<MultipleMinerTest>>,
9+
}
10+
11+
impl Debug for SignerTestContext {
12+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13+
f.debug_struct("SignerTestContext").finish()
14+
}
15+
}
16+
17+
impl Clone for SignerTestContext {
18+
fn clone(&self) -> Self {
19+
Self {
20+
miners: self.miners.clone(),
21+
}
22+
}
23+
}
24+
25+
impl TestContext for SignerTestContext {}
26+
27+
impl SignerTestContext {
28+
pub fn new(num_signers: usize, num_transfer_txs: u64) -> Self {
29+
let miners = MultipleMinerTest::new_with_config_modifications(
30+
num_signers,
31+
num_transfer_txs,
32+
|signer_config| {
33+
signer_config.block_proposal_validation_timeout = Duration::from_secs(1800);
34+
signer_config.tenure_last_block_proposal_timeout = Duration::from_secs(1800);
35+
signer_config.first_proposal_burn_block_timing = Duration::from_secs(1800);
36+
},
37+
|config| {
38+
config.miner.block_commit_delay = Duration::from_secs(0);
39+
},
40+
|config| {
41+
config.miner.block_commit_delay = Duration::from_secs(0);
42+
},
43+
);
44+
45+
Self {
46+
miners: Arc::new(Mutex::new(miners)),
47+
}
48+
}
49+
}
50+
51+
#[derive(Debug, Default)]
52+
pub struct SignerTestState {
53+
pub is_booted_to_nakamoto: bool,
54+
pub is_primary_miner_skip_commit_op: bool,
55+
pub is_secondary_miner_skip_commit_op: bool,
56+
pub mining_stalled: bool,
57+
}
58+
59+
impl State for SignerTestState {}

0 commit comments

Comments
 (0)