From 8c6e1329ff1f1011aa37dd5e28c01a731e1c66dc Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 10 Feb 2023 19:57:00 +0000 Subject: [PATCH] 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. --- lightning/src/ln/functional_test_utils.rs | 27 ++++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 6c3c6e76..458d303f 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -576,21 +576,26 @@ macro_rules! get_event { } } +/// Gets an UpdateHTLCs MessageSendEvent +pub fn get_htlc_update_msgs(node: &Node, recipient: &PublicKey) -> msgs::CommitmentUpdate { + let events = node.node.get_and_clear_pending_msg_events(); + assert_eq!(events.len(), 1); + match events[0] { + MessageSendEvent::UpdateHTLCs { ref node_id, ref updates } => { + assert_eq!(node_id, recipient); + (*updates).clone() + }, + _ => panic!("Unexpected event"), + } +} + #[macro_export] /// Gets an UpdateHTLCs MessageSendEvent +/// +/// Don't use this, use the identically-named function instead. macro_rules! get_htlc_update_msgs { ($node: expr, $node_id: expr) => { - { - let events = $node.node.get_and_clear_pending_msg_events(); - assert_eq!(events.len(), 1); - match events[0] { - $crate::util::events::MessageSendEvent::UpdateHTLCs { ref node_id, ref updates } => { - assert_eq!(*node_id, $node_id); - (*updates).clone() - }, - _ => panic!("Unexpected event"), - } - } + $crate::ln::functional_test_utils::get_htlc_update_msgs(&$node, &$node_id) } } -- 2.30.2