From: Matt Corallo Date: Fri, 10 Feb 2023 19:57:00 +0000 (+0000) Subject: Replace `get_htlc_update_msgs` macro with a function X-Git-Tag: v0.0.115~76^2~4 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=8c6e1329ff1f1011aa37dd5e28c01a731e1c66dc;p=rust-lightning 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. --- diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 6c3c6e76d..458d303fc 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) } }