Skip to content

Commit b12eabc

Browse files
committed
Keep linters happy
1 parent c68577c commit b12eabc

File tree

8 files changed

+61
-68
lines changed

8 files changed

+61
-68
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ pub struct MinerMineBtcBlocks {
111111

112112
impl MinerMineBtcBlocks {
113113
fn new(ctx: Arc<SignerTestContext>, num_blocks: u64) -> Self {
114-
Self {
115-
ctx,
116-
num_blocks,
117-
}
114+
Self { ctx, num_blocks }
118115
}
119116

120117
pub fn one(ctx: Arc<SignerTestContext>) -> Self {
@@ -133,10 +130,7 @@ impl Command<SignerTestState, SignerTestContext> for MinerMineBtcBlocks {
133130
}
134131

135132
fn apply(&self, _state: &mut SignerTestState) {
136-
info!(
137-
"Applying: Mining {} Bitcoin block(s)",
138-
self.num_blocks
139-
);
133+
info!("Applying: Mining {} Bitcoin block(s)", self.num_blocks);
140134

141135
// We can use miner 1 sortition db - it's the same for both miners
142136
let sortdb = self.ctx.get_sortition_db(1);
@@ -222,7 +216,9 @@ impl Command<SignerTestState, SignerTestContext> for ChainGenerateBtcBlocks {
222216
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
223217
use proptest::prelude::*;
224218
prop_oneof![
225-
Just(CommandWrapper::new(ChainGenerateBtcBlocks::one(ctx.clone()))),
219+
Just(CommandWrapper::new(ChainGenerateBtcBlocks::one(
220+
ctx.clone()
221+
))),
226222
(2u64..=5u64).prop_map({
227223
let ctx = ctx.clone();
228224
move |num_blocks| {
@@ -231,4 +227,4 @@ impl Command<SignerTestState, SignerTestContext> for ChainGenerateBtcBlocks {
231227
})
232228
]
233229
}
234-
}
230+
}

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ impl Command<SignerTestState, SignerTestContext> for ChainVerifyMinerBlockCount
8989
&miner_pk,
9090
)
9191
}
92-
HeightStrategy::AfterSpecificHeight(height) => {
93-
self.ctx.get_miner_blocks_after_specified_block_height(
94-
&conf,
95-
height,
96-
&miner_pk,
97-
)
98-
}
92+
HeightStrategy::AfterSpecificHeight(height) => self
93+
.ctx
94+
.get_miner_blocks_after_specified_block_height(&conf, height, &miner_pk),
9995
};
10096

10197
assert_eq!(
102-
self.expected_block_count, miner_blocks_after_height,
98+
self.expected_block_count,
99+
miner_blocks_after_height,
103100
"Expected {} blocks from miner {} after {:?}, but found {}",
104-
self.expected_block_count, self.miner_index, self.height_strategy, miner_blocks_after_height
101+
self.expected_block_count,
102+
self.miner_index,
103+
self.height_strategy,
104+
miner_blocks_after_height
105105
);
106106

107107
info!(
@@ -111,7 +111,10 @@ impl Command<SignerTestState, SignerTestContext> for ChainVerifyMinerBlockCount
111111
}
112112

113113
fn label(&self) -> String {
114-
format!("VERIFY_MINER_{}_BLOCK_COUNT_{:?}", self.miner_index, self.height_strategy)
114+
format!(
115+
"VERIFY_MINER_{}_BLOCK_COUNT_{:?}",
116+
self.miner_index, self.height_strategy
117+
)
115118
}
116119

117120
fn build(
@@ -129,4 +132,4 @@ impl Command<SignerTestState, SignerTestContext> for ChainVerifyMinerBlockCount
129132
},
130133
)
131134
}
132-
}
135+
}

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

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlock {
189189
/// Can optionally wait for the proposed block to be rejected or accepted based on the expectation.
190190
#[derive(Debug, Clone)]
191191
enum BlockExpectation {
192-
JustProposal, // Just wait for proposal, don't check outcome
193-
ExpectRejection(RejectReason), // Expect rejection with specific reason
194-
ExpectAcceptance, // Expect the block to be accepted/confirmed
192+
JustProposal, // Just wait for proposal, don't check outcome
193+
ExpectRejection(RejectReason), // Expect rejection with specific reason
194+
ExpectAcceptance, // Expect the block to be accepted/confirmed
195195
}
196196

197197
pub struct ChainExpectNakaBlockProposal {
@@ -201,15 +201,19 @@ pub struct ChainExpectNakaBlockProposal {
201201
}
202202

203203
impl ChainExpectNakaBlockProposal {
204-
fn new(ctx: Arc<SignerTestContext>, miner_index: usize) -> Self {
205-
Self {
206-
ctx,
204+
pub fn new(ctx: Arc<SignerTestContext>, miner_index: usize) -> Self {
205+
Self {
206+
ctx,
207207
miner_index,
208208
expectation: BlockExpectation::JustProposal,
209209
}
210210
}
211211

212-
pub fn with_rejection(ctx: Arc<SignerTestContext>, miner_index: usize, reason: RejectReason) -> Self {
212+
pub fn with_rejection(
213+
ctx: Arc<SignerTestContext>,
214+
miner_index: usize,
215+
reason: RejectReason,
216+
) -> Self {
213217
Self {
214218
ctx,
215219
miner_index,
@@ -235,22 +239,22 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
235239
self.miner_index,
236240
);
237241
true
238-
},
242+
}
239243
BlockExpectation::ExpectRejection(reason) => {
240244
info!(
241245
"Checking: Waiting for block proposal from miner {:?} and rejection with reason {:?}",
242246
self.miner_index,
243247
reason,
244248
);
245249
true
246-
},
250+
}
247251
BlockExpectation::ExpectAcceptance => {
248252
info!(
249253
"Checking: Waiting for block proposal from miner {:?} and acceptance",
250254
self.miner_index,
251255
);
252256
true
253-
},
257+
}
254258
}
255259
}
256260

@@ -286,12 +290,9 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
286290
match &self.expectation {
287291
BlockExpectation::JustProposal => {
288292
info!("Block proposal received, no further expectations");
289-
},
293+
}
290294
BlockExpectation::ExpectRejection(reason) => {
291-
info!(
292-
"Now waiting for block rejection with reason {:?}",
293-
reason
294-
);
295+
info!("Now waiting for block rejection with reason {:?}", reason);
295296

296297
wait_for_block_global_rejection_with_reject_reason(
297298
30,
@@ -301,15 +302,12 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
301302
)
302303
.expect("Timed out waiting for block rejection");
303304

304-
info!(
305-
"Block was rejected with the expected reason: {:?}",
306-
reason
307-
);
308-
},
305+
info!("Block was rejected with the expected reason: {:?}", reason);
306+
}
309307
BlockExpectation::ExpectAcceptance => {
310308
info!("Now waiting for block acceptance");
311309
// TODO: Implement waiting for block acceptance/confirmation
312-
},
310+
}
313311
}
314312
}
315313

