Skip to content

Commit b5194b4

Browse files
committed
Rename Btc commands to Bitcoin and remove unnecessary {:?} debug
1 parent 441b1ee commit b5194b4

File tree

12 files changed

+46
-147
lines changed

12 files changed

+46
-147
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use super::context::{SignerTestContext, SignerTestState};
1111
/// This command simulates the process of mining a new Bitcoin block in the Stacks blockchain
1212
/// testing framework. Unlike the tenure change variant, this command simply advances the
1313
/// Bitcoin chain by one block without explicitly triggering a tenure change transaction.
14-
pub struct MinerMineBtcBlocks {
14+
pub struct MinerMineBitcoinBlocks {
1515
ctx: Arc<SignerTestContext>,
1616
num_blocks: u64,
1717
}
1818

19-
impl MinerMineBtcBlocks {
19+
impl MinerMineBitcoinBlocks {
2020
fn new(ctx: Arc<SignerTestContext>, num_blocks: u64) -> Self {
2121
Self { ctx, num_blocks }
2222
}
@@ -30,16 +30,16 @@ impl MinerMineBtcBlocks {
3030
}
3131
}
3232

33-
impl Command<SignerTestState, SignerTestContext> for MinerMineBtcBlocks {
33+
impl Command<SignerTestState, SignerTestContext> for MinerMineBitcoinBlocks {
3434
fn check(&self, _state: &SignerTestState) -> bool {
35-
info!("Checking: Mining tenure. Result: {:?}", true);
35+
info!("Checking: Mining tenure. Result: {}", true);
3636
true
3737
}
3838

3939
fn apply(&self, state: &mut SignerTestState) {
4040
info!("Applying: Mining {} Bitcoin block(s)", self.num_blocks);
4141

42-
state.last_block_height = Some(self.ctx.get_peer_stacks_tip_height());
42+
state.last_stacks_block_height = Some(self.ctx.get_peer_stacks_tip_height());
4343

4444
// We can use miner 1 sortition db - it's the same for both miners
4545
let sortdb = self.ctx.get_sortition_db(1);
@@ -60,10 +60,10 @@ impl Command<SignerTestState, SignerTestContext> for MinerMineBtcBlocks {
6060
ctx: Arc<SignerTestContext>,
6161
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
6262
prop_oneof![
63-
Just(CommandWrapper::new(MinerMineBtcBlocks::one(ctx.clone()))),
63+
Just(CommandWrapper::new(MinerMineBitcoinBlocks::one(ctx.clone()))),
6464
(2u64..5u64).prop_map({
6565
move |num_blocks| {
66-
CommandWrapper::new(MinerMineBtcBlocks::multiple(ctx.clone(), num_blocks))
66+
CommandWrapper::new(MinerMineBitcoinBlocks::multiple(ctx.clone(), num_blocks))
6767
}
6868
})
6969
]
@@ -75,12 +75,12 @@ impl Command<SignerTestState, SignerTestContext> for MinerMineBtcBlocks {
7575
/// controller to generate between 1-5 blocks without waiting for confirmations or
7676
/// monitoring their effect on the Stacks chain. It represents a low-level operation
7777
/// to advance the Bitcoin chain state.
78-
pub struct ChainGenerateBtcBlocks {
78+
pub struct ChainGenerateBitcoinBlocks {
7979
ctx: Arc<SignerTestContext>,
8080
num_blocks: u64,
8181
}
8282

83-
impl ChainGenerateBtcBlocks {
83+
impl ChainGenerateBitcoinBlocks {
8484
fn new(ctx: Arc<SignerTestContext>, num_blocks: u64) -> Self {
8585
Self { ctx, num_blocks }
8686
}
@@ -94,10 +94,10 @@ impl ChainGenerateBtcBlocks {
9494
}
9595
}
9696

97-
impl Command<SignerTestState, SignerTestContext> for ChainGenerateBtcBlocks {
97+
impl Command<SignerTestState, SignerTestContext> for ChainGenerateBitcoinBlocks {
9898
fn check(&self, _state: &SignerTestState) -> bool {
9999
info!(
100-
"Checking: Build next {} Bitcoin block(s). Result: {:?}",
100+
"Checking: Build next {} Bitcoin block(s). Result: {}",
101101
self.num_blocks, true
102102
);
103103
true
@@ -122,12 +122,12 @@ impl Command<SignerTestState, SignerTestContext> for ChainGenerateBtcBlocks {
122122
ctx: Arc<SignerTestContext>,
123123
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
124124
prop_oneof![
125-
Just(CommandWrapper::new(ChainGenerateBtcBlocks::one(
125+
Just(CommandWrapper::new(ChainGenerateBitcoinBlocks::one(
126126
ctx.clone()
127127
))),
128128
(2u64..=5u64).prop_map({
129129
move |num_blocks| {
130-
CommandWrapper::new(ChainGenerateBtcBlocks::multiple(ctx.clone(), num_blocks))
130+
CommandWrapper::new(ChainGenerateBitcoinBlocks::multiple(ctx.clone(), num_blocks))
131131
}
132132
})
133133
]

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Command<SignerTestState, SignerTestContext> for MinerSubmitBlockCommit {
2626
.get();
2727

2828
info!(
29-
"Checking: Submitting block commit miner {}. Result: {:?}",
29+
"Checking: Submitting block commit miner {}. Result: {}",
3030
self.miner_index, is_miner_paused
3131
);
3232

@@ -67,7 +67,6 @@ impl Command<SignerTestState, SignerTestContext> for MinerSubmitBlockCommit {
6767
.get_counters_for_miner(self.miner_index)
6868
.naka_skip_commit_op
6969
.get()
70-
== true,
7170
);
7271
}
7372

@@ -78,11 +77,8 @@ impl Command<SignerTestState, SignerTestContext> for MinerSubmitBlockCommit {
7877
fn build(
7978
ctx: Arc<SignerTestContext>,
8079
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
81-
(1usize..=2usize).prop_flat_map(move |miner_index| {
82-
Just(CommandWrapper::new(MinerSubmitBlockCommit::new(
83-
ctx.clone(),
84-
miner_index,
85-
)))
86-
})
80+
(1usize..=2usize).prop_map(move |miner_index| {
81+
CommandWrapper::new(MinerSubmitBlockCommit::new(ctx.clone(), miner_index))
82+
})
8783
}
8884
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::Arc;
22

33
use madhouse::{Command, CommandWrapper};
4-
use proptest::prelude::{Just, Strategy};
4+
use proptest::prelude::Strategy;
55

66
use super::context::{SignerTestContext, SignerTestState};
77

@@ -66,7 +66,7 @@ impl ChainVerifyMinerBlockCount {
6666
impl Command<SignerTestState, SignerTestContext> for ChainVerifyMinerBlockCount {
6767
fn check(&self, _state: &SignerTestState) -> bool {
6868
info!(
69-
"Checking: Verifying miner {} block count. Result: {:?}",
69+
"Checking: Verifying miner {} block count. Result: {}",
7070
self.miner_index, true
7171
);
7272
true
@@ -120,15 +120,15 @@ impl Command<SignerTestState, SignerTestContext> for ChainVerifyMinerBlockCount
120120
fn build(
121121
ctx: Arc<SignerTestContext>,
122122
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
123-
(1usize..=2usize, 1usize..=5usize).prop_flat_map(
123+
(1usize..=2usize, 1usize..=5usize).prop_map(
124124
move |(miner_index, expected_block_count)| {
125-
Just(CommandWrapper::new(
125+
CommandWrapper::new(
126126
ChainVerifyMinerBlockCount::after_boot_to_epoch3(
127127
ctx.clone(),
128128
miner_index,
129129
expected_block_count,
130130
),
131-
))
131+
)
132132
},
133133
)
134134
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl ChainExpectNakaBlock {
6060
impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlock {
6161
fn check(&self, state: &SignerTestState) -> bool {
6262
info!(
63-
"Checking: Waiting for Nakamoto block from miner {}. Result: {:?}",
63+
"Checking: Waiting for Nakamoto block from miner {}. Result: {}",
6464
self.miner_index, !state.mining_stalled
6565
);
6666
!state.mining_stalled
@@ -138,7 +138,7 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlock {
138138
HeightStrategy::FromStateHeight => {
139139
// Get the height from the state
140140
let conf = self.ctx.get_node_config(self.miner_index);
141-
let expected_height = state.last_block_height.unwrap() + 1;
141+
let expected_height = state.last_stacks_block_height.unwrap() + 1;
142142

143143
let miner_block =
144144
wait_for_block_pushed_by_miner_key(30, expected_height, &miner_pk).expect(
@@ -165,7 +165,7 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlock {
165165
}
166166

167167
fn label(&self) -> String {
168-
format!("WAIT_FOR_NAKAMOTO_BLOCK_FROM_MINER_{:?}", self.miner_index)
168+
format!("WAIT_FOR_NAKAMOTO_BLOCK_FROM_MINER_{}", self.miner_index)
169169
}
170170

171171
fn build(
@@ -236,22 +236,22 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
236236
match &self.expectation {
237237
BlockExpectation::JustProposal => {
238238
info!(
239-
"Checking: Waiting for block proposal from miner {:?}",
239+
"Checking: Waiting for block proposal from miner {}",
240240
self.miner_index,
241241
);
242242
true
243243
}
244244
BlockExpectation::ExpectRejection(reason) => {
245245
info!(
246-
"Checking: Waiting for block proposal from miner {:?} and rejection with reason {:?}",
246+
"Checking: Waiting for block proposal from miner {} and rejection with reason {}",
247247
self.miner_index,
248248
reason,
249249
);
250250
true
251251
}
252252
BlockExpectation::ExpectAcceptance => {
253253
info!(
254-
"Checking: Waiting for block proposal from miner {:?} and acceptance",
254+
"Checking: Waiting for block proposal from miner {} and acceptance",
255255
self.miner_index,
256256
);
257257
true
@@ -261,7 +261,7 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
261261

262262
fn apply(&self, _state: &mut SignerTestState) {
263263
info!(
264-
"Applying: Waiting for block proposal from miner {:?}",
264+
"Applying: Waiting for block proposal from miner {}",
265265
self.miner_index
266266
);
267267

@@ -283,7 +283,7 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
283283
let block_hash = proposed_block.header.signer_signature_hash();
284284

285285
info!(
286-
"Received block proposal at height {} with hash {:?}",
286+
"Received block proposal at height {} with hash {}",
287287
expected_height, block_hash
288288
);
289289

@@ -293,7 +293,7 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
293293
panic!("To be implemented: BlockExpectation::JustProposal");
294294
}
295295
BlockExpectation::ExpectRejection(reason) => {
296-
info!("Now waiting for block rejection with reason {:?}", reason);
296+
info!("Now waiting for block rejection with reason {}", reason);
297297

298298
wait_for_block_global_rejection_with_reject_reason(
299299
30,
@@ -303,7 +303,7 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
303303
)
304304
.expect("Timed out waiting for block rejection");
305305

306-
info!("Block was rejected with the expected reason: {:?}", reason);
306+
info!("Block was rejected with the expected reason: {}", reason);
307307
}
308308
BlockExpectation::ExpectAcceptance => {
309309
panic!("To be implemented: BlockExpectation::ExpectAcceptance");
@@ -312,7 +312,7 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
312312
}
313313

314314
fn label(&self) -> String {
315-
format!("WAIT_FOR_BLOCK_PROPOSAL_FROM_MINER_{:?}", self.miner_index)
315+
format!("WAIT_FOR_BLOCK_PROPOSAL_FROM_MINER_{}", self.miner_index)
316316
}
317317

318318
fn build(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl ChainBootToEpoch3 {
2222
impl Command<SignerTestState, SignerTestContext> for ChainBootToEpoch3 {
2323
fn check(&self, state: &SignerTestState) -> bool {
2424
info!(
25-
"Checking: Booting miners to Nakamoto. Result: {:?}",
25+
"Checking: Booting miners to Nakamoto. Result: {}",
2626
!state.is_booted_to_nakamoto
2727
);
2828
// This command should only run if the state indicates it hasn't booted to Nakamoto yet.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Command<SignerTestState, SignerTestContext> for ChainMinerCommitOp {
4444
let should_apply = current_state != self.skip;
4545
let operation = if self.skip { "disabl" } else { "enabl" };
4646
info!(
47-
"Checking: {}ing commit operations for miner {}. Result: {:?}",
47+
"Checking: {}ing commit operations for miner {}. Result: {}",
4848
operation, self.miner_index, should_apply
4949
);
5050
should_apply

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

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -133,111 +133,14 @@ impl SignerTestContext {
133133
})
134134
.count()
135135
}
136-
137-
pub fn _print_counters(&self, miner_index: usize) {
138-
let counters = self.get_counters_for_miner(miner_index);
139-
140-
println!("=== COUNTERS FOR MINER {} ===", miner_index);
141-
println!(
142-
"blocks_processed: {}",
143-
counters.blocks_processed.load(Ordering::SeqCst)
144-
);
145-
println!(
146-
"microblocks_processed: {}",
147-
counters.microblocks_processed.load(Ordering::SeqCst)
148-
);
149-
println!(
150-
"missed_tenures: {}",
151-
counters.missed_tenures.load(Ordering::SeqCst)
152-
);
153-
println!(
154-
"missed_microblock_tenures: {}",
155-
counters.missed_microblock_tenures.load(Ordering::SeqCst)
156-
);
157-
println!(
158-
"cancelled_commits: {}",
159-
counters.cancelled_commits.load(Ordering::SeqCst)
160-
);
161-
println!(
162-
"sortitions_processed: {}",
163-
counters.sortitions_processed.load(Ordering::SeqCst)
164-
);
165-
println!(
166-
"naka_submitted_vrfs: {}",
167-
counters.naka_submitted_vrfs.load(Ordering::SeqCst)
168-
);
169-
println!(
170-
"naka_submitted_commits: {}",
171-
counters.naka_submitted_commits.load(Ordering::SeqCst)
172-
);
173-
println!(
174-
"naka_submitted_commit_last_burn_height: {}",
175-
counters
176-
.naka_submitted_commit_last_burn_height
177-
.load(Ordering::SeqCst)
178-
);
179-
println!(
180-
"naka_mined_blocks: {}",
181-
counters.naka_mined_blocks.load(Ordering::SeqCst)
182-
);
183-
println!(
184-
"naka_rejected_blocks: {}",
185-
counters.naka_rejected_blocks.load(Ordering::SeqCst)
186-
);
187-
println!(
188-
"naka_proposed_blocks: {}",
189-
counters.naka_proposed_blocks.load(Ordering::SeqCst)
190-
);
191-
println!(
192-
"naka_mined_tenures: {}",
193-
counters.naka_mined_tenures.load(Ordering::SeqCst)
194-
);
195-
println!(
196-
"naka_signer_pushed_blocks: {}",
197-
counters.naka_signer_pushed_blocks.load(Ordering::SeqCst)
198-
);
199-
println!(
200-
"naka_miner_directives: {}",
201-
counters.naka_miner_directives.load(Ordering::SeqCst)
202-
);
203-
println!(
204-
"naka_submitted_commit_last_stacks_tip: {}",
205-
counters
206-
.naka_submitted_commit_last_stacks_tip
207-
.load(Ordering::SeqCst)
208-
);
209-
println!(
210-
"naka_submitted_commit_last_commit_amount: {}",
211-
counters
212-
.naka_submitted_commit_last_commit_amount
213-
.load(Ordering::SeqCst)
214-
);
215-
println!(
216-
"naka_miner_current_rejections: {}",
217-
counters
218-
.naka_miner_current_rejections
219-
.load(Ordering::SeqCst)
220-
);
221-
println!(
222-
"naka_miner_current_rejections_timeout_secs: {}",
223-
counters
224-
.naka_miner_current_rejections_timeout_secs
225-
.load(Ordering::SeqCst)
226-
);
227-
println!(
228-
"naka_skip_commit_op: {}",
229-
counters.naka_skip_commit_op.get()
230-
);
231-
println!("==============================");
232-
}
233136
}
234137

235138
#[derive(Debug, Default)]
236139
pub struct SignerTestState {
237140
pub is_booted_to_nakamoto: bool,
238141
pub mining_stalled: bool,
239142
pub epoch_3_start_block_height: Option<u64>,
240-
pub last_block_height: Option<u64>,
143+
pub last_stacks_block_height: Option<u64>,
241144
}
242145

243146
impl SignerTestState {}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod sortition;
1111
mod stacks_mining;
1212
mod transfer;
1313

14-
pub use bitcoin_mining::{ChainGenerateBtcBlocks, MinerMineBtcBlocks};
14+
pub use bitcoin_mining::{ChainGenerateBitcoinBlocks, MinerMineBitcoinBlocks};
1515
pub use block_commit::MinerSubmitBlockCommit;
1616
pub use block_verify::ChainVerifyMinerBlockCount;
1717
pub use block_wait::{ChainExpectNakaBlock, ChainExpectNakaBlockProposal, ChainExpectTenureChange};

0 commit comments

Comments
 (0)