Skip to content

Commit cb32bd2

Browse files
Trivially refactor reload_node macro
Cleans it up a bit in preparation for adding a new variant in the next commit.
1 parent 8fb86ea commit cb32bd2

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

lightning/src/ln/functional_test_utils.rs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,8 +1366,10 @@ pub fn _reload_node<'a, 'b, 'c>(
13661366
}
13671367

13681368
#[macro_export]
1369-
macro_rules! reload_node {
1370-
($node: expr, $new_config: expr, $chanman_encoded: expr, $monitors_encoded: expr, $persister: ident, $new_chain_monitor: ident, $new_channelmanager: ident) => {
1369+
macro_rules! _reload_node_inner {
1370+
($node: expr, $new_config: expr, $chanman_encoded: expr, $monitors_encoded: expr, $persister:
1371+
ident, $new_chain_monitor: ident, $new_channelmanager: ident, $reconstruct_pending_htlcs: expr
1372+
) => {
13711373
let chanman_encoded = $chanman_encoded;
13721374

13731375
$persister = $crate::util::test_utils::TestPersister::new();
@@ -1381,22 +1383,46 @@ macro_rules! reload_node {
13811383
);
13821384
$node.chain_monitor = &$new_chain_monitor;
13831385

1384-
$new_channelmanager =
1385-
_reload_node(&$node, $new_config, &chanman_encoded, $monitors_encoded, None);
1386+
$new_channelmanager = _reload_node(
1387+
&$node,
1388+
$new_config,
1389+
&chanman_encoded,
1390+
$monitors_encoded,
1391+
$reconstruct_pending_htlcs,
1392+
);
13861393
$node.node = &$new_channelmanager;
13871394
$node.onion_messenger.set_offers_handler(&$new_channelmanager);
13881395
$node.onion_messenger.set_async_payments_handler(&$new_channelmanager);
13891396
};
1397+
}
1398+
1399+
#[macro_export]
1400+
macro_rules! reload_node {
1401+
// Reload the node using the node's current config
13901402
($node: expr, $chanman_encoded: expr, $monitors_encoded: expr, $persister: ident, $new_chain_monitor: ident, $new_channelmanager: ident) => {
13911403
let config = $node.node.get_current_config();
1392-
reload_node!(
1404+
_reload_node_inner!(
13931405
$node,
13941406
config,
13951407
$chanman_encoded,
13961408
$monitors_encoded,
13971409
$persister,
13981410
$new_chain_monitor,
1399-
$new_channelmanager
1411+
$new_channelmanager,
1412+
None
1413+
);
1414+
};
1415+
// Reload the node with the new provided config
1416+
($node: expr, $new_config: expr, $chanman_encoded: expr, $monitors_encoded: expr, $persister: ident, $new_chain_monitor: ident, $new_channelmanager: ident) => {
1417+
_reload_node_inner!(
1418+
$node,
1419+
$new_config,
1420+
$chanman_encoded,
1421+
$monitors_encoded,
1422+
$persister,
1423+
$new_chain_monitor,
1424+
$new_channelmanager,
1425+
None
14001426
);
14011427
};
14021428
}

0 commit comments

Comments
 (0)