Skip to content

Commit 3c4e70c

Browse files
committed
Capture stfu send in reconnection tests
We'll use this in the next commit to test that we'll send a stfu message for a splice we intend to initiate upon reconnecting.
1 parent d91e14b commit 3c4e70c

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

lightning/src/ln/async_signer_tests.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ fn do_test_async_raa_peer_disconnect(
596596
}
597597

598598
// Expect the RAA
599-
let (_, revoke_and_ack, commitment_signed, resend_order, _, _) =
599+
let (_, revoke_and_ack, commitment_signed, resend_order, _, _, _) =
600600
handle_chan_reestablish_msgs!(dst, src);
601601
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
602602
assert!(revoke_and_ack.is_none());
@@ -612,14 +612,14 @@ fn do_test_async_raa_peer_disconnect(
612612
dst.node.signer_unblocked(Some((src_node_id, chan_id)));
613613

614614
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
615-
let (_, revoke_and_ack, commitment_signed, resend_order, _, _) =
615+
let (_, revoke_and_ack, commitment_signed, resend_order, _, _, _) =
616616
handle_chan_reestablish_msgs!(dst, src);
617617
assert!(revoke_and_ack.is_some());
618618
assert!(commitment_signed.is_some());
619619
assert!(resend_order == RAACommitmentOrder::RevokeAndACKFirst);
620620
} else {
621621
// Make sure we don't double send the RAA.
622-
let (_, revoke_and_ack, commitment_signed, _, _, _) =
622+
let (_, revoke_and_ack, commitment_signed, _, _, _, _) =
623623
handle_chan_reestablish_msgs!(dst, src);
624624
assert!(revoke_and_ack.is_none());
625625
assert!(commitment_signed.is_none());
@@ -746,7 +746,8 @@ fn do_test_async_commitment_signature_peer_disconnect(
746746
}
747747

748748
// Expect the RAA
749-
let (_, revoke_and_ack, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
749+
let (_, revoke_and_ack, commitment_signed, _, _, _, _) =
750+
handle_chan_reestablish_msgs!(dst, src);
750751
assert!(revoke_and_ack.is_some());
751752
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
752753
assert!(commitment_signed.is_none());
@@ -759,11 +760,11 @@ fn do_test_async_commitment_signature_peer_disconnect(
759760
dst.node.signer_unblocked(Some((src_node_id, chan_id)));
760761

761762
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
762-
let (_, _, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
763+
let (_, _, commitment_signed, _, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
763764
assert!(commitment_signed.is_some());
764765
} else {
765766
// Make sure we don't double send the CS.
766-
let (_, _, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
767+
let (_, _, commitment_signed, _, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
767768
assert!(commitment_signed.is_none());
768769
}
769770
}
@@ -880,6 +881,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
880881
assert!(as_resp.2.is_none());
881882
assert!(as_resp.4.is_none());
882883
assert!(as_resp.5.is_none());
884+
assert!(as_resp.6.is_none());
883885

884886
if monitor_update_failure {
885887
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
@@ -901,6 +903,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
901903
assert!(as_resp.2.is_none());
902904
assert!(as_resp.4.is_none());
903905
assert!(as_resp.5.is_none());
906+
assert!(as_resp.6.is_none());
904907

905908
nodes[0].enable_channel_signer_op(&node_b_id, &chan_id, SignerOp::SignCounterpartyCommitment);
906909
nodes[0].node.signer_unblocked(Some((node_b_id, chan_id)));
@@ -923,6 +926,9 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
923926
assert!(as_resp.5.is_none());
924927
assert!(bs_resp.5.is_none());
925928

929+
assert!(as_resp.6.is_none());
930+
assert!(bs_resp.6.is_none());
931+
926932
// Now that everything is restored, get the CS + RAA and handle them.
927933
nodes[1]
928934
.node

lightning/src/ln/functional_test_utils.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4871,6 +4871,13 @@ macro_rules! handle_chan_reestablish_msgs {
48714871
had_channel_update = true;
48724872
}
48734873

4874+
let mut stfu = None;
4875+
if let Some(&MessageSendEvent::SendStfu { ref node_id, ref msg }) = msg_events.get(idx) {
4876+
idx += 1;
4877+
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
4878+
stfu = Some(msg.clone());
4879+
}
4880+
48744881
let mut revoke_and_ack = None;
48754882
let mut commitment_update = None;
48764883
let order = if let Some(ev) = msg_events.get(idx) {
@@ -4946,7 +4953,15 @@ macro_rules! handle_chan_reestablish_msgs {
49464953

49474954
assert_eq!(msg_events.len(), idx, "{msg_events:?}");
49484955

4949-
(channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs, tx_signatures)
4956+
(
4957+
channel_ready,
4958+
revoke_and_ack,
4959+
commitment_update,
4960+
order,
4961+
announcement_sigs,
4962+
tx_signatures,
4963+
stfu,
4964+
)
49504965
}};
49514966
}
49524967

@@ -4955,6 +4970,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
49554970
pub node_b: &'a Node<'b, 'c, 'd>,
49564971
pub send_channel_ready: (bool, bool),
49574972
pub send_announcement_sigs: (bool, bool),
4973+
pub send_stfu: (bool, bool),
49584974
pub send_interactive_tx_commit_sig: (bool, bool),
49594975
pub send_interactive_tx_sigs: (bool, bool),
49604976
pub expect_renegotiated_funding_locked_monitor_update: (bool, bool),
@@ -4977,6 +4993,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
49774993
node_b,
49784994
send_channel_ready: (false, false),
49794995
send_announcement_sigs: (false, false),
4996+
send_stfu: (false, false),
49804997
send_interactive_tx_commit_sig: (false, false),
49814998
send_interactive_tx_sigs: (false, false),
49824999
expect_renegotiated_funding_locked_monitor_update: (false, false),
@@ -5000,6 +5017,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
50005017
node_b,
50015018
send_channel_ready,
50025019
send_announcement_sigs,
5020+
send_stfu,
50035021
send_interactive_tx_commit_sig,
50045022
send_interactive_tx_sigs,
50055023
expect_renegotiated_funding_locked_monitor_update,
@@ -5118,6 +5136,12 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
51185136
} else {
51195137
assert!(chan_msgs.4.is_none());
51205138
}
5139+
if send_stfu.0 {
5140+
let stfu = chan_msgs.6.take().unwrap();
5141+
node_a.node.handle_stfu(node_b_id, &stfu);
5142+
} else {
5143+
assert!(chan_msgs.6.is_none());
5144+
}
51215145
if send_interactive_tx_commit_sig.0 {
51225146
assert!(chan_msgs.1.is_none());
51235147
let commitment_update = chan_msgs.2.take().unwrap();
@@ -5224,6 +5248,12 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
52245248
} else {
52255249
assert!(chan_msgs.4.is_none());
52265250
}
5251+
if send_stfu.1 {
5252+
let stfu = chan_msgs.6.take().unwrap();
5253+
node_b.node.handle_stfu(node_a_id, &stfu);
5254+
} else {
5255+
assert!(chan_msgs.6.is_none());
5256+
}
52275257
if send_interactive_tx_commit_sig.1 {
52285258
assert!(chan_msgs.1.is_none());
52295259
let commitment_update = chan_msgs.2.take().unwrap();

0 commit comments

Comments
 (0)