Skip to content

Commit 48209a2

Browse files
committed
Move MineBitcoinBlock to commands/mining and remove tenure mod
1 parent f8d7404 commit 48209a2

File tree

3 files changed

+56
-63
lines changed

3 files changed

+56
-63
lines changed

testnet/stacks-node/src/tests/signer/commands/mining.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,58 @@ impl Command<SignerTestState, SignerTestContext>
151151
))
152152
}
153153
}
154+
155+
pub struct MineBitcoinBlock {
156+
miners: Arc<Mutex<MultipleMinerTest>>,
157+
timeout_secs: u64,
158+
}
159+
160+
impl MineBitcoinBlock {
161+
pub fn new(miners: Arc<Mutex<MultipleMinerTest>>, timeout_secs: u64) -> Self {
162+
Self {
163+
miners,
164+
timeout_secs,
165+
}
166+
}
167+
}
168+
169+
impl Command<SignerTestState, SignerTestContext> for MineBitcoinBlock {
170+
fn check(&self, _state: &SignerTestState) -> bool {
171+
info!("Checking: Mining tenure. Result: {:?}", true);
172+
true
173+
}
174+
175+
fn apply(&self, _state: &mut SignerTestState) {
176+
info!(
177+
"Applying: Mining tenure and waiting for it for {:?} seconds",
178+
self.timeout_secs
179+
);
180+
181+
let sortdb = {
182+
let miners = self.miners.lock().unwrap();
183+
let (conf_1, _) = miners.get_node_configs();
184+
let burnchain = conf_1.get_burnchain();
185+
let sortdb = burnchain.open_sortition_db(true).unwrap();
186+
sortdb
187+
};
188+
189+
{
190+
let mut miners = self.miners.lock().unwrap();
191+
miners
192+
.mine_bitcoin_blocks_and_confirm(&sortdb, 1, self.timeout_secs)
193+
.expect("Failed to mine BTC block");
194+
}
195+
}
196+
197+
fn label(&self) -> String {
198+
"MINE_BITCOIN_BLOCK".to_string()
199+
}
200+
201+
fn build(
202+
ctx: Arc<SignerTestContext>,
203+
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
204+
(60u64..90u64).prop_map(move |timeout_secs| {
205+
CommandWrapper::new(MineBitcoinBlock::new(ctx.miners.clone(), timeout_secs))
206+
})
207+
}
208+
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod commit_ops;
77
mod mining;
88
mod shutdown;
99
mod stalling;
10-
mod tenure;
1110
mod transfer;
1211

1312
pub use context::{SignerTestContext};
@@ -18,8 +17,7 @@ pub use block_commit::{
1817
pub use block_wait::{WaitForBlockFromMiner1, WaitForBlockFromMiner2};
1918
pub use boot::BootToEpoch3;
2019
pub use commit_ops::{SkipCommitOpPrimaryMiner, SkipCommitOpSecondaryMiner};
21-
pub use mining::MineBitcoinBlockTenureChangePrimaryMiner;
20+
pub use mining::{MineBitcoinBlock, MineBitcoinBlockTenureChangePrimaryMiner};
2221
pub use shutdown::ShutdownMiners;
2322
pub use stalling::{RecoverFromStall, StallMining};
24-
pub use tenure::MineBitcoinBlock;
2523
pub use transfer::SendTransferTx;

testnet/stacks-node/src/tests/signer/commands/tenure.rs

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)