Skip to content

Commit e841721

Browse files
committed
Test channel reestablish during splice lifecycle
This test captures all the new spec requirements introduced for a splice to the channel reestablish flow.
1 parent 0649f82 commit e841721

File tree

3 files changed

+377
-46
lines changed

3 files changed

+377
-46
lines changed

lightning/src/ln/async_signer_tests.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ fn do_test_async_raa_peer_disconnect(
600600
}
601601

602602
// Expect the RAA
603-
let (_, revoke_and_ack, commitment_signed, resend_order, _) =
603+
let (_, revoke_and_ack, commitment_signed, resend_order, _, _) =
604604
handle_chan_reestablish_msgs!(dst, src);
605605
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
606606
assert!(revoke_and_ack.is_none());
@@ -616,14 +616,15 @@ fn do_test_async_raa_peer_disconnect(
616616
dst.node.signer_unblocked(Some((src_node_id, chan_id)));
617617

618618
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
619-
let (_, revoke_and_ack, commitment_signed, resend_order, _) =
619+
let (_, revoke_and_ack, commitment_signed, resend_order, _, _) =
620620
handle_chan_reestablish_msgs!(dst, src);
621621
assert!(revoke_and_ack.is_some());
622622
assert!(commitment_signed.is_some());
623623
assert!(resend_order == RAACommitmentOrder::RevokeAndACKFirst);
624624
} else {
625625
// Make sure we don't double send the RAA.
626-
let (_, revoke_and_ack, commitment_signed, _, _) = handle_chan_reestablish_msgs!(dst, src);
626+
let (_, revoke_and_ack, commitment_signed, _, _, _) =
627+
handle_chan_reestablish_msgs!(dst, src);
627628
assert!(revoke_and_ack.is_none());
628629
assert!(commitment_signed.is_none());
629630
}
@@ -749,7 +750,7 @@ fn do_test_async_commitment_signature_peer_disconnect(
749750
}
750751

