Trivially refactor reload_node macro
What changed, and why it matters
This is a purely internal cleanup of a test helper macro in the Lightning Dev Kit Rust codebase. It renames and splits a macro used only in tests so that future variants can be added more easily. There is no change to production code, no change to user-facing behavior, and no security relevance.
No action required. This is a non-security test-only refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the reload_node! macro in lightning/src/ln/functional_test_utils.rs into a new internal _reload_node_inner! macro and two public reload_node! variants. The new internal macro accepts an additional $reconstruct_pending_htlcs parameter, but both existing variants pass None, preserving identical behavior. The change is purely structural and preparatory for a subsequent commit.
Changed components
lightning/src/ln/functional_test_utils.rsInspect captured patch +32 / −6
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index 25b5408..07f11ed 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -1366,8 +1366,10 @@ pub fn _reload_node<'a, 'b, 'c>(
}
#[macro_export]
-macro_rules! reload_node {
- ($node: expr, $new_config: expr, $chanman_encoded: expr, $monitors_encoded: expr, $persister: ident, $new_chain_monitor: ident, $new_channelmanager: ident) => {
+macro_rules! _reload_node_inner {
+ ($node: expr, $new_config: expr, $chanman_encoded: expr, $monitors_encoded: expr, $persister:
+ ident, $new_chain_monitor: ident, $new_channelmanager: ident, $reconstruct_pending_htlcs: expr
+ ) => {
let chanman_encoded = $chanman_encoded;
$persister = $crate::util::test_utils::TestPersister::new();
@@ -1381,22 +1383,46 @@ macro_rules! reload_node {
);
$node.chain_monitor = &$new_chain_monitor;
- $new_channelmanager =
- _reload_node(&$node, $new_config, &chanman_encoded, $monitors_encoded, None);
+ $new_channelmanager = _reload_node(
+ &$node,
+ $new_config,
+ &chanman_encoded,
+ $monitors_encoded,
+ $reconstruct_pending_htlcs,
+ );
$node.node = &$new_channelmanager;
$node.onion_messenger.set_offers_handler(&$new_channelmanager);
$node.onion_messenger.set_async_payments_handler(&$new_channelmanager);
};
+}
+
+#[macro_export]
+macro_rules! reload_node {
+ // Reload the node using the node's current config
($node: expr, $chanman_encoded: expr, $monitors_encoded: expr, $persister: ident, $new_chain_monitor: ident, $new_channelmanager: ident) => {
let config = $node.node.get_current_config();
- reload_node!(
+ _reload_node_inner!(
$node,
config,
$chanman_encoded,
$monitors_encoded,
$persister,
$new_chain_monitor,
- $new_channelmanager
+ $new_channelmanager,
+ None
+ );
+ };
+ // Reload the node with the new provided config
+ ($node: expr, $new_config: expr, $chanman_encoded: expr, $monitors_encoded: expr, $persister: ident, $new_chain_monitor: ident, $new_channelmanager: ident) => {
+ _reload_node_inner!(
+ $node,
+ $new_config,
+ $chanman_encoded,
+ $monitors_encoded,
+ $persister,
+ $new_chain_monitor,
+ $new_channelmanager,
+ None
);
};
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.