Skip to content

Commit aa5ab88

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 c7c5976 commit aa5ab88

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
@@ -4807,6 +4807,15 @@ macro_rules! handle_chan_reestablish_msgs {
48074807
}
48084808
}
48094809

4810+
let mut tx_signatures = None;
4811+
if let Some(&MessageSendEvent::SendTxSignatures { ref node_id, ref msg }) =
4812+
msg_events.get(idx)
4813+
{
4814+
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
4815+
tx_signatures = Some(msg.clone());
4816+
idx += 1;
4817+
}
4818+
48104819
if let Some(&MessageSendEvent::SendChannelUpdate { ref node_id, .. }) = msg_events.get(idx)
48114820
{
48124821
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
@@ -4825,7 +4834,7 @@ macro_rules! handle_chan_reestablish_msgs {
48254834

48264835
assert_eq!(msg_events.len(), idx, "{msg_events:?}");
48274836

4828-
(channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs)
4837+
(channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs, tx_signatures)
48294838
}};
48304839
}
48314840

@@ -4834,6 +4843,9 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
48344843
pub node_b: &'a Node<'b, 'c, 'd>,
48354844
pub send_channel_ready: (bool, bool),
48364845
pub send_announcement_sigs: (bool, bool),
4846+
pub send_interactive_tx_commit_sig: (bool, bool),
4847+
pub send_interactive_tx_sigs: (bool, bool),
4848+
pub expect_renegotiated_funding_locked_monitor_update: (bool, bool),
48374849
pub pending_responding_commitment_signed: (bool, bool),
48384850
/// Indicates that the pending responding commitment signed will be a dup for the recipient,
48394851
/// and no monitor update is expected
@@ -4853,6 +4865,9 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
48534865
node_b,
48544866
send_channel_ready: (false, false),
48554867
send_announcement_sigs: (false, false),
4868+
send_interactive_tx_commit_sig: (false, false),
4869+
send_interactive_tx_sigs: (false, false),
4870+
expect_renegotiated_funding_locked_monitor_update: (false, false),
48564871
pending_responding_commitment_signed: (false, false),
48574872
pending_responding_commitment_signed_dup_monitor: (false, false),
48584873
pending_htlc_adds: (0, 0),
@@ -4873,6 +4888,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
48734888
node_b,
48744889
send_channel_ready,
48754890
send_announcement_sigs,
4891+
send_interactive_tx_commit_sig,
4892+
send_interactive_tx_sigs,
4893+
expect_renegotiated_funding_locked_monitor_update,
48764894
pending_htlc_adds,
48774895
pending_htlc_claims,
48784896
pending_htlc_fails,
@@ -4923,7 +4941,11 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
49234941
node_b.node.handle_channel_reestablish(node_a_id, &msg);
49244942
resp_1.push(handle_chan_reestablish_msgs!(node_b, node_a));
49254943
}
4926-
if pending_cell_htlc_claims.0 != 0 || pending_cell_htlc_fails.0 != 0 {
4944+
4945+
if pending_cell_htlc_claims.0 != 0
4946+
|| pending_cell_htlc_fails.0 != 0
4947+
|| expect_renegotiated_funding_locked_monitor_update.1
4948+
{
49274949
check_added_monitors!(node_b, 1);
49284950
} else {
49294951
check_added_monitors!(node_b, 0);
@@ -4934,7 +4956,10 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
49344956
node_a.node.handle_channel_reestablish(node_b_id, &msg);
49354957
resp_2.push(handle_chan_reestablish_msgs!(node_a, node_b));
49364958
}
4937-
if pending_cell_htlc_claims.1 != 0 || pending_cell_htlc_fails.1 != 0 {
4959+
if pending_cell_htlc_claims.1 != 0
4960+
|| pending_cell_htlc_fails.1 != 0
4961+
|| expect_renegotiated_funding_locked_monitor_update.0
4962+
{
49384963
check_added_monitors!(node_a, 1);
49394964
} else {
49404965
check_added_monitors!(node_a, 0);
@@ -4981,6 +5006,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
49815006
} else {
49825007
assert!(chan_msgs.4.is_none());
49835008
}
5009+
if send_interactive_tx_commit_sig.0 {
5010+
assert!(chan_msgs.1.is_none());
5011+
let commitment_update = chan_msgs.2.take().unwrap();
5012+
assert_eq!(commitment_update.commitment_signed.len(), 1);
5013+
node_a.node.handle_commitment_signed_batch_test(
5014+
node_b_id,
5015+
&commitment_update.commitment_signed,
5016+
)
5017+
}
5018+
if send_interactive_tx_sigs.0 {
5019+
let tx_signatures = chan_msgs.5.take().unwrap();
5020+
node_a.node.handle_tx_signatures(node_b_id, &tx_signatures);
5021+
} else {
5022+
assert!(chan_msgs.5.is_none());
5023+
}
49845024
if pending_raa.0 {
49855025
assert!(chan_msgs.3 == RAACommitmentOrder::RevokeAndACKFirst);
49865026
node_a.node.handle_revoke_and_ack(node_b_id, &chan_msgs.1.unwrap());
@@ -5072,6 +5112,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
50725112
} else {
50735113
assert!(chan_msgs.4.is_none());
50745114
}
5115+
if send_interactive_tx_commit_sig.1 {
5116+
assert!(chan_msgs.1.is_none());
5117+
let commitment_update = chan_msgs.2.take().unwrap();
5118+
assert_eq!(commitment_update.commitment_signed.len(), 1);
5119+
node_b.node.handle_commitment_signed_batch_test(
5120+
node_a_id,
5121+
&commitment_update.commitment_signed,
5122+
)
5123+
}
5124+
if send_interactive_tx_sigs.1 {
5125+
let tx_signatures = chan_msgs.5.take().unwrap();
5126+
node_b.node.handle_tx_signatures(node_a_id, &tx_signatures);
5127+
} else {
5128+
assert!(chan_msgs.5.is_none());
5129+
}
50755130
if pending_raa.1 {
50765131
assert!(chan_msgs.3 == RAACommitmentOrder::RevokeAndACKFirst);
50775132
node_b.node.handle_revoke_and_ack(node_a_id, &chan_msgs.1.unwrap());

0 commit comments

Comments
 (0)