Skip to content

Commit 5909b79

Browse files
committed
Add test for aggregated revoked HTLC claim on anchors channel
1 parent 72e07f2 commit 5909b79

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
@@ -1232,24 +1232,23 @@ macro_rules! check_warn_msg {
12321232

12331233
/// Check that a channel's closing channel update has been broadcasted, and optionally
12341234
/// check whether an error message event has occurred.
1235-
pub fn check_closed_broadcast(node: &Node, with_error_msg: bool) -> Option<msgs::ErrorMessage> {
1235+
pub fn check_closed_broadcast(node: &Node, num_channels: usize, with_error_msg: bool) -> Vec<msgs::ErrorMessage> {
12361236
let msg_events = node.node.get_and_clear_pending_msg_events();
1237-
assert_eq!(msg_events.len(), if with_error_msg { 2 } else { 1 });
1238-
match msg_events[0] {
1239-
MessageSendEvent::BroadcastChannelUpdate { ref msg } => {
1240-
assert_eq!(msg.contents.flags & 2, 2);
1241-
},
1242-
_ => panic!("Unexpected event"),
1243-
}
1244-
if with_error_msg {
1245-
match msg_events[1] {
1237+
assert_eq!(msg_events.len(), if with_error_msg { num_channels * 2 } else { num_channels });
1238+
msg_events.into_iter().filter_map(|msg_event| {
1239+
match msg_event {
1240+
MessageSendEvent::BroadcastChannelUpdate { ref msg } => {
1241+
assert_eq!(msg.contents.flags & 2, 2);
1242+
None
1243+
},
12461244
MessageSendEvent::HandleError { action: msgs::ErrorAction::SendErrorMessage { ref msg }, node_id: _ } => {
1245+
assert!(with_error_msg);
12471246
// TODO: Check node_id
12481247
Some(msg.clone())
12491248
},
12501249
_ => panic!("Unexpected event"),
12511250
}
1252-
} else { None }
1251+
}).collect()
12531252
}
12541253

12551254
/// Check that a channel's closing channel update has been broadcasted, and optionally
@@ -1259,7 +1258,7 @@ pub fn check_closed_broadcast(node: &Node, with_error_msg: bool) -> Option<msgs:
12591258
#[macro_export]
12601259
macro_rules! check_closed_broadcast {
12611260
($node: expr, $with_error_msg: expr) => {
1262-
$crate::ln::functional_test_utils::check_closed_broadcast(&$node, $with_error_msg)
1261+
$crate::ln::functional_test_utils::check_closed_broadcast(&$node, 1, $with_error_msg).pop()
12631262
}
12641263
}
12651264

0 commit comments

Comments
 (0)