Skip to content

Commit a02c9a6

Browse files
committed
chore: Apply Clippy lint collection_is_never_used
1 parent 8c23c0e commit a02c9a6

File tree

24 files changed

+21
-197
lines changed

24 files changed

+21
-197
lines changed

stackslib/src/burnchains/tests/burnchain.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -698,32 +698,21 @@ fn test_burn_snapshot_sequence() {
698698
initial_reward_start_block: first_block_height,
699699
};
700700

701-
let mut leader_private_keys = vec![];
702701
let mut leader_public_keys = vec![];
703702
let mut leader_bitcoin_public_keys = vec![];
704-
let mut leader_bitcoin_addresses = vec![];
705703

706704
for i in 0..32 {
707705
let mut csprng: ThreadRng = thread_rng();
708706
let vrf_privkey = VRFPrivateKey(ed25519_dalek::SigningKey::generate(&mut csprng));
709707
let vrf_pubkey = VRFPublicKey::from_private(&vrf_privkey);
710708

711-
let privkey_hex = vrf_privkey.to_hex();
712-
leader_private_keys.push(privkey_hex);
713-
714709
let pubkey_hex = vrf_pubkey.to_hex();
715710
leader_public_keys.push(pubkey_hex);
716711

717712
let bitcoin_privkey = Secp256k1PrivateKey::new();
718713
let bitcoin_publickey = BitcoinPublicKey::from_private(&bitcoin_privkey);
719714

720715
leader_bitcoin_public_keys.push(to_hex(&bitcoin_publickey.to_bytes()));
721-
722-
leader_bitcoin_addresses.push(BitcoinAddress::from_bytes_legacy(
723-
BitcoinNetworkType::Testnet,
724-
LegacyBitcoinAddressType::PublicKeyHash,
725-
&Hash160::from_data(&bitcoin_publickey.to_bytes()).0,
726-
));
727716
}
728717

729718
let mut expected_burn_total: u64 = 0;
@@ -732,7 +721,6 @@ fn test_burn_snapshot_sequence() {
732721
let mut db = SortitionDB::connect_test(first_block_height, &first_burn_hash).unwrap();
733722
let mut prev_snapshot =
734723
BlockSnapshot::initial(first_block_height, &first_burn_hash, first_block_height);
735-
let mut all_stacks_block_hashes = vec![];
736724

737725
for i in 0..32 {
738726
let mut block_ops = vec![];
@@ -823,7 +811,6 @@ fn test_burn_snapshot_sequence() {
823811
burn_header_hash: burn_block_hash.clone(),
824812
};
825813

826-
all_stacks_block_hashes.push(next_block_commit.block_header_hash.clone());
827814
block_ops.push(BlockstackOperationType::LeaderBlockCommit(
828815
next_block_commit,
829816
));

stackslib/src/burnchains/tests/db.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,6 @@ fn test_update_block_descendancy_with_fork() {
919919
let mut cmts_genesis = vec![];
920920
let mut cmts_invalid = vec![];
921921

922-
let mut fork_parent = None;
923-
let mut fork_parent_block_header: Option<BurnchainBlockHeader> = None;
924922
let mut fork_cmts = vec![];
925923

926924
for i in 0..5 {
@@ -954,7 +952,6 @@ fn test_update_block_descendancy_with_fork() {
954952
};
955953

956954
fork_headers.push(block_header.clone());
957-
fork_parent_block_header = Some(block_header);
958955
}
959956

960957
let mut am_id = 0;
@@ -1018,7 +1015,6 @@ fn test_update_block_descendancy_with_fork() {
10181015
fork_cmts.push(fork_cmt.clone());
10191016

10201017
parent = Some(cmt);
1021-
fork_parent = Some(fork_cmt);
10221018

10231019
if i == 0 {
10241020
am_id = {

stackslib/src/chainstate/coordinator/tests.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,6 @@ fn test_sortition_with_reward_set() {
22682268
let mut started_first_reward_cycle = false;
22692269
// process sequential blocks, and their sortitions...
22702270
let mut stacks_blocks: Vec<(SortitionId, StacksBlock)> = vec![];
2271-
let mut anchor_blocks = vec![];
22722271

22732272
// split up the vrf keys and committers so that we have some that will be mining "correctly"
22742273
// and some that will be producing bad outputs
@@ -2442,10 +2441,6 @@ fn test_sortition_with_reward_set() {
24422441
let new_burnchain_tip = burnchain.get_canonical_chain_tip().unwrap();
24432442
if b.is_reward_cycle_start(new_burnchain_tip.block_height) {
24442443
started_first_reward_cycle = true;
2445-
// store the anchor block for this sortition for later checking
2446-
let ic = sort_db.index_handle_at_tip();
2447-
let bhh = ic.get_last_anchor_block_hash().unwrap().unwrap();
2448-
anchor_blocks.push(bhh);
24492444
}
24502445

24512446
let tip = SortitionDB::get_canonical_burn_chain_tip(sort_db.conn()).unwrap();
@@ -2540,7 +2535,6 @@ fn test_sortition_with_burner_reward_set() {
25402535
let mut started_first_reward_cycle = false;
25412536
// process sequential blocks, and their sortitions...
25422537
let mut stacks_blocks: Vec<(SortitionId, StacksBlock)> = vec![];
2543-
let mut anchor_blocks = vec![];
25442538

25452539
// split up the vrf keys and committers so that we have some that will be mining "correctly"
25462540
// and some that will be producing bad outputs
@@ -2688,10 +2682,6 @@ fn test_sortition_with_burner_reward_set() {
26882682
let new_burnchain_tip = burnchain.get_canonical_chain_tip().unwrap();
26892683
if b.is_reward_cycle_start(new_burnchain_tip.block_height) {
26902684
started_first_reward_cycle = true;
2691-
// store the anchor block for this sortition for later checking
2692-
let ic = sort_db.index_handle_at_tip();
2693-
let bhh = ic.get_last_anchor_block_hash().unwrap().unwrap();
2694-
anchor_blocks.push(bhh);
26952685
}
26962686

26972687
let tip = SortitionDB::get_canonical_burn_chain_tip(sort_db.conn()).unwrap();
@@ -2804,7 +2794,6 @@ fn test_pox_btc_ops() {
28042794
let mut started_first_reward_cycle = false;
28052795
// process sequential blocks, and their sortitions...
28062796
let mut stacks_blocks: Vec<(SortitionId, StacksBlock)> = vec![];
2807-
let mut anchor_blocks = vec![];
28082797

28092798
// track the reward set consumption
28102799
let mut reward_cycle_count = 0;
@@ -2972,10 +2961,6 @@ fn test_pox_btc_ops() {
29722961
if b.is_reward_cycle_start(new_burnchain_tip.block_height) {
29732962
if new_burnchain_tip.block_height < sunset_ht {
29742963
started_first_reward_cycle = true;
2975-
// store the anchor block for this sortition for later checking
2976-
let ic = sort_db.index_handle_at_tip();
2977-
let bhh = ic.get_last_anchor_block_hash().unwrap().unwrap();
2978-
anchor_blocks.push(bhh);
29792964
} else {
29802965
// store the anchor block for this sortition for later checking
29812966
let ic = sort_db.index_handle_at_tip();
@@ -3096,7 +3081,6 @@ fn test_stx_transfer_btc_ops() {
30963081
let mut started_first_reward_cycle = false;
30973082
// process sequential blocks, and their sortitions...
30983083
let mut stacks_blocks: Vec<(SortitionId, StacksBlock)> = vec![];
3099-
let mut anchor_blocks = vec![];
31003084

31013085
// track the reward set consumption
31023086
let mut reward_recipients = HashSet::new();
@@ -3319,10 +3303,6 @@ fn test_stx_transfer_btc_ops() {
33193303
if b.is_reward_cycle_start(new_burnchain_tip.block_height) {
33203304
if new_burnchain_tip.block_height < sunset_ht {
33213305
started_first_reward_cycle = true;
3322-
// store the anchor block for this sortition for later checking
3323-
let ic = sort_db.index_handle_at_tip();
3324-
let bhh = ic.get_last_anchor_block_hash().unwrap().unwrap();
3325-
anchor_blocks.push(bhh);
33263306
} else {
33273307
// store the anchor block for this sortition for later checking
33283308
let ic = sort_db.index_handle_at_tip();
@@ -5303,7 +5283,6 @@ fn test_sortition_with_sunset() {
53035283
let mut started_first_reward_cycle = false;
53045284
// process sequential blocks, and their sortitions...
53055285
let mut stacks_blocks: Vec<(SortitionId, StacksBlock)> = vec![];
5306-
let mut anchor_blocks = vec![];
53075286

53085287
// split up the vrf keys and committers so that we have some that will be mining "correctly"
53095288
// and some that will be producing bad outputs
@@ -5487,10 +5466,6 @@ fn test_sortition_with_sunset() {
54875466
if b.is_reward_cycle_start(new_burnchain_tip.block_height) {
54885467
if new_burnchain_tip.block_height < sunset_ht {
54895468
started_first_reward_cycle = true;
5490-
// store the anchor block for this sortition for later checking
5491-
let ic = sort_db.index_handle_at_tip();
5492-
let bhh = ic.get_last_anchor_block_hash().unwrap().unwrap();
5493-
anchor_blocks.push(bhh);
54945469
} else {
54955470
// store the anchor block for this sortition for later checking
54965471
let ic = sort_db.index_handle_at_tip();
@@ -5616,7 +5591,6 @@ fn test_sortition_with_sunset_and_epoch_switch() {
56165591
let mut started_first_reward_cycle = false;
56175592
// process sequential blocks, and their sortitions...
56185593
let mut stacks_blocks: Vec<(SortitionId, StacksBlock)> = vec![];
5619-
let mut anchor_blocks = vec![];
56205594

56215595
// split up the vrf keys and committers so that we have some that will be mining "correctly"
56225596
// and some that will be producing bad outputs
@@ -5828,10 +5802,6 @@ fn test_sortition_with_sunset_and_epoch_switch() {
58285802
if b.is_reward_cycle_start(new_burnchain_tip.block_height) {
58295803
if new_burnchain_tip.block_height < sunset_ht {
58305804
started_first_reward_cycle = true;
5831-
// store the anchor block for this sortition for later checking
5832-
let ic = sort_db.index_handle_at_tip();
5833-
let bhh = ic.get_last_anchor_block_hash().unwrap().unwrap();
5834-
anchor_blocks.push(bhh);
58355805
} else {
58365806
// store the anchor block for this sortition for later checking
58375807
let ic = sort_db.index_handle_at_tip();
@@ -6479,7 +6449,6 @@ fn test_pox_fork_out_of_order() {
64796449
let mut sortition_ids_diverged = false;
64806450
// process sequential blocks, and their sortitions...
64816451
let mut stacks_blocks: Vec<(SortitionId, StacksBlock)> = vec![];
6482-
let mut anchor_blocks = vec![];
64836452

64846453
// setup:
64856454
// 2 forks: 0 - 1 - 2 - 3 - 4 - 5 - 11 - 12 - 13 - 14 - 15
@@ -6560,8 +6529,6 @@ fn test_pox_fork_out_of_order() {
65606529
.unwrap()
65616530
.block_height
65626531
);
6563-
6564-
anchor_blocks.push(bhh);
65656532
}
65666533

65676534
let tip = SortitionDB::get_canonical_burn_chain_tip(sort_db.conn()).unwrap();

stackslib/src/chainstate/nakamoto/coordinator/tests.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ fn advance_to_nakamoto(
112112
let default_pox_addr =
113113
PoxAddress::from_legacy(AddressHashMode::SerializeP2PKH, addr.bytes.clone());
114114

115+
// Stores the result of a function with side effects, so have Clippy ignore it
116+
#[allow(clippy::collection_is_never_read)]
115117
let mut tip = None;
116118
for sortition_height in 0..11 {
117119
// stack to pox-3 in cycle 7
@@ -347,9 +349,6 @@ fn replay_reward_cycle(
347349
.step_by(reward_cycle_length)
348350
.collect();
349351

350-
let mut indexes: Vec<_> = (0..stacks_blocks.len()).collect();
351-
indexes.shuffle(&mut thread_rng());
352-
353352
for burn_ops in burn_ops.iter() {
354353
let (_, _, consensus_hash) = peer.next_burnchain_block(burn_ops.clone());
355354
}
@@ -845,7 +844,6 @@ fn block_descendant() {
845844
boot_plan.pox_constants = pox_constants;
846845

847846
let mut peer = boot_plan.boot_into_nakamoto_peer(vec![], None);
848-
let mut blocks = vec![];
849847
let pox_constants = peer.sortdb().pox_constants.clone();
850848
let first_burn_height = peer.sortdb().first_block_height;
851849

@@ -854,7 +852,6 @@ fn block_descendant() {
854852
loop {
855853
let (block, burn_height, ..) =
856854
peer.single_block_tenure(&private_key, |_| {}, |_| {}, |_| true);
857-
blocks.push(block);
858855

859856
if pox_constants.is_in_prepare_phase(first_burn_height, burn_height + 1) {
860857
info!("At prepare phase start"; "burn_height" => burn_height);
@@ -3206,9 +3203,6 @@ fn test_stacks_on_burnchain_ops() {
32063203
);
32073204

32083205
let mut all_blocks: Vec<NakamotoBlock> = vec![];
3209-
let mut all_burn_ops = vec![];
3210-
let mut consensus_hashes = vec![];
3211-
let mut fee_counts = vec![];
32123206
let stx_miner_key = peer.miner.nakamoto_miner_key();
32133207

32143208
let mut extra_burn_ops = vec![];
@@ -3406,8 +3400,6 @@ fn test_stacks_on_burnchain_ops() {
34063400
})
34073401
.sum::<u128>();
34083402

3409-
consensus_hashes.push(consensus_hash);
3410-
fee_counts.push(fees);
34113403
let mut blocks: Vec<NakamotoBlock> = blocks_and_sizes
34123404
.into_iter()
34133405
.map(|(block, _, _)| block)
@@ -3449,7 +3441,6 @@ fn test_stacks_on_burnchain_ops() {
34493441
);
34503442

34513443
all_blocks.append(&mut blocks);
3452-
all_burn_ops.push(burn_ops);
34533444
}
34543445

34553446
// check receipts for burn ops

stackslib/src/chainstate/nakamoto/tests/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,8 +2529,6 @@ fn parse_vote_for_aggregate_public_key_invalid() {
25292529
};
25302530
invalid_function_arg_reward_cycle.set_origin_nonce(1);
25312531

2532-
let mut account_nonces = std::collections::HashMap::new();
2533-
account_nonces.insert(invalid_contract_name.origin_address(), 1);
25342532
for (i, tx) in vec![
25352533
invalid_contract_address,
25362534
invalid_contract_name,

stackslib/src/chainstate/stacks/block.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,19 +1146,6 @@ mod test {
11461146
StacksEpochId::latest(),
11471147
);
11481148

1149-
// remove all coinbases
1150-
let mut txs_anchored = vec![];
1151-
1152-
for tx in all_txs.iter() {
1153-
match tx.payload {
1154-
TransactionPayload::Coinbase(..) => {
1155-
continue;
1156-
}
1157-
_ => {}
1158-
}
1159-
txs_anchored.push(tx);
1160-
}
1161-
11621149
// make microblocks with 3 transactions each (or fewer)
11631150
for i in 0..(all_txs.len() / 3) {
11641151
let txs = vec![

stackslib/src/chainstate/stacks/boot/pox_4_tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,8 @@ fn pox_lock_unlock() {
928928

929929
assert_eq!(burnchain.pox_constants.reward_slots(), 6);
930930
let mut coinbase_nonce = 0;
931+
// Stores the result of a function with side effects, so have Clippy ignore it
932+
#[allow(clippy::collection_is_never_read)]
931933
let mut latest_block = None;
932934

933935
// Advance into pox4
@@ -2685,6 +2687,8 @@ fn pox_4_delegate_stack_increase_events() {
26852687

26862688
assert_eq!(burnchain.pox_constants.reward_slots(), 6);
26872689
let mut coinbase_nonce = 0;
2690+
// Stores the result of a function with side effects, so have Clippy ignore it
2691+
#[allow(clippy::collection_is_never_read)]
26882692
let mut latest_block = None;
26892693

26902694
let alice_key = keys.pop().unwrap();

stackslib/src/chainstate/stacks/db/transactions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ impl TryFrom<Value> for HashableClarityValue {
7272

7373
impl std::hash::Hash for HashableClarityValue {
7474
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
75-
#[allow(clippy::unwrap_used)]
75+
#[allow(clippy::unwrap_used, clippy::collection_is_never_read)]
7676
// this unwrap is safe _as long as_ TryFrom<Value> was used as a constructor
77+
// Also, this function has side effects, which cause Clippy to wrongly think `bytes` is unused
7778
let bytes = self.0.serialize_to_vec().unwrap();
7879
bytes.hash(state);
7980
}

stackslib/src/chainstate/stacks/index/test/trie.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,6 @@ fn trie_cursor_splice_leaf_4() {
12451245
let (nodes, node_ptrs, hashes) =
12461246
make_node_path(&mut f, node_id.to_u8(), &path_segments, [31u8; 40].to_vec());
12471247

1248-
let mut ptrs = vec![];
1249-
12501248
// splice in a node in each path segment
12511249
for k in 0..5 {
12521250
let mut path = vec![
@@ -1274,7 +1272,6 @@ fn trie_cursor_splice_leaf_4() {
12741272
&mut node,
12751273
)
12761274
.unwrap();
1277-
ptrs.push(new_ptr);
12781275

12791276
Trie::update_root_hash(&mut f, &c).unwrap();
12801277

@@ -1338,7 +1335,6 @@ fn trie_cursor_splice_leaf_2() {
13381335

13391336
let (nodes, node_ptrs, hashes) =
13401337
make_node_path(&mut f, node_id.to_u8(), &path_segments, [31u8; 40].to_vec());
1341-
let mut ptrs = vec![];
13421338

13431339
// splice in a node in each path segment
13441340
for k in 0..10 {
@@ -1363,7 +1359,6 @@ fn trie_cursor_splice_leaf_2() {
13631359
&mut node,
13641360
)
13651361
.unwrap();
1366-
ptrs.push(new_ptr);
13671362

13681363
Trie::update_root_hash(&mut f, &c).unwrap();
13691364

0 commit comments

Comments
 (0)