751752
// Expect the RAA
752-
let (_, revoke_and_ack, commitment_signed, _, _) = handle_chan_reestablish_msgs!(dst, src);
753+
let (_, revoke_and_ack, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
753754
assert!(revoke_and_ack.is_some());
754755
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
755756
assert!(commitment_signed.is_none());
@@ -762,11 +763,11 @@ fn do_test_async_commitment_signature_peer_disconnect(
762763
dst.node.signer_unblocked(Some((src_node_id, chan_id)));
763764

764765
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
765-
let (_, _, commitment_signed, _, _) = handle_chan_reestablish_msgs!(dst, src);
766+
let (_, _, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
766767
assert!(commitment_signed.is_some());
767768
} else {
768769
// Make sure we don't double send the CS.
769-
let (_, _, commitment_signed, _, _) = handle_chan_reestablish_msgs!(dst, src);
770+
let (_, _, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
770771
assert!(commitment_signed.is_none());
771772
}
772773
}
@@ -882,6 +883,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
882883
assert!(as_resp.1.is_none());
883884
assert!(as_resp.2.is_none());
884885
assert!(as_resp.4.is_none());
886+
assert!(as_resp.5.is_none());
885887

886888
if monitor_update_failure {
887889
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
@@ -902,6 +904,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
902904
assert!(as_resp.1.is_none());
903905
assert!(as_resp.2.is_none());
904906
assert!(as_resp.4.is_none());
907+
assert!(as_resp.5.is_none());
905908

906909
nodes[0].enable_channel_signer_op(&node_b_id, &chan_id, SignerOp::SignCounterpartyCommitment);
907910
nodes[0].node.signer_unblocked(Some((node_b_id, chan_id)));
@@ -921,6 +924,9 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
921924
assert!(as_resp.4.is_none());
922925
assert!(bs_resp.4.is_none());
923926

927+
assert!(as_resp.5.is_none());
928+
assert!(bs_resp.5.is_none());
929+
924930
// Now that everything is restored, get the CS + RAA and handle them.
925931
nodes[1]
926932
.node

lightning/src/ln/functional_test_utils.rs

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4837,6 +4837,15 @@ macro_rules! handle_chan_reestablish_msgs {
48374837
}
48384838
}
48394839

4840+
let mut tx_signatures = None;
4841+
if let Some(&MessageSendEvent::SendTxSignatures { ref node_id, ref msg }) =
4842+
msg_events.get(idx)
4843+
{
4844+
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
4845+
tx_signatures = Some(msg.clone());
4846+
idx += 1;
4847+
}
4848+
48404849
if let Some(&MessageSendEvent::SendChannelUpdate { ref node_id, .. }) = msg_events.get(idx)
48414850
{
48424851
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
@@ -4855,7 +4864,7 @@ macro_rules! handle_chan_reestablish_msgs {
48554864

48564865
assert_eq!(msg_events.len(), idx, "{msg_events:?}");
48574866

4858-
(channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs)
4867+
(channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs, tx_signatures)
48594868
}};
48604869
}
48614870

@@ -4864,6 +4873,9 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
48644873
pub node_b: &'a Node<'b, 'c, 'd>,
48654874
pub send_channel_ready: (bool, bool),
48664875
pub send_announcement_sigs: (bool, bool),
4876+
pub send_interactive_tx_commit_sig: (bool, bool),
4877+
pub send_interactive_tx_sigs: (bool, bool),
4878+
pub expect_renegotiated_funding_locked_monitor_update: (bool, bool),
48674879
pub pending_responding_commitment_signed: (bool, bool),
48684880
/// Indicates that the pending responding commitment signed will be a dup for the recipient,
48694881
/// and no monitor update is expected
@@ -4883,6 +4895,9 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
48834895
node_b,
48844896
send_channel_ready: (false, false),
48854897
send_announcement_sigs: (false, false),
4898+
send_interactive_tx_commit_sig: (false, false),
4899+
send_interactive_tx_sigs: (false, false),
4900+
expect_renegotiated_funding_locked_monitor_update: (false, false),
48864901
pending_responding_commitment_signed: (false, false),
48874902
pending_responding_commitment_signed_dup_monitor: (false, false),
48884903
pending_htlc_adds: (0, 0),
@@ -4903,6 +4918,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
49034918
node_b,
49044919
send_channel_ready,
49054920
send_announcement_sigs,
4921+
send_interactive_tx_commit_sig,
4922+
send_interactive_tx_sigs,
4923+
expect_renegotiated_funding_locked_monitor_update,
49064924
pending_htlc_adds,
49074925
pending_htlc_claims,
49084926
pending_htlc_fails,
@@ -4953,7 +4971,11 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
49534971
node_b.node.handle_channel_reestablish(node_a_id, &msg);
49544972
resp_1.push(handle_chan_reestablish_msgs!(node_b, node_a));
49554973
}
4956-
if pending_cell_htlc_claims.0 != 0 || pending_cell_htlc_fails.0 != 0 {
4974+
4975+
if pending_cell_htlc_claims.0 != 0
4976+
|| pending_cell_htlc_fails.0 != 0
4977+
|| expect_renegotiated_funding_locked_monitor_update.1
4978+
{
49574979
check_added_monitors!(node_b, 1);
49584980
} else {
49594981
check_added_monitors!(node_b, 0);
@@ -4964,7 +4986,10 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
49644986
node_a.node.handle_channel_reestablish(node_b_id, &msg);
49654987
resp_2.push(handle_chan_reestablish_msgs!(node_a, node_b));
49664988
}
4967-
if pending_cell_htlc_claims.1 != 0 || pending_cell_htlc_fails.1 != 0 {
4989+
if pending_cell_htlc_claims.1 != 0
4990+
|| pending_cell_htlc_fails.1 != 0
4991+
|| expect_renegotiated_funding_locked_monitor_update.0
4992+
{
49684993
check_added_monitors!(node_a, 1);
49694994
} else {
49704995
check_added_monitors!(node_a, 0);
@@ -5011,6 +5036,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
50115036
} else {
50125037
assert!(chan_msgs.4.is_none());
50135038
}
5039+
if send_interactive_tx_commit_sig.0 {
5040+
assert!(chan_msgs.1.is_none());
5041+
let commitment_update = chan_msgs.2.take().unwrap();
5042+
assert_eq!(commitment_update.commitment_signed.len(), 1);
5043+
node_a.node.handle_commitment_signed_batch_test(
5044+
node_b_id,
5045+
&commitment_update.commitment_signed,
5046+
)
5047+
}
5048+
if send_interactive_tx_sigs.0 {
5049+
let tx_signatures = chan_msgs.5.take().unwrap();
5050+
node_a.node.handle_tx_signatures(node_b_id, &tx_signatures);
5051+
} else {
5052+
assert!(chan_msgs.5.is_none());
5053+
}
50145054
if pending_raa.0 {
50155055
assert!(chan_msgs.3 == RAACommitmentOrder::RevokeAndACKFirst);
50165056
node_a.node.handle_revoke_and_ack(node_b_id, &chan_msgs.1.unwrap());
@@ -5102,6 +5142,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
51025142
} else {
51035143
assert!(chan_msgs.4.is_none());
51045144
}
5145+
if send_interactive_tx_commit_sig.1 {
5146+
assert!(chan_msgs.1.is_none());
5147+
let commitment_update = chan_msgs.2.take().unwrap();
5148+
assert_eq!(commitment_update.commitment_signed.len(), 1);
5149+
node_b.node.handle_commitment_signed_batch_test(
5150+
node_a_id,
5151+
&commitment_update.commitment_signed,
5152+
)
5153+
}
5154+
if send_interactive_tx_sigs.1 {
5155+
let tx_signatures = chan_msgs.5.take().unwrap();
5156+
node_b.node.handle_tx_signatures(node_a_id, &tx_signatures);
5157+
} else {
5158+
assert!(chan_msgs.5.is_none());
5159+
}
51055160
if pending_raa.1 {
51065161
assert!(chan_msgs.3 == RAACommitmentOrder::RevokeAndACKFirst);
51075162
node_b.node.handle_revoke_and_ack(node_a_id, &chan_msgs.1.unwrap());

0 commit comments

Comments
 (0)