diff --git a/ci/check-lint.sh b/ci/check-lint.sh index cd013dfd17e..2f16210e22c 100755 --- a/ci/check-lint.sh +++ b/ci/check-lint.sh @@ -110,4 +110,4 @@ CLIPPY() { CLIPPY # We allow some additional warnings in tests which we should fix, but which aren't currently a priority -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" +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" diff --git a/lightning-rapid-gossip-sync/src/processing.rs b/lightning-rapid-gossip-sync/src/processing.rs index 708d54160eb..2a4fb6de345 100644 --- a/lightning-rapid-gossip-sync/src/processing.rs +++ b/lightning-rapid-gossip-sync/src/processing.rs @@ -503,7 +503,7 @@ mod tests { let logger = TestLogger::new(); let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); - let example_input = vec![ + let example_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218, 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 { let logger = TestLogger::new(); let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); - let example_input = vec![ + let example_input = [ 76, 68, 75, 2, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 102, 97, 206, 240, 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 { let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); let rapid_sync = RapidGossipSync::new(&network_graph, &logger); - let example_input = vec![ + let example_input = [ 76, 68, 75, 2, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 102, 105, 183, 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 { let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); let rapid_sync = RapidGossipSync::new(&network_graph, &logger); - let example_input = vec![ + let example_input = [ 76, 68, 75, 2, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 102, 106, 12, 80, 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 { #[test] #[cfg(feature = "std")] fn incremental_only_update_ignores_missing_channel() { - let incremental_update_input = vec![ + let incremental_update_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167, 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 { #[test] #[cfg(feature = "std")] fn incremental_only_update_fails_without_prior_updates() { - let announced_update_input = vec![ + let announced_update_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167, 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 { #[test] #[cfg(feature = "std")] fn incremental_only_update_fails_without_prior_same_direction_updates() { - let initialization_input = vec![ + let initialization_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218, 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 { assert!(initialized.contains("619737530008010752")); assert!(initialized.contains("783241506229452801")); - let opposite_direction_incremental_update_input = vec![ + let opposite_direction_incremental_update_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167, 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 { #[test] #[cfg(feature = "std")] fn incremental_update_succeeds_with_prior_announcements_and_full_updates() { - let initialization_input = vec![ + let initialization_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218, 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 { let initialization_result = rapid_sync.update_network_graph(&initialization_input[..]); assert!(initialization_result.is_ok()); - let single_direction_incremental_update_input = vec![ + let single_direction_incremental_update_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167, 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 { #[test] #[cfg(feature = "std")] fn update_succeeds_when_duplicate_gossip_is_applied() { - let initialization_input = vec![ + let initialization_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218, 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 { let initialization_result = rapid_sync.update_network_graph(&initialization_input[..]); assert!(initialization_result.is_ok()); - let single_direction_incremental_update_input = vec![ + let single_direction_incremental_update_input = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167, 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 { #[test] #[cfg(feature = "std")] pub fn update_fails_with_unknown_version() { - let unknown_version_input = vec![ + let unknown_version_input = [ 76, 68, 75, 3, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218, 0, 0, 0, 4, 2, 22, 7, 207, 206, 25, 164, 197, 231, 230, 231, 56, 102, 61, 250, 251, diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index bfa5acc3bd5..5a4a94b1641 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -6260,7 +6260,7 @@ mod tests { value: Amount::ZERO, }); let base_weight = claim_tx.weight().to_wu(); - 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)]; + 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)]; let mut inputs_total_weight = 2; // count segwit flags { let mut sighash_parts = sighash::SighashCache::new(&mut claim_tx); @@ -6292,7 +6292,7 @@ mod tests { value: Amount::ZERO, }); let base_weight = claim_tx.weight().to_wu(); - 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)]; + 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)]; let mut inputs_total_weight = 2; // count segwit flags { let mut sighash_parts = sighash::SighashCache::new(&mut claim_tx); @@ -6322,7 +6322,7 @@ mod tests { value: Amount::ZERO, }); let base_weight = claim_tx.weight().to_wu(); - let inputs_weight = vec![WEIGHT_REVOKED_OUTPUT]; + let inputs_weight = [WEIGHT_REVOKED_OUTPUT]; let mut inputs_total_weight = 2; // count segwit flags { let mut sighash_parts = sighash::SighashCache::new(&mut claim_tx); diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs index d65fa53a544..4a868e0eb76 100644 --- a/lightning/src/ln/blinded_payment_tests.rs +++ b/lightning/src/ln/blinded_payment_tests.rs @@ -747,7 +747,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) { if intercept_node_fails { nodes[1].node.fail_intercepted_htlc(intercept_id).unwrap(); - expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(nodes[1], vec![HTLCHandlingFailureType::InvalidForward { requested_forward_scid: intercept_scid }]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(nodes[1], [HTLCHandlingFailureType::InvalidForward { requested_forward_scid: intercept_scid }]); nodes[1].node.process_pending_htlc_forwards(); check_added_monitors!(&nodes[1], 1); fail_blinded_htlc_backwards(payment_hash, 1, &[&nodes[0], &nodes[1]], false); @@ -1046,7 +1046,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) { do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event_1_2.commitment_msg, true, true); expect_pending_htlcs_forwardable!(nodes[2]); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(nodes[2], - vec![HTLCHandlingFailureType::Receive { payment_hash }]); + [HTLCHandlingFailureType::Receive { payment_hash }]); check_added_monitors!(nodes[2], 1); }, ReceiveCheckFail::PaymentConstraints => { diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 9e7031bf8cb..5c39d503a6b 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -15935,7 +15935,7 @@ mod tests { check_added_monitors!(nodes[1], 0); commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false); expect_pending_htlcs_forwardable!(nodes[1]); - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }]); check_added_monitors!(nodes[1], 1); let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); assert!(updates.update_add_htlcs.is_empty()); @@ -16155,7 +16155,7 @@ mod tests { // We have to forward pending HTLCs twice - once tries to forward the payment forward (and // fails), the second will process the resulting failure and fail the HTLC backward expect_pending_htlcs_forwardable!(nodes[1]); - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Receive { payment_hash }]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Receive { payment_hash }]); check_added_monitors!(nodes[1], 1); let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); assert!(updates.update_add_htlcs.is_empty()); @@ -16200,7 +16200,7 @@ mod tests { check_added_monitors!(nodes[1], 0); commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false); expect_pending_htlcs_forwardable!(nodes[1]); - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Receive { payment_hash }]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Receive { payment_hash }]); check_added_monitors!(nodes[1], 1); let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); assert!(updates.update_add_htlcs.is_empty()); @@ -16247,7 +16247,7 @@ mod tests { check_added_monitors!(nodes[1], 0); commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false); expect_pending_htlcs_forwardable!(nodes[1]); - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Receive { payment_hash }]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Receive { payment_hash }]); check_added_monitors!(nodes[1], 1); let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); assert!(updates.update_add_htlcs.is_empty()); diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 79219857b0e..c680dc94486 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -2168,7 +2168,7 @@ pub fn do_commitment_signed_dance(node_a: &Node<'_, '_, '_>, node_b: &Node<'_, ' if fail_backwards { expect_pending_htlcs_forwardable_and_htlc_handling_failed!(node_a, - vec![crate::events::HTLCHandlingFailureType::Forward{ node_id: Some(node_b.node.get_our_node_id()), channel_id }]); + [crate::events::HTLCHandlingFailureType::Forward{ node_id: Some(node_b.node.get_our_node_id()), channel_id }]); check_added_monitors!(node_a, 1); 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 node.node.handle_update_fail_htlc(prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0); commitment_signed_dance!(node, prev_node, next_msgs.as_ref().unwrap().1, update_next_node); if !update_next_node { - 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 }]); + 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 }]); } } let events = node.node.get_and_clear_pending_msg_events(); diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 60aa21bc44e..8ca290ef165 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -873,7 +873,7 @@ fn do_test_fail_back_before_backwards_timeout(post_fail_back_action: PostFailBac // Check that nodes[1] fails the HTLC upstream expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] ); check_added_monitors(&nodes[1], 1); let htlc_updates = get_htlc_update_msgs(&nodes[1], &node_a_id); @@ -894,7 +894,7 @@ fn do_test_fail_back_before_backwards_timeout(post_fail_back_action: PostFailBac // Expect handling another fail back event, but the HTLC is already gone expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] @@ -923,7 +923,7 @@ fn do_test_fail_back_before_backwards_timeout(post_fail_back_action: PostFailBac nodes[2].node.fail_htlc_backwards(&payment_hash); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[2], - vec![HTLCHandlingFailureType::Receive { payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash }] ); check_added_monitors(&nodes[2], 1); let commitment_update = get_htlc_update_msgs(&nodes[2], &node_b_id); @@ -2104,7 +2104,7 @@ fn do_test_htlc_on_chain_timeout(connect_style: ConnectStyle) { check_added_monitors(&nodes[2], 0); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[2], - vec![HTLCHandlingFailureType::Receive { payment_hash: payment_hash.clone() }] + [HTLCHandlingFailureType::Receive { payment_hash: payment_hash.clone() }] ); check_added_monitors(&nodes[2], 1); @@ -2181,7 +2181,7 @@ fn do_test_htlc_on_chain_timeout(connect_style: ConnectStyle) { expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] ); check_added_monitors(&nodes[1], 1); let events = nodes[1].node.get_and_clear_pending_msg_events(); @@ -2269,7 +2269,7 @@ pub fn test_simple_commitment_revoked_fail_backward() { expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] ); check_added_monitors(&nodes[1], 1); let events = nodes[1].node.get_and_clear_pending_msg_events(); @@ -2362,7 +2362,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive( nodes[2].node.fail_htlc_backwards(&first_payment_hash); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[2], - vec![HTLCHandlingFailureType::Receive { payment_hash: first_payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash: first_payment_hash }] ); check_added_monitors(&nodes[2], 1); let updates = get_htlc_update_msgs!(nodes[2], node_b_id); @@ -2379,7 +2379,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive( nodes[2].node.fail_htlc_backwards(&second_payment_hash); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[2], - vec![HTLCHandlingFailureType::Receive { payment_hash: second_payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash: second_payment_hash }] ); check_added_monitors(&nodes[2], 1); let updates = get_htlc_update_msgs!(nodes[2], node_b_id); @@ -2399,7 +2399,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive( nodes[2].node.fail_htlc_backwards(&third_payment_hash); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[2], - vec![HTLCHandlingFailureType::Receive { payment_hash: third_payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash: third_payment_hash }] ); check_added_monitors(&nodes[2], 1); let updates = get_htlc_update_msgs!(nodes[2], node_b_id); @@ -3720,7 +3720,7 @@ fn do_test_htlc_timeout(send_partial_mpp: bool) { expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }] ); check_added_monitors(&nodes[1], 1); @@ -4584,7 +4584,7 @@ pub fn test_duplicate_payment_hash_one_failure_one_success() { connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] ); let htlc_updates = get_htlc_update_msgs!(nodes[1], node_a_id); assert!(htlc_updates.update_add_htlcs.is_empty()); @@ -5406,7 +5406,7 @@ fn do_htlc_claim_previous_remote_commitment_only(use_dust: bool, check_revoke_no nodes[1].node.fail_htlc_backwards(&our_payment_hash); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }] ); check_added_monitors(&nodes[1], 1); @@ -6055,7 +6055,7 @@ pub fn test_update_fulfill_htlc_bolt2_after_malformed_htlc_message_must_forward_ commitment_signed_dance!(nodes[1], nodes[2], update_msg.1, false, true); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] ); let events_4 = nodes[1].node.get_and_clear_pending_msg_events(); assert_eq!(events_4.len(), 1); @@ -6147,7 +6147,7 @@ pub fn test_channel_failed_after_message_with_badonion_node_perm_bits_set() { expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }] ); let events_4 = nodes[1].node.get_and_clear_pending_msg_events(); assert_eq!(events_4.len(), 1); @@ -6229,7 +6229,7 @@ fn do_test_failure_delay_dust_htlc_local_commitment(announce_latest: bool) { check_added_monitors(&nodes[1], 0); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash: payment_hash_2 }] + [HTLCHandlingFailureType::Receive { payment_hash: payment_hash_2 }] ); check_added_monitors(&nodes[1], 1); @@ -6595,7 +6595,7 @@ pub fn test_check_htlc_underpaying() { expect_pending_htlcs_forwardable!(nodes[1]); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }] ); // Node 3 is expecting payment of 100_000 but received 10_000, @@ -7250,7 +7250,7 @@ pub fn test_bump_txn_sanitize_tracking_maps() { connect_blocks(&nodes[0], TEST_FINAL_CLTV + 2 - CHAN_CONFIRM_DEPTH); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!( nodes[0], - vec![HTLCHandlingFailureType::Receive { payment_hash: payment_hash_2 }] + [HTLCHandlingFailureType::Receive { payment_hash: payment_hash_2 }] ); assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 0); @@ -9442,7 +9442,7 @@ fn do_test_tx_confirmed_skipping_blocks_immediate_broadcast(test_height_before_t ); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id }] ); check_added_monitors(&nodes[1], 1); @@ -9472,7 +9472,7 @@ fn do_test_tx_confirmed_skipping_blocks_immediate_broadcast(test_height_before_t // spurious HTLCHandlingFailed event. expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id }] ); } } @@ -9580,7 +9580,7 @@ fn do_test_dup_htlc_second_rejected(test_for_second_fail_panic: bool) { // Let the second HTLC fail and claim the first expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }] ); nodes[1].node.process_pending_htlc_forwards(); @@ -9722,7 +9722,7 @@ pub fn test_inconsistent_mpp_params() { expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[2], - vec![HTLCHandlingFailureType::Forward { node_id: Some(node_d_id), channel_id: chan_2_3.2 }] + [HTLCHandlingFailureType::Forward { node_id: Some(node_d_id), channel_id: chan_2_3.2 }] ); check_added_monitors(&nodes[2], 1); diff --git a/lightning/src/ln/htlc_reserve_unit_tests.rs b/lightning/src/ln/htlc_reserve_unit_tests.rs index 111e0b404de..4f1f5c581df 100644 --- a/lightning/src/ln/htlc_reserve_unit_tests.rs +++ b/lightning/src/ln/htlc_reserve_unit_tests.rs @@ -676,7 +676,7 @@ pub fn holding_cell_htlc_counting() { // fails), the second will process the resulting failure and fail the HTLC backward. expect_pending_htlcs_forwardable!(nodes[1]); let fail = HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }; - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![fail]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [fail]); check_added_monitors(&nodes[1], 1); let bs_fail_updates = get_htlc_update_msgs!(nodes[1], node_a_id); @@ -768,7 +768,7 @@ pub fn test_basic_channel_reserve() { unwrap_send_err!(nodes[0], err, true, APIError::ChannelUnavailable { .. }, {}); assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty()); - send_payment(&nodes[0], &vec![&nodes[1]], max_can_send); + send_payment(&nodes[0], &[&nodes[1]], max_can_send); } #[xtest(feature = "_externalize_tests")] diff --git a/lightning/src/ln/interactivetxs.rs b/lightning/src/ln/interactivetxs.rs index ee991a0ae8c..a1c3c8fcf94 100644 --- a/lightning/src/ln/interactivetxs.rs +++ b/lightning/src/ln/interactivetxs.rs @@ -2730,7 +2730,7 @@ mod tests { #[test] fn test_calculate_change_output_value_open() { - let input_prevouts = vec![ + let input_prevouts = [ TxOut { value: Amount::from_sat(70_000), script_pubkey: ScriptBuf::new() }, TxOut { value: Amount::from_sat(60_000), script_pubkey: ScriptBuf::new() }, ]; diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index cdcb570af68..0a89899f118 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -89,7 +89,7 @@ fn chanmon_fail_from_stale_commitment() { assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty()); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1); - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Forward { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_id_2 }]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Forward { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_id_2 }]); check_added_monitors!(nodes[1], 1); let fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); @@ -2997,7 +2997,7 @@ fn test_anchors_aggregated_revoked_htlc_tx() { for event in spendable_output_events { if let Event::SpendableOutputs { outputs, channel_id } = event { assert_eq!(outputs.len(), 1); - assert!(vec![chan_b.2, chan_a.2].contains(&channel_id.unwrap())); + assert!([chan_b.2, chan_a.2].contains(&channel_id.unwrap())); let spend_tx = nodes[0].keys_manager.backing.spend_spendable_outputs( &[&outputs[0]], Vec::new(), ScriptBuf::new_op_return(&[]), 253, None, &Secp256k1::new(), ).unwrap(); diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index c3913d31e9c..2cf7e109eb1 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -5298,7 +5298,7 @@ mod tests { previous_output: OutPoint { txid: Txid::from_str("305bab643ee297b8b6b76b320792c8223d55082122cb606bf89382146ced9c77").unwrap(), index: 2 }.into_bitcoin_outpoint(), script_sig: ScriptBuf::new(), sequence: Sequence(0xfffffffd), - witness: Witness::from_slice(&vec![ + witness: Witness::from_slice(&[ >::from_hex("304402206af85b7dd67450ad12c979302fac49dfacbc6a8620f49c5da2b5721cf9565ca502207002b32fed9ce1bf095f57aeb10c36928ac60b12e723d97d2964a54640ceefa701").unwrap(), >::from_hex("0301ab7dc16488303549bfcdd80f6ae5ee4c20bf97ab5410bbd6b1bfa85dcd6944").unwrap()]), }], @@ -5390,10 +5390,10 @@ mod tests { channel_id: ChannelId::from_bytes([2; 32]), tx_hash: Txid::from_str("c2d4449afa8d26140898dd54d3390b057ba2a5afcf03ba29d7dc0d8b9ffe966e").unwrap(), witnesses: vec![ - Witness::from_slice(&vec![ + Witness::from_slice(&[ >::from_hex("304402206af85b7dd67450ad12c979302fac49dfacbc6a8620f49c5da2b5721cf9565ca502207002b32fed9ce1bf095f57aeb10c36928ac60b12e723d97d2964a54640ceefa701").unwrap(), >::from_hex("0301ab7dc16488303549bfcdd80f6ae5ee4c20bf97ab5410bbd6b1bfa85dcd6944").unwrap()]), - Witness::from_slice(&vec![ + Witness::from_slice(&[ >::from_hex("3045022100ee00dbf4a862463e837d7c08509de814d620e4d9830fa84818713e0fa358f145022021c3c7060c4d53fe84fd165d60208451108a778c13b92ca4c6bad439236126cc01").unwrap(), >::from_hex("028fbbf0b16f5ba5bcb5dd37cd4047ce6f726a21c06682f9ec2f52b057de1dbdb5").unwrap()]), ], diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index 0612b9abe58..416a4e130a9 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -190,16 +190,14 @@ fn run_onion_failure_test_with_fail_intercept( callback_node(); expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[2], - vec![HTLCHandlingFailureType::Receive { - payment_hash: payment_hash.clone() - }] + [HTLCHandlingFailureType::Receive { payment_hash: *payment_hash }] ); }, 1 | 3 => { expect_htlc_forward!(&nodes[2]); expect_htlc_handling_failed_destinations!( nodes[2].node.get_and_clear_pending_events(), - vec![expected_failure_type.clone().unwrap()] + [expected_failure_type.clone().unwrap()] ); }, _ => {}, @@ -2299,7 +2297,7 @@ fn do_test_fail_htlc_backwards_with_reason(failure_code: FailureCode) { expect_pending_htlcs_forwardable_and_htlc_handling_failed!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash }] ); check_added_monitors!(nodes[1], 1); @@ -2466,7 +2464,7 @@ fn test_phantom_onion_hmac_failure() { nodes[1].node.process_pending_htlc_forwards(); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash }] ); nodes[1].node.process_pending_htlc_forwards(); let update_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); @@ -2567,7 +2565,7 @@ fn test_phantom_invalid_onion_payload() { nodes[1].node.process_pending_htlc_forwards(); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash }] ); nodes[1].node.process_pending_htlc_forwards(); let update_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); @@ -2633,7 +2631,7 @@ fn test_phantom_final_incorrect_cltv_expiry() { nodes[1].node.process_pending_htlc_forwards(); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash }] ); nodes[1].node.process_pending_htlc_forwards(); let update_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); @@ -2687,7 +2685,7 @@ fn test_phantom_failure_too_low_cltv() { nodes[1].node.process_pending_htlc_forwards(); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash }] ); nodes[1].node.process_pending_htlc_forwards(); let update_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); @@ -2847,7 +2845,7 @@ fn test_phantom_failure_too_low_recv_amt() { nodes[1].node.process_pending_htlc_forwards(); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash: payment_hash.clone() }] + [HTLCHandlingFailureType::Receive { payment_hash: payment_hash.clone() }] ); nodes[1].node.process_pending_htlc_forwards(); let update_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); @@ -2976,7 +2974,7 @@ fn test_phantom_failure_reject_payment() { nodes[1].node.fail_htlc_backwards(&payment_hash); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!( nodes[1], - vec![HTLCHandlingFailureType::Receive { payment_hash }] + [HTLCHandlingFailureType::Receive { payment_hash }] ); nodes[1].node.process_pending_htlc_forwards(); diff --git a/lightning/src/ln/priv_short_conf_tests.rs b/lightning/src/ln/priv_short_conf_tests.rs index 3715b9fc13f..8da1f98c6a9 100644 --- a/lightning/src/ln/priv_short_conf_tests.rs +++ b/lightning/src/ln/priv_short_conf_tests.rs @@ -507,7 +507,7 @@ fn test_scid_alias_returned() { commitment_signed_dance!(nodes[1], nodes[0], &as_updates.commitment_signed, false, true); expect_pending_htlcs_forwardable!(nodes[1]); - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Forward { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan.0.channel_id }]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Forward { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan.0.channel_id }]); check_added_monitors!(nodes[1], 1); let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); diff --git a/lightning/src/ln/quiescence_tests.rs b/lightning/src/ln/quiescence_tests.rs index 82aa0208c67..99342cb970f 100644 --- a/lightning/src/ln/quiescence_tests.rs +++ b/lightning/src/ln/quiescence_tests.rs @@ -384,7 +384,7 @@ fn quiescence_updates_go_to_holding_cell(fail_htlc: bool) { if fail_htlc { nodes[1].node.fail_htlc_backwards(&payment_hash2); let failed_payment = HTLCHandlingFailureType::Receive { payment_hash: payment_hash2 }; - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(&nodes[1], vec![failed_payment]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(&nodes[1], [failed_payment]); } else { nodes[1].node.claim_funds(payment_preimage2); check_added_monitors(&nodes[1], 1); @@ -434,7 +434,7 @@ fn quiescence_updates_go_to_holding_cell(fail_htlc: bool) { if fail_htlc { nodes[0].node.fail_htlc_backwards(&payment_hash1); let failed_payment = HTLCHandlingFailureType::Receive { payment_hash: payment_hash1 }; - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(&nodes[0], vec![failed_payment]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(&nodes[0], [failed_payment]); } else { nodes[0].node.claim_funds(payment_preimage1); } diff --git a/lightning/src/ln/reorg_tests.rs b/lightning/src/ln/reorg_tests.rs index 4d01956e60a..0ae3048215e 100644 --- a/lightning/src/ln/reorg_tests.rs +++ b/lightning/src/ln/reorg_tests.rs @@ -132,7 +132,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { } else { // Confirm the timeout tx and check that we fail the HTLC backwards connect_block(&nodes[1], &create_dummy_block(nodes[1].best_block_hash(), 42, Vec::new())); - expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCHandlingFailureType::Forward { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_2.2 }]); + expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCHandlingFailureType::Forward { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_2.2 }]); } check_added_monitors!(nodes[1], 1); diff --git a/lightning/src/ln/wire.rs b/lightning/src/ln/wire.rs index 32b1792a566..bd49bdd9eab 100644 --- a/lightning/src/ln/wire.rs +++ b/lightning/src/ln/wire.rs @@ -825,7 +825,7 @@ mod tests { #[test] fn read_lnd_node_announcement() { // Taken from lnd v0.9.0-beta. - let buffer = vec![ + let buffer = [ 1, 1, 91, 164, 146, 213, 213, 165, 21, 227, 102, 33, 105, 179, 214, 21, 221, 175, 228, 93, 57, 177, 191, 127, 107, 229, 31, 50, 21, 81, 179, 71, 39, 18, 35, 2, 89, 224, 110, 123, 66, 39, 148, 246, 177, 85, 12, 19, 70, 226, 173, 132, 156, 26, 122, 146, 71, 213, @@ -928,7 +928,7 @@ mod tests { #[test] fn read_custom_message() { - let buffer = vec![35, 40]; + let buffer = [35, 40]; let decoded_msg = read(&mut &buffer[..], &TestCustomMessageReader {}).unwrap(); match decoded_msg { Message::Custom(custom) => { @@ -941,7 +941,7 @@ mod tests { #[test] fn read_with_custom_reader_unknown_message_type() { - let buffer = vec![35, 42]; + let buffer = [35, 42]; let decoded_msg = read(&mut &buffer[..], &TestCustomMessageReader {}).unwrap(); match decoded_msg { Message::Unknown(_) => {}, diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index 3615850a22e..eacc2a8914b 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -2623,7 +2623,7 @@ mod tests { ), } - let empty_payment_paths = vec![]; + let empty_payment_paths = []; let mut tlv_stream = invoice.as_tlv_stream(); tlv_stream.3.paths = Some(Iterable(empty_payment_paths.iter().map(|path| path.inner_blinded_path()))); diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index c2d6484ccd6..82960a6b5d9 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -1764,8 +1764,8 @@ mod tests { #[test] fn bigsize_encoding_decoding() { - let values = vec![0, 252, 253, 65535, 65536, 4294967295, 4294967296, 18446744073709551615]; - let bytes = vec![ + let values = [0, 252, 253, 65535, 65536, 4294967295, 4294967296, 18446744073709551615]; + let bytes = [ "00", "fc", "fd00fd", @@ -1782,7 +1782,7 @@ mod tests { super::BigSize(values[i]).write(&mut stream).unwrap(); assert_eq!(stream.0, >::from_hex(bytes[i]).unwrap()); } - let err_bytes = vec![ + let err_bytes = [ "fd00fc", "fe0000ffff", "ff00000000ffffffff",