What changed, and why it matters
This commit only changes test code. It replaces a few instances of cloning a test value to make a single-element slice with a helper that borrows the value instead. This avoids an unnecessary clone in unit tests and has no effect on the production library or real Lightning node behavior.
No security action needed. Treat as routine test-code cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies three test functions in lightning/src/ln/blinded_payment_tests.rs and lightning/src/ln/payment_tests.rs. Each change replaces &[value.clone()] with core::slice::from_ref(&value). This is a code-quality/test cleanup change that removes redundant clones when the macro or helper only needs a borrowed slice. There are no changes to non-test source files, no cryptographic or network logic changes, and no runtime behavior change in production code.
Changed components
lightning/src/ln/blinded_payment_tests.rslightning/src/ln/payment_tests.rsInspect captured patch +8 / −5
diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs
index d72c816..0631db3 100644
--- a/lightning/src/ln/blinded_payment_tests.rs
+++ b/lightning/src/ln/blinded_payment_tests.rs
@@ -453,7 +453,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
HTLCHandlingFailureType::Forward { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_1_2.2 },
};
expect_htlc_handling_failed_destinations!(
- nodes[1].node.get_and_clear_pending_events(), &[failed_destination.clone()]
+ nodes[1].node.get_and_clear_pending_events(), core::slice::from_ref(&failed_destination)
);
match check {
ForwardCheckFail::ForwardPayloadEncodedAsReceive => {
@@ -484,7 +484,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
HTLCHandlingFailureType::Forward { node_id: Some(nodes[3].node.get_our_node_id()), channel_id: chan_2_3.2 },
};
expect_htlc_handling_failed_destinations!(
- nodes[2].node.get_and_clear_pending_events(), &[failed_destination.clone()]
+ nodes[2].node.get_and_clear_pending_events(), core::slice::from_ref(&failed_destination)
);
check_added_monitors!(nodes[2], 1);
diff --git a/lightning/src/ln/payment_tests.rs b/lightning/src/ln/payment_tests.rs
index b11294f..4c63bfa 100644
--- a/lightning/src/ln/payment_tests.rs
+++ b/lightning/src/ln/payment_tests.rs
@@ -3581,7 +3581,7 @@ fn no_extra_retries_on_back_to_back_fail() {
expect_and_process_pending_htlcs(&nodes[1], false);
expect_htlc_handling_failed_destinations!(
nodes[1].node.get_and_clear_pending_events(),
- &[next_hop_failure.clone()]
+ core::slice::from_ref(&next_hop_failure)
);
check_added_monitors(&nodes[1], 1);
@@ -3755,7 +3755,7 @@ fn test_simple_partial_retry() {
HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 };
expect_htlc_handling_failed_destinations!(
nodes[1].node.get_and_clear_pending_events(),
- &[next_hop_failure.clone()]
+ core::slice::from_ref(&next_hop_failure)
);
check_added_monitors(&nodes[1], 2);
@@ -4247,7 +4247,10 @@ fn do_claim_from_closed_chan(fail_payment: bool) {
// We fail the HTLC on the A->B->D path first as it expires 4 blocks earlier. We go ahead
// and expire both immediately, though, by connecting another 4 blocks.
let reason = HTLCHandlingFailureType::Receive { payment_hash: hash };
- expect_and_process_pending_htlcs_and_htlc_handling_failed(&nodes[3], &[reason.clone()]);
+ expect_and_process_pending_htlcs_and_htlc_handling_failed(
+ &nodes[3],
+ core::slice::from_ref(&reason),
+ );
connect_blocks(&nodes[3], 4);
expect_and_process_pending_htlcs_and_htlc_handling_failed(&nodes[3], &[reason]);
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.