@@ -327,4 +325,4 @@ impl Command<SignerTestState, SignerTestContext> for ChainExpectNakaBlockProposa
327325
)))
328326
})
329327
}
330-
}
328+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl SignerTestContext {
6161
self.num_signers
6262
}
6363

64-
// Getter for num_transfer_txs
64+
// Getter for num_transfer_txs
6565
pub fn get_num_transfer_txs(&self) -> u64 {
6666
self.num_transfer_txs
6767
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ mod stacks_mining;
1212
mod transfer;
1313

1414
pub use bitcoin_mining::{
15-
MinerMineBtcBlocks, MinerMineBlockAndTriggerTenureChange, ChainGenerateBtcBlocks,
15+
ChainGenerateBtcBlocks, MinerMineBlockAndTriggerTenureChange, MinerMineBtcBlocks,
1616
};
1717
pub use block_commit::MinerSubmitBlockCommit;
1818
pub use block_verify::ChainVerifyMinerBlockCount;
19-
pub use block_wait::{
20-
ChainExpectNakaBlock,
21-
ChainExpectNakaBlockProposal,
22-
};
19+
pub use block_wait::{ChainExpectNakaBlock, ChainExpectNakaBlockProposal};
2320
pub use boot::ChainBootToEpoch3;
2421
pub use commit_ops::ChainMinerCommitOp;
2522
pub use context::SignerTestContext;
2623
pub use shutdown::ChainShutdownMiners;
27-
pub use sortition::{ChainVerifyLastSortitionWinnerReorged, ChainExpectSortitionWinner};
24+
pub use sortition::{ChainExpectSortitionWinner, ChainVerifyLastSortitionWinnerReorged};
2825
pub use stacks_mining::ChainStacksMining;
2926
pub use transfer::MinerSendAndMineTransferTx;

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,20 @@ impl Command<SignerTestState, SignerTestContext> for ChainShutdownMiners {
2626

2727
fn apply(&self, _state: &mut SignerTestState) {
2828
info!("Applying: Shutting down miners");
29-
29+
3030
let miners_arc = self.ctx.miners.clone();
31-
31+
3232
// Try to unwrap the Arc - this only works if we're the last reference
3333
match Arc::try_unwrap(miners_arc) {
34-
Ok(mutex) => {
35-
match mutex.into_inner() {
36-
Ok(miners) => {
37-
miners.shutdown();
38-
info!("Miners have been shut down");
39-
}
40-
Err(_) => {
41-
warn!("Mutex was poisoned, cannot shutdown miners cleanly");
42-
}
34+
Ok(mutex) => match mutex.into_inner() {
35+
Ok(miners) => {
36+
miners.shutdown();
37+
info!("Miners have been shut down");
4338
}
44-
}
39+
Err(_) => {
40+
warn!("Mutex was poisoned, cannot shutdown miners cleanly");
41+
}
42+
},
4543
Err(_) => {
4644
warn!("Cannot shutdown miners: other references to Arc still exist");
4745
// Could potentially set a flag or use some other coordination mechanism
@@ -58,4 +56,4 @@ impl Command<SignerTestState, SignerTestContext> for ChainShutdownMiners {
5856
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
5957
Just(CommandWrapper::new(ChainShutdownMiners::new(ctx.clone())))
6058
}
61-
}
59+
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ impl Command<SignerTestState, SignerTestContext> for MinerSendAndMineTransferTx
6262
) -> impl Strategy<Value = CommandWrapper<SignerTestState, SignerTestContext>> {
6363
(20u64..40u64).prop_map(move |timeout_secs| {
6464
// Originally, timeout was 30 seconds
65-
CommandWrapper::new(MinerSendAndMineTransferTx::new(
66-
ctx.clone(),
67-
timeout_secs,
68-
))
65+
CommandWrapper::new(MinerSendAndMineTransferTx::new(ctx.clone(), timeout_secs))
6966
})
7067
}
7168
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10976,7 +10976,11 @@ fn disallow_reorg_within_first_proposal_burn_block_timing_secs_but_more_than_one
1097610976
MinerSendAndMineTransferTx,
1097710977
MinerSendAndMineTransferTx,
1097810978
(ChainGenerateBtcBlocks::one(test_context.clone())),
10979-
(ChainExpectNakaBlockProposal::with_rejection(test_context.clone(), MINER1, RejectReason::ReorgNotAllowed)),
10979+
(ChainExpectNakaBlockProposal::with_rejection(
10980+
test_context.clone(),
10981+
MINER1,
10982+
RejectReason::ReorgNotAllowed
10983+
)),
1098010984
(ChainVerifyMinerBlockCount::after_boot_to_epoch3(test_context.clone(), MINER1, 1)), // FIXME: This takes the expected block count as a parameter - can we avoid that?
1098110985
ChainShutdownMiners, // FIXME: miners.shutdown() says: Cannot shutdown miners: other references to Arc still exist
1098210986
]

0 commit comments

Comments
 (0)