Skip to content

Commit 6f2e01c

Browse files
committed
Add test for aggregated revoked HTLC claim on anchors channel
1 parent 3278898 commit 6f2e01c

File tree

2 files changed

+382
-14
lines changed

2 files changed

+382
-14
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,24 +1239,23 @@ macro_rules! check_warn_msg {
12391239

12401240
/// Check that a channel's closing channel update has been broadcasted, and optionally
12411241
/// check whether an error message event has occurred.
1242-
pub fn check_closed_broadcast(node: &Node, with_error_msg: bool) -> Option<msgs::ErrorMessage> {
1242+
pub fn check_closed_broadcast(node: &Node, num_channels: usize, with_error_msg: bool) -> Vec<msgs::ErrorMessage> {
12431243
let msg_events = node.node.get_and_clear_pending_msg_events();
1244-
assert_eq!(msg_events.len(), if with_error_msg { 2 } else { 1 });
1245-
match msg_events[0] {
1246-
MessageSendEvent::BroadcastChannelUpdate { ref msg } => {
1247-
assert_eq!(msg.contents.flags & 2, 2);
1248-
},
1249-
_ => panic!("Unexpected event"),
1250-
}
1251-
if with_error_msg {
1252-
match msg_events[1] {
1244+
assert_eq!(msg_events.len(), if with_error_msg { num_channels * 2 } else { num_channels });
1245+
msg_events.into_iter().filter_map(|msg_event| {
1246+
match msg_event {
1247+
MessageSendEvent::BroadcastChannelUpdate { ref msg } => {
1248+
assert_eq!(msg.contents.flags & 2, 2);
1249+
None
1250+
},
12531251
MessageSendEvent::HandleError { action: msgs::ErrorAction::SendErrorMessage { ref msg }, node_id: _ } => {
1252+
assert!(with_error_msg);
12541253
// TODO: Check node_id
12551254
Some(msg.clone())
12561255
},
12571256
_ => panic!("Unexpected event"),
12581257
}
1259-
} else { None }
1258+
}).collect()
12601259
}
12611260

12621261
/// Check that a channel's closing channel update has been broadcasted, and optionally
@@ -1266,7 +1265,7 @@ pub fn check_closed_broadcast(node: &Node, with_error_msg: bool) -> Option<msgs:
12661265
#[macro_export]
12671266
macro_rules! check_closed_broadcast {
12681267
($node: expr, $with_error_msg: expr) => {
1269-
$crate::ln::functional_test_utils::check_closed_broadcast(&$node, $with_error_msg)
1268+
$crate::ln::functional_test_utils::check_closed_broadcast(&$node, 1, $with_error_msg).pop()
12701269
}
12711270
}
12721271

0 commit comments

Comments
 (0)