Skip to content

Commit 1bbc692

Browse files
committed
Remove commitment_signed_dance macro
Replace last `commitment_signed_dance` calls with `commitment_signed_dance_return_raa`.
1 parent 021d503 commit 1bbc692

File tree

5 files changed

+24
-30
lines changed

5 files changed

+24
-30
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ fn test_monitor_update_fail_no_rebroadcast() {
857857
SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
858858
nodes[1].node.handle_update_add_htlc(node_a_id, &send_event.msgs[0]);
859859
let commitment = send_event.commitment_msg;
860-
let bs_raa = commitment_signed_dance!(nodes[1], nodes[0], commitment, false, true, false, true);
860+
let bs_raa = commitment_signed_dance_return_raa(&nodes[1], &nodes[0], &commitment, false);
861861

862862
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
863863
nodes[1].node.handle_revoke_and_ack(node_a_id, &bs_raa);
@@ -1006,7 +1006,7 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
10061006

10071007
let commitment = updates.commitment_signed;
10081008
let bs_revoke_and_ack =
1009-
commitment_signed_dance!(nodes[1], nodes[2], commitment, false, true, false, true);
1009+
commitment_signed_dance_return_raa(&nodes[1], &nodes[2], &commitment, false);
10101010
check_added_monitors!(nodes[0], 0);
10111011

10121012
// While the second channel is AwaitingRAA, forward a second payment to get it into the
@@ -2084,7 +2084,7 @@ fn monitor_update_claim_fail_no_response() {
20842084
let payment_event = SendEvent::from_event(events.pop().unwrap());
20852085
nodes[1].node.handle_update_add_htlc(node_a_id, &payment_event.msgs[0]);
20862086
let commitment = payment_event.commitment_msg;
2087-
let as_raa = commitment_signed_dance!(nodes[1], nodes[0], commitment, false, true, false, true);
2087+
let as_raa = commitment_signed_dance_return_raa(&nodes[1], &nodes[0], &commitment, false);
20882088

20892089
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
20902090
nodes[1].node.claim_funds(payment_preimage_1);

lightning/src/ln/functional_test_utils.rs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,29 +2640,6 @@ pub fn expect_htlc_forwarding_fails(
26402640
expect_htlc_failure_conditions(events, expected_failure);
26412641
}
26422642

2643-
#[macro_export]
2644-
/// Performs the "commitment signed dance" - the series of message exchanges which occur after a
2645-
/// commitment update.
2646-
macro_rules! commitment_signed_dance {
2647-
($node_a: expr, $node_b: expr, $commitment_signed: expr, $fail_backwards: expr, true /* skip last step */, false /* return extra message */, true /* return last RAA */) => {{
2648-
$crate::ln::functional_test_utils::check_added_monitors(&$node_a, 0);
2649-
assert!($node_a.node.get_and_clear_pending_msg_events().is_empty());
2650-
$node_a.node.handle_commitment_signed_batch_test(
2651-
$node_b.node.get_our_node_id(),
2652-
&$commitment_signed,
2653-
);
2654-
check_added_monitors(&$node_a, 1);
2655-
let (extra_msg_option, bs_revoke_and_ack) =
2656-
$crate::ln::functional_test_utils::do_main_commitment_signed_dance(
2657-
&$node_a,
2658-
&$node_b,
2659-
$fail_backwards,
2660-
);
2661-
assert!(extra_msg_option.is_none());
2662-
bs_revoke_and_ack
2663-
}};
2664-
}
2665-
26662643
/// Runs the commitment_signed dance after the initial commitment_signed is delivered through to
26672644
/// the initiator's `revoke_and_ack` response. i.e. [`do_main_commitment_signed_dance`] plus the
26682645
/// `revoke_and_ack` response to it.
@@ -2724,6 +2701,22 @@ pub fn do_main_commitment_signed_dance(
27242701
(extra_msg_option, bs_revoke_and_ack)
27252702
}
27262703

2704+
pub fn commitment_signed_dance_return_raa(
2705+
node_a: &Node<'_, '_, '_>, node_b: &Node<'_, '_, '_>,
2706+
commitment_signed: &Vec<msgs::CommitmentSigned>, fail_backwards: bool,
2707+
) -> msgs::RevokeAndACK {
2708+
check_added_monitors(&node_a, 0);
2709+
assert!(node_a.node.get_and_clear_pending_msg_events().is_empty());
2710+
node_a
2711+
.node
2712+
.handle_commitment_signed_batch_test(node_b.node.get_our_node_id(), commitment_signed);
2713+
check_added_monitors(&node_a, 1);
2714+
let (extra_msg_option, bs_revoke_and_ack) =
2715+
do_main_commitment_signed_dance(&node_a, &node_b, fail_backwards);
2716+
assert!(extra_msg_option.is_none());
2717+
bs_revoke_and_ack
2718+
}
2719+
27272720
/// Runs a full commitment_signed dance, delivering a commitment_signed, the responding
27282721
/// `revoke_and_ack` and `commitment_signed`, and then the final `revoke_and_ack` response.
27292722
///

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(
19351935
assert!(updates.update_fee.is_none());
19361936
nodes[1].node.handle_update_fail_htlc(node_c_id, &updates.update_fail_htlcs[0]);
19371937
let cs = updates.commitment_signed;
1938-
let bs_raa = commitment_signed_dance!(nodes[1], nodes[2], cs, false, true, false, true);
1938+
let bs_raa = commitment_signed_dance_return_raa(&nodes[1], &nodes[2], &cs, false);
19391939
// Drop the last RAA from 3 -> 2
19401940

19411941
nodes[2].node.fail_htlc_backwards(&second_payment_hash);
@@ -4453,7 +4453,7 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
44534453
do_commitment_signed_dance(&nodes[2], &nodes[3], commitment, false, false);
44544454
} else {
44554455
let cs = six_removes.commitment_signed;
4456-
commitment_signed_dance!(nodes[2], nodes[3], cs, false, true, false, true);
4456+
commitment_signed_dance_return_raa(&nodes[2], &nodes[3], &cs, false);
44574457
}
44584458

44594459
// D's latest commitment transaction now contains 1st + 2nd + 9th HTLCs (implicitly, they're

lightning/src/ln/payment_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4066,7 +4066,7 @@ fn test_threaded_payment_retries() {
40664066
// `process_pending_htlc_forwards`. Instead, we defer the monitor update check until after
40674067
// *we've* called `process_pending_htlc_forwards` when its guaranteed to have two updates.
40684068
let cs = bs_fail_updates.commitment_signed;
4069-
let last_raa = commitment_signed_dance!(nodes[0], nodes[1], cs, false, true, false, true);
4069+
let last_raa = commitment_signed_dance_return_raa(&nodes[0], &nodes[1], &cs, false);
40704070
nodes[0].node.handle_revoke_and_ack(node_b_id, &last_raa);
40714071

40724072
let cur_time = Instant::now();

lightning/src/ln/reorg_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,8 @@ fn test_htlc_preimage_claim_prev_counterparty_commitment_after_current_counterpa
772772
// Handle the fee update on the other side, but don't send the last RAA such that the previous
773773
// commitment is still valid (unrevoked).
774774
nodes[1].node().handle_update_fee(nodes[0].node.get_our_node_id(), &update_fee);
775-
let _last_revoke_and_ack = commitment_signed_dance!(nodes[1], nodes[0], commit_sig, false, true, false, true);
775+
let _last_revoke_and_ack = commitment_signed_dance_return_raa(&nodes[1], &nodes[0], &commit_sig, false);
776+
776777
let message = "Channel force-closed".to_owned();
777778

778779
// Force close with the latest commitment, confirm it, and reorg it with the previous commitment.

0 commit comments

Comments
 (0)