Skip to content

Commit 4bb14ad

Browse files
committed
Replace check_added_monitors with a function
The `check_added_monitors!()` 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 338,710 LoC to 329,119 LoC.
1 parent 8311581 commit 4bb14ad

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -758,14 +758,19 @@ macro_rules! unwrap_send_err {
758758
}
759759

760760
/// Check whether N channel monitor(s) have been added.
761+
pub fn check_added_monitors(node: &Node, count: usize) {
762+
let mut added_monitors = node.chain_monitor.added_monitors.lock().unwrap();
763+
assert_eq!(added_monitors.len(), count);
764+
added_monitors.clear();
765+
}
766+
767+
/// Check whether N channel monitor(s) have been added.
768+
///
769+
/// Don't use this, use the identically-named function instead.
761770
#[macro_export]
762771
macro_rules! check_added_monitors {
763772
($node: expr, $count: expr) => {
764-
{
765-
let mut added_monitors = $node.chain_monitor.added_monitors.lock().unwrap();
766-
assert_eq!(added_monitors.len(), $count);
767-
added_monitors.clear();
768-
}
773+
$crate::ln::functional_test_utils::check_added_monitors(&$node, $count);
769774
}
770775
}
771776

@@ -1464,10 +1469,10 @@ macro_rules! commitment_signed_dance {
14641469
};
14651470
($node_a: expr, $node_b: expr, $commitment_signed: expr, $fail_backwards: expr, true /* skip last step */, false /* return extra message */, true /* return last RAA */) => {
14661471
{
1467-
check_added_monitors!($node_a, 0);
1472+
$crate::ln::functional_test_utils::check_added_monitors(&$node_a, 0);
14681473
assert!($node_a.node.get_and_clear_pending_msg_events().is_empty());
14691474
$node_a.node.handle_commitment_signed(&$node_b.node.get_our_node_id(), &$commitment_signed);
1470-
check_added_monitors!($node_a, 1);
1475+
check_added_monitors(&$node_a, 1);
14711476
let (extra_msg_option, bs_revoke_and_ack) = $crate::ln::functional_test_utils::do_main_commitment_signed_dance(&$node_a, &$node_b, $fail_backwards);
14721477
assert!(extra_msg_option.is_none());
14731478
bs_revoke_and_ack
@@ -1477,7 +1482,7 @@ macro_rules! commitment_signed_dance {
14771482
{
14781483
let (extra_msg_option, bs_revoke_and_ack) = $crate::ln::functional_test_utils::do_main_commitment_signed_dance(&$node_a, &$node_b, $fail_backwards);
14791484
$node_a.node.handle_revoke_and_ack(&$node_b.node.get_our_node_id(), &bs_revoke_and_ack);
1480-
check_added_monitors!($node_a, 1);
1485+
$crate::ln::functional_test_utils::check_added_monitors(&$node_a, 1);
14811486
extra_msg_option
14821487
}
14831488
};

0 commit comments

Comments
 (0)