Skip to content

Commit 0cdcf54

Browse files
committed
Support capturing tx_abort send within channel reestablish tests
1 parent 3f96d12 commit 0cdcf54

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

lightning/src/ln/async_signer_tests.rs

Lines changed: 11 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,7 @@ fn do_test_async_commitment_signature_peer_disconnect(
746746
}
747747

748748
// Expect the RAA
749-
let (_, revoke_and_ack, commitment_signed, _, _, _, _) =
749+
let (_, revoke_and_ack, commitment_signed, _, _, _, _, _) =
750750
handle_chan_reestablish_msgs!(dst, src);
751751
assert!(revoke_and_ack.is_some());
752752
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
@@ -760,11 +760,11 @@ fn do_test_async_commitment_signature_peer_disconnect(
760760
dst.node.signer_unblocked(Some((src_node_id, chan_id)));
761761

762762
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
763-
let (_, _, commitment_signed, _, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
763+
let (_, _, commitment_signed, _, _, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
764764
assert!(commitment_signed.is_some());
765765
} else {
766766
// Make sure we don't double send the CS.
767-
let (_, _, commitment_signed, _, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
767+
let (_, _, commitment_signed, _, _, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
768768
assert!(commitment_signed.is_none());
769769
}
770770
}
@@ -882,6 +882,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
882882
assert!(as_resp.4.is_none());
883883
assert!(as_resp.5.is_none());
884884
assert!(as_resp.6.is_none());
885+
assert!(as_resp.7.is_none());
885886

886887
if monitor_update_failure {
887888
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
@@ -904,6 +905,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
904905
assert!(as_resp.4.is_none());
905906
assert!(as_resp.5.is_none());
906907
assert!(as_resp.6.is_none());
908+
assert!(as_resp.7.is_none());
907909

908910
nodes[0].enable_channel_signer_op(&node_b_id, &chan_id, SignerOp::SignCounterpartyCommitment);
909911
nodes[0].node.signer_unblocked(Some((node_b_id, chan_id)));
@@ -929,6 +931,9 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
929931
assert!(as_resp.6.is_none());
930932
assert!(bs_resp.6.is_none());
931933

934+
assert!(as_resp.7.is_none());
935+
assert!(bs_resp.7.is_none());
936+
932937
// Now that everything is restored, get the CS + RAA and handle them.
933938
nodes[1]
934939
.node

lightning/src/ln/functional_test_utils.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4996,9 +4996,17 @@ macro_rules! handle_chan_reestablish_msgs {
49964996
($src_node: expr, $dst_node: expr) => {{
49974997
let msg_events = $src_node.node.get_and_clear_pending_msg_events();
49984998
let mut idx = 0;
4999+
5000+
let mut tx_abort = None;
5001+
if let Some(&MessageSendEvent::SendTxAbort { ref node_id, ref msg }) = msg_events.get(idx) {
5002+
idx += 1;
5003+
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
5004+
tx_abort = Some(msg.clone());
5005+
}
5006+
49995007
let channel_ready =
50005008
if let Some(&MessageSendEvent::SendChannelReady { ref node_id, ref msg }) =
5001-
msg_events.get(0)
5009+
msg_events.get(idx)
50025010
{
50035011
idx += 1;
50045012
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
@@ -5115,6 +5123,7 @@ macro_rules! handle_chan_reestablish_msgs {
51155123
announcement_sigs,
51165124
tx_signatures,
51175125
stfu,
5126+
tx_abort,
51185127
)
51195128
}};
51205129
}
@@ -5127,6 +5136,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
51275136
pub send_stfu: (bool, bool),
51285137
pub send_interactive_tx_commit_sig: (bool, bool),
51295138
pub send_interactive_tx_sigs: (bool, bool),
5139+
pub send_tx_abort: (bool, bool),
51305140
pub expect_renegotiated_funding_locked_monitor_update: (bool, bool),
51315141
pub pending_responding_commitment_signed: (bool, bool),
51325142
/// Indicates that the pending responding commitment signed will be a dup for the recipient,
@@ -5150,6 +5160,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
51505160
send_stfu: (false, false),
51515161
send_interactive_tx_commit_sig: (false, false),
51525162
send_interactive_tx_sigs: (false, false),
5163+
send_tx_abort: (false, false),
51535164
expect_renegotiated_funding_locked_monitor_update: (false, false),
51545165
pending_responding_commitment_signed: (false, false),
51555166
pending_responding_commitment_signed_dup_monitor: (false, false),
@@ -5174,6 +5185,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
51745185
send_stfu,
51755186
send_interactive_tx_commit_sig,
51765187
send_interactive_tx_sigs,
5188+
send_tx_abort,
51775189
expect_renegotiated_funding_locked_monitor_update,
51785190
pending_htlc_adds,
51795191
pending_htlc_claims,
@@ -5305,6 +5317,12 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
53055317
&commitment_update.commitment_signed,
53065318
)
53075319
}
5320+
if send_tx_abort.0 {
5321+
let tx_abort = chan_msgs.7.take().unwrap();
5322+
node_a.node.handle_tx_abort(node_b_id, &tx_abort);
5323+
} else {
5324+
assert!(chan_msgs.7.is_none());
5325+
}
53085326
if send_interactive_tx_sigs.0 {
53095327
let tx_signatures = chan_msgs.5.take().unwrap();
53105328
node_a.node.handle_tx_signatures(node_b_id, &tx_signatures);
@@ -5417,6 +5435,12 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
54175435
&commitment_update.commitment_signed,
54185436
)
54195437
}
5438+
if send_tx_abort.1 {
5439+
let tx_abort = chan_msgs.7.take().unwrap();
5440+
node_a.node.handle_tx_abort(node_b_id, &tx_abort);
5441+
} else {
5442+
assert!(chan_msgs.7.is_none());
5443+
}
54205444
if send_interactive_tx_sigs.1 {
54215445
let tx_signatures = chan_msgs.5.take().unwrap();
54225446
node_b.node.handle_tx_signatures(node_a_id, &tx_signatures);

0 commit comments

Comments
 (0)