Skip to content

Commit 15724ec

Browse files
authored
Merge pull request #3883 from TheBlueMatt/2025-06-no-test-useless-vecs
Remove (and deny) useless test `vec!`s
2 parents 0fe51c5 + 6091c4a commit 15724ec

18 files changed

+74
-76
lines changed

ci/check-lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ CLIPPY() {
110110

111111
CLIPPY
112112
# We allow some additional warnings in tests which we should fix, but which aren't currently a priority
113-
CLIPPY --tests "-A clippy::bool_assert_comparison -A clippy::assertions_on_constants -A clippy::needless-late-init -A clippy::field_reassign_with_default -A clippy::unnecessary_literal_unwrap -A clippy::useless_vec"
113+
CLIPPY --tests "-A clippy::bool_assert_comparison -A clippy::assertions_on_constants -A clippy::needless-late-init -A clippy::field_reassign_with_default -A clippy::unnecessary_literal_unwrap"

lightning-rapid-gossip-sync/src/processing.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ mod tests {
503503
let logger = TestLogger::new();
504504
let network_graph = NetworkGraph::new(Network::Bitcoin, &logger);
505505

506-
let example_input = vec![
506+
let example_input = [
507507
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
508508
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218,
509509
0, 0, 0, 4, 2, 22, 7, 207, 206, 25, 164, 197, 231, 230, 231, 56, 102, 61, 250, 251,
@@ -534,7 +534,7 @@ mod tests {
534534
let logger = TestLogger::new();
535535
let network_graph = NetworkGraph::new(Network::Bitcoin, &logger);
536536

537-
let example_input = vec![
537+
let example_input = [
538538
76, 68, 75, 2, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
539539
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 102, 97, 206, 240,
540540
0, 0, 0, 0, 2, 63, 27, 132, 197, 86, 123, 18, 100, 64, 153, 93, 62, 213, 170, 186, 5,
@@ -597,7 +597,7 @@ mod tests {
597597
let network_graph = NetworkGraph::new(Network::Bitcoin, &logger);
598598
let rapid_sync = RapidGossipSync::new(&network_graph, &logger);
599599

600-
let example_input = vec![
600+
let example_input = [
601601
76, 68, 75, 2, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
602602
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 102, 105, 183,
603603
240, 0, 0, 0, 0, 1, 63, 27, 132, 197, 86, 123, 18, 100, 64, 153, 93, 62, 213, 170, 186,
@@ -625,7 +625,7 @@ mod tests {
625625
let network_graph = NetworkGraph::new(Network::Bitcoin, &logger);
626626
let rapid_sync = RapidGossipSync::new(&network_graph, &logger);
627627

628-
let example_input = vec![
628+
let example_input = [
629629
76, 68, 75, 2, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
630630
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 102, 106, 12, 80,
631631
1, 0, 2, 23, 48, 0, 0, 0, 3, 143, 27, 132, 197, 86, 123, 18, 100, 64, 153, 93, 62, 213,
@@ -700,7 +700,7 @@ mod tests {
700700
#[test]
701701
#[cfg(feature = "std")]
702702
fn incremental_only_update_ignores_missing_channel() {
703-
let incremental_update_input = vec![
703+
let incremental_update_input = [
704704
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
705705
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167,
706706
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -721,7 +721,7 @@ mod tests {
721721
#[test]
722722
#[cfg(feature = "std")]
723723
fn incremental_only_update_fails_without_prior_updates() {
724-
let announced_update_input = vec![
724+
let announced_update_input = [
725725
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
726726
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167,
727727
0, 0, 0, 4, 2, 22, 7, 207, 206, 25, 164, 197, 231, 230, 231, 56, 102, 61, 250, 251,
@@ -749,7 +749,7 @@ mod tests {
749749
#[test]
750750
#[cfg(feature = "std")]
751751
fn incremental_only_update_fails_without_prior_same_direction_updates() {
752-
let initialization_input = vec![
752+
let initialization_input = [
753753
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
754754
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218,
755755
0, 0, 0, 4, 2, 22, 7, 207, 206, 25, 164, 197, 231, 230, 231, 56, 102, 61, 250, 251,
@@ -789,7 +789,7 @@ mod tests {
789789
assert!(initialized.contains("619737530008010752"));
790790
assert!(initialized.contains("783241506229452801"));
791791

792-
let opposite_direction_incremental_update_input = vec![
792+
let opposite_direction_incremental_update_input = [
793793
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
794794
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167,
795795
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -802,7 +802,7 @@ mod tests {
802802
#[test]
803803
#[cfg(feature = "std")]
804804
fn incremental_update_succeeds_with_prior_announcements_and_full_updates() {
805-
let initialization_input = vec![
805+
let initialization_input = [
806806
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
807807
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218,
808808
0, 0, 0, 4, 2, 22, 7, 207, 206, 25, 164, 197, 231, 230, 231, 56, 102, 61, 250, 251,
@@ -829,7 +829,7 @@ mod tests {
829829
let initialization_result = rapid_sync.update_network_graph(&initialization_input[..]);
830830
assert!(initialization_result.is_ok());
831831

832-
let single_direction_incremental_update_input = vec![
832+
let single_direction_incremental_update_input = [
833833
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
834834
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167,
835835
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -863,7 +863,7 @@ mod tests {
863863
#[test]
864864
#[cfg(feature = "std")]
865865
fn update_succeeds_when_duplicate_gossip_is_applied() {
866-
let initialization_input = vec![
866+
let initialization_input = [
867867
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
868868
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218,
869869
0, 0, 0, 4, 2, 22, 7, 207, 206, 25, 164, 197, 231, 230, 231, 56, 102, 61, 250, 251,
@@ -890,7 +890,7 @@ mod tests {
890890
let initialization_result = rapid_sync.update_network_graph(&initialization_input[..]);
891891
assert!(initialization_result.is_ok());
892892

893-
let single_direction_incremental_update_input = vec![
893+
let single_direction_incremental_update_input = [
894894
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
895895
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167,
896896
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -1023,7 +1023,7 @@ mod tests {
10231023
#[test]
10241024
#[cfg(feature = "std")]
10251025
pub fn update_fails_with_unknown_version() {
1026-
let unknown_version_input = vec![
1026+
let unknown_version_input = [
10271027
76, 68, 75, 3, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
10281028
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218,
10291029
0, 0, 0, 4, 2, 22, 7, 207, 206, 25, 164, 197, 231, 230, 231, 56, 102, 61, 250, 251,

lightning/src/chain/channelmonitor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6260,7 +6260,7 @@ mod tests {
62606260
value: Amount::ZERO,
62616261
});
62626262
let base_weight = claim_tx.weight().to_wu();
6263-
let inputs_weight = vec![WEIGHT_REVOKED_OUTPUT, weight_revoked_offered_htlc(channel_type_features), weight_revoked_offered_htlc(channel_type_features), weight_revoked_received_htlc(channel_type_features)];
6263+
let inputs_weight = [WEIGHT_REVOKED_OUTPUT, weight_revoked_offered_htlc(channel_type_features), weight_revoked_offered_htlc(channel_type_features), weight_revoked_received_htlc(channel_type_features)];
62646264
let mut inputs_total_weight = 2; // count segwit flags
62656265
{
62666266
let mut sighash_parts = sighash::SighashCache::new(&mut claim_tx);
@@ -6292,7 +6292,7 @@ mod tests {
62926292
value: Amount::ZERO,
62936293
});
62946294
let base_weight = claim_tx.weight().to_wu();
6295-
let inputs_weight = vec![weight_offered_htlc(channel_type_features), weight_received_htlc(channel_type_features), weight_received_htlc(channel_type_features), weight_received_htlc(channel_type_features)];
6295+
let inputs_weight = [weight_offered_htlc(channel_type_features), weight_received_htlc(channel_type_features), weight_received_htlc(channel_type_features), weight_received_htlc(channel_type_features)];
62966296
let mut inputs_total_weight = 2; // count segwit flags
62976297
{
62986298
let mut sighash_parts = sighash::SighashCache::new(&mut claim_tx);
@@ -6322,7 +6322,7 @@ mod tests {
63226322
value: Amount::ZERO,
63236323
});
63246324
let base_weight = claim_tx.weight().to_wu();
6325-
let inputs_weight = vec![WEIGHT_REVOKED_OUTPUT];
6325+
let inputs_weight = [WEIGHT_REVOKED_OUTPUT];
63266326
let mut inputs_total_weight = 2; // count segwit flags
63276327
{
63286328
let mut sighash_parts = sighash::SighashCache::new(&mut claim_tx);

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
747747

748748
if intercept_node_fails {
749749
nodes[1].node.fail_intercepted_htlc(intercept_id).unwrap();
750-
expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(nodes[1], vec![HTLCHandlingFailureType::InvalidForward { requested_forward_scid: intercept_scid }]);
750+
expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(nodes[1], [HTLCHandlingFailureType::InvalidForward { requested_forward_scid: intercept_scid }]);
751751
nodes[1].node.process_pending_htlc_forwards();
752752
check_added_monitors!(&nodes[1], 1);
753753
fail_blinded_htlc_backwards(payment_hash, 1, &[&nodes[0], &nodes[1]], false);
@@ -1046,7 +1046,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10461046
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event_1_2.commitment_msg, true, true);
10471047
expect_pending_htlcs_forwardable!(nodes[2]);
10481048
expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(nodes[2],
1049-
vec![HTLCHandlingFailureType::Receive { payment_hash }]);
1049+
[HTLCHandlingFailureType::Receive { payment_hash }]);
10501050
check_added_monitors!(nodes[2], 1);
10511051
},
10521052
ReceiveCheckFail::PaymentConstraints => {

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15935,7 +15935,7 @@ mod tests {
1593515935
check_added_monitors!(nodes[1], 0);
1593615936
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
1593715937
expect_pending_htlcs_forwardable!(nodes[1]);
15938-
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }]);
15938+
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }]);
1593915939
check_added_monitors!(nodes[1], 1);
1594015940
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
1594115941
assert!(updates.update_add_htlcs.is_empty());
@@ -16155,7 +16155,7 @@ mod tests {
1615516155
// We have to forward pending HTLCs twice - once tries to forward the payment forward (and
1615616156
// fails), the second will process the resulting failure and fail the HTLC backward
1615716157
expect_pending_htlcs_forwardable!(nodes[1]);
16158-
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Receive { payment_hash }]);
16158+
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Receive { payment_hash }]);
1615916159
check_added_monitors!(nodes[1], 1);
1616016160
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
1616116161
assert!(updates.update_add_htlcs.is_empty());
@@ -16200,7 +16200,7 @@ mod tests {
1620016200
check_added_monitors!(nodes[1], 0);
1620116201
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
1620216202
expect_pending_htlcs_forwardable!(nodes[1]);
16203-
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Receive { payment_hash }]);
16203+
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Receive { payment_hash }]);
1620416204
check_added_monitors!(nodes[1], 1);
1620516205
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
1620616206
assert!(updates.update_add_htlcs.is_empty());
@@ -16247,7 +16247,7 @@ mod tests {
1624716247
check_added_monitors!(nodes[1], 0);
1624816248
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
1624916249
expect_pending_htlcs_forwardable!(nodes[1]);
16250-
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Receive { payment_hash }]);
16250+
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Receive { payment_hash }]);
1625116251
check_added_monitors!(nodes[1], 1);
1625216252
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
1625316253
assert!(updates.update_add_htlcs.is_empty());

lightning/src/ln/functional_test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,7 +2168,7 @@ pub fn do_commitment_signed_dance(node_a: &Node<'_, '_, '_>, node_b: &Node<'_, '
21682168

21692169
if fail_backwards {
21702170
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(node_a,
2171-
vec![crate::events::HTLCHandlingFailureType::Forward{ node_id: Some(node_b.node.get_our_node_id()), channel_id }]);
2171+
[crate::events::HTLCHandlingFailureType::Forward{ node_id: Some(node_b.node.get_our_node_id()), channel_id }]);
21722172
check_added_monitors!(node_a, 1);
21732173

21742174
let node_a_per_peer_state = node_a.node.per_peer_state.read().unwrap();
@@ -3243,7 +3243,7 @@ pub fn pass_failed_payment_back<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expe
32433243
node.node.handle_update_fail_htlc(prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
32443244
commitment_signed_dance!(node, prev_node, next_msgs.as_ref().unwrap().1, update_next_node);
32453245
if !update_next_node {
3246-
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(node, vec![HTLCHandlingFailureType::Forward { node_id: Some(prev_node.node.get_our_node_id()), channel_id: next_msgs.as_ref().unwrap().0.channel_id }]);
3246+
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(node, [HTLCHandlingFailureType::Forward { node_id: Some(prev_node.node.get_our_node_id()), channel_id: next_msgs.as_ref().unwrap().0.channel_id }]);
32473247
}
32483248
}
32493249
let events = node.node.get_and_clear_pending_msg_events();

0 commit comments

Comments
 (0)