Skip to content

Commit ac99ec9

Browse files
committed
test: add a test with 2 miners, one of whom tries to fork the other and is prevented by the signer set
1 parent d651825 commit ac99ec9

File tree

3 files changed

+340
-4
lines changed

3 files changed

+340
-4
lines changed

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,21 @@ where
625625
Ok(())
626626
}
627627

628+
pub fn wait_for<F>(timeout_secs: u64, mut check: F) -> Result<(), String>
629+
where
630+
F: FnMut() -> Result<bool, String>,
631+
{
632+
let start = Instant::now();
633+
while !check()? {
634+
if start.elapsed() > Duration::from_secs(timeout_secs) {
635+
error!("Timed out waiting for check to process");
636+
return Err("Timed out".into());
637+
}
638+
thread::sleep(Duration::from_millis(100));
639+
}
640+
Ok(())
641+
}
642+
628643
/// Mine a bitcoin block, and wait until:
629644
/// (1) a new block has been processed by the coordinator
630645
pub fn next_block_and_process_new_stacks_block(

testnet/stacks-node/src/tests/signer/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ pub struct SignerTest<S> {
9292
pub running_nodes: RunningNodes,
9393
// The spawned signers and their threads
9494
pub spawned_signers: Vec<S>,
95+
// The spawned signers and their threads
96+
pub signer_configs: Vec<SignerConfig>,
9597
// the private keys of the signers
9698
pub signer_stacks_private_keys: Vec<StacksPrivateKey>,
9799
// link to the stacks node
@@ -209,6 +211,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
209211
signer_stacks_private_keys,
210212
stacks_client,
211213
run_stamp,
214+
signer_configs,
212215
}
213216
}
214217

0 commit comments

Comments
 (0)