Skip to content

Commit bc44a4e

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 41de9c5 commit bc44a4e

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
@@ -4814,6 +4814,13 @@ macro_rules! handle_chan_reestablish_msgs {
48144814
had_channel_update = true;
48154815
}
48164816

4817+
let mut stfu = None;
4818+
if let Some(&MessageSendEvent::SendStfu { ref node_id, ref msg }) = msg_events.get(idx) {
4819+
idx += 1;
4820+
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
4821+
stfu = Some(msg.clone());
4822+
}
4823+
48174824
let mut revoke_and_ack = None;
48184825
let mut commitment_update = None;
48194826
let order = if let Some(ev) = msg_events.get(idx) {
@@ -4889,7 +4896,15 @@ macro_rules! handle_chan_reestablish_msgs {
48894896

48904897
assert_eq!(msg_events.len(), idx, "{msg_events:?}");
48914898

4892-
(channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs, tx_signatures)
4899+
(
4900+
channel_ready,
4901+
revoke_and_ack,
4902+
commitment_update,
4903+
order,
4904+
announcement_sigs,
4905+
tx_signatures,
4906+
stfu,
4907+
)
48934908
}};
48944909
}
48954910

@@ -4898,6 +4913,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
48984913
pub node_b: &'a Node<'b, 'c, 'd>,
48994914
pub send_channel_ready: (bool, bool),
49004915
pub send_announcement_sigs: (bool, bool),
4916+
pub send_stfu: (bool, bool),
49014917
pub send_interactive_tx_commit_sig: (bool, bool),
49024918
pub send_interactive_tx_sigs: (bool, bool),
49034919
pub expect_renegotiated_funding_locked_monitor_update: (bool, bool),
@@ -4920,6 +4936,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
49204936
node_b,
49214937
send_channel_ready: (false, false),
49224938
send_announcement_sigs: (false, false),
4939+
send_stfu: (false, false),
49234940
send_interactive_tx_commit_sig: (false, false),
49244941
send_interactive_tx_sigs: (false, false),
49254942
expect_renegotiated_funding_locked_monitor_update: (false, false),
@@ -4943,6 +4960,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
49434960
node_b,
49444961
send_channel_ready,
49454962
send_announcement_sigs,
4963+
send_stfu,
49464964
send_interactive_tx_commit_sig,
49474965
send_interactive_tx_sigs,
49484966
expect_renegotiated_funding_locked_monitor_update,
@@ -5061,6 +5079,12 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
50615079
} else {
50625080
assert!(chan_msgs.4.is_none());
50635081
}
5082+
if send_stfu.0 {
5083+
let stfu = chan_msgs.6.take().unwrap();
5084+
node_a.node.handle_stfu(node_b_id, &stfu);
5085+
} else {
5086+
assert!(chan_msgs.6.is_none());
5087+
}
50645088
if send_interactive_tx_commit_sig.0 {
50655089
assert!(chan_msgs.1.is_none());
50665090
let commitment_update = chan_msgs.2.take().unwrap();
@@ -5167,6 +5191,12 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
51675191
} else {
51685192
assert!(chan_msgs.4.is_none());
51695193
}
5194+
if send_stfu.1 {
5195+
let stfu = chan_msgs.6.take().unwrap();
5196+
node_b.node.handle_stfu(node_a_id, &stfu);
5197+
} else {
5198+
assert!(chan_msgs.6.is_none());
5199+
}
51705200
if send_interactive_tx_commit_sig.1 {
51715201
assert!(chan_msgs.1.is_none());
51725202
let commitment_update = chan_msgs.2.take().unwrap();

0 commit comments

Comments
 (0)