Use `commitment_signed_dance_through_cp_raa` instead of macro
What changed, and why it matters
This commit is a small internal cleanup in the project's test code. It replaces a few uses of a test helper macro with a direct call to an equivalent helper function. There is no change to the actual Lightning node logic that runs in production, and nothing in the commit suggests a security fix or vulnerability.
No security action needed. Treat as a normal code-quality/test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors test-only code in rust-lightning. The commitment_signed_dance! macro had a branch that simply forwarded to commitment_signed_dance_through_cp_raa. The commit removes that macro branch and updates four call sites in test files to call commitment_signed_dance_through_cp_raa directly. The production behavior of the helper function is unchanged; only the call site syntax differs.
Changed components
lightning/src/ln/blinded_payment_tests.rslightning/src/ln/chanmon_update_fail_tests.rslightning/src/ln/functional_test_utils.rslightning/src/ln/shutdown_tests.rsInspect captured patch +6 / −14
diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs
index b92b958..cfb2878 100644
--- a/lightning/src/ln/blinded_payment_tests.rs
+++ b/lightning/src/ln/blinded_payment_tests.rs
@@ -1027,7 +1027,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
check_added_monitors!(nodes[2], 1);
nodes[2].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_shutdown);
- commitment_signed_dance!(nodes[2], nodes[1], (), false, true, false, false);
+ assert!(commitment_signed_dance_through_cp_raa(&nodes[2], &nodes[1], false, false).is_none());
expect_and_process_pending_htlcs(&nodes[2], false);
expect_htlc_handling_failed_destinations!(nodes[2].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash }]);
check_added_monitors(&nodes[2], 1);
diff --git a/lightning/src/ln/chanmon_update_fail_tests.rs b/lightning/src/ln/chanmon_update_fail_tests.rs
index 4f7a285..0e6568d 100644
--- a/lightning/src/ln/chanmon_update_fail_tests.rs
+++ b/lightning/src/ln/chanmon_update_fail_tests.rs
@@ -2826,8 +2826,7 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
expect_payment_claimable!(nodes[1], payment_hash_1, payment_secret_1, 100000);
check_added_monitors!(nodes[1], 1);
- commitment_signed_dance!(nodes[1], nodes[0], (), false, true, false, false);
-
+ assert!(commitment_signed_dance_through_cp_raa(&nodes[1], &nodes[0], false, false).is_none());
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index 8c786de..90cb43d 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -2661,15 +2661,6 @@ macro_rules! commitment_signed_dance {
assert!(extra_msg_option.is_none());
bs_revoke_and_ack
}};
- ($node_a: expr, $node_b: expr, (), $fail_backwards: expr, true /* skip last step */, false /* no extra message */, $incl_claim: expr) => {
- assert!($crate::ln::functional_test_utils::commitment_signed_dance_through_cp_raa(
- &$node_a,
- &$node_b,
- $fail_backwards,
- $incl_claim
- )
- .is_none());
- };
}
/// Runs the commitment_signed dance after the initial commitment_signed is delivered through to
@@ -2755,7 +2746,9 @@ pub fn do_commitment_signed_dance(
if fail_backwards {
assert!(!got_claim);
}
- commitment_signed_dance!(node_a, node_b, (), fail_backwards, true, false, got_claim);
+ assert!(
+ commitment_signed_dance_through_cp_raa(node_a, node_b, fail_backwards, got_claim).is_none()
+ );
if skip_last_step {
return;
diff --git a/lightning/src/ln/shutdown_tests.rs b/lightning/src/ln/shutdown_tests.rs
index 3df6c37..03f0702 100644
--- a/lightning/src/ln/shutdown_tests.rs
+++ b/lightning/src/ln/shutdown_tests.rs
@@ -566,7 +566,7 @@ fn do_htlc_fail_async_shutdown(blinded_recipient: bool) {
nodes[1].node.handle_commitment_signed_batch_test(node_a_id, &updates.commitment_signed);
check_added_monitors!(nodes[1], 1);
nodes[1].node.handle_shutdown(node_a_id, &node_0_shutdown);
- commitment_signed_dance!(nodes[1], nodes[0], (), false, true, false, false);
+ assert!(commitment_signed_dance_through_cp_raa(&nodes[1], &nodes[0], false, false).is_none());
expect_and_process_pending_htlcs(&nodes[1], false);
expect_htlc_handling_failed_destinations!(
nodes[1].node.get_and_clear_pending_events(),
Why this scored 15/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.