Skip to content

Commit 8c6e132

Browse files
committed
Replace get_htlc_update_msgs macro with a function
The `get_htlc_update_msgs!()` macro has no reason to be a macro so here we move its logic to a function and leave the macro in place to avoid touching every line of code in the tests. This reduces the `--profile=test --lib` `Zpretty=expanded` code size from 321,985 LoC to 316,856 LoC.
1 parent 35bb0f4 commit 8c6e132

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -576,21 +576,26 @@ macro_rules! get_event {
576576
}
577577
}
578578

579+
/// Gets an UpdateHTLCs MessageSendEvent
580+
pub fn get_htlc_update_msgs(node: &Node, recipient: &PublicKey) -> msgs::CommitmentUpdate {
581+
let events = node.node.get_and_clear_pending_msg_events();
582+
assert_eq!(events.len(), 1);
583+
match events[0] {
584+
MessageSendEvent::UpdateHTLCs { ref node_id, ref updates } => {
585+
assert_eq!(node_id, recipient);
586+
(*updates).clone()
587+
},
588+
_ => panic!("Unexpected event"),
589+
}
590+
}
591+
579592
#[macro_export]
580593
/// Gets an UpdateHTLCs MessageSendEvent
594+
///
595+
/// Don't use this, use the identically-named function instead.
581596
macro_rules! get_htlc_update_msgs {
582597
($node: expr, $node_id: expr) => {
583-
{
584-
let events = $node.node.get_and_clear_pending_msg_events();
585-
assert_eq!(events.len(), 1);
586-
match events[0] {
587-
$crate::util::events::MessageSendEvent::UpdateHTLCs { ref node_id, ref updates } => {
588-
assert_eq!(*node_id, $node_id);
589-
(*updates).clone()
590-
},
591-
_ => panic!("Unexpected event"),
592-
}
593-
}
598+
$crate::ln::functional_test_utils::get_htlc_update_msgs(&$node, &$node_id)
594599
}
595600
}
596601

0 commit comments

Comments
 (0)