Skip to content

Commit 6ebc739

Browse files
committed
Move expected_bytes to check_persisted_data! macro
1 parent afb7aa8 commit 6ebc739

File tree

1 file changed

+8
-10
lines changed
  • lightning-background-processor/src

1 file changed

+8
-10
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -559,14 +559,15 @@ mod tests {
559559
let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone());
560560

561561
macro_rules! check_persisted_data {
562-
($node: expr, $filepath: expr, $expected_bytes: expr) => {
562+
($node: expr, $filepath: expr) => {
563+
let mut expected_bytes = Vec::new();
563564
loop {
564-
$expected_bytes.clear();
565-
match $node.write(&mut $expected_bytes) {
565+
expected_bytes.clear();
566+
match $node.write(&mut expected_bytes) {
566567
Ok(()) => {
567568
match std::fs::read($filepath) {
568569
Ok(bytes) => {
569-
if bytes == $expected_bytes {
570+
if bytes == expected_bytes {
570571
break
571572
} else {
572573
continue
@@ -583,8 +584,7 @@ mod tests {
583584

584585
// Check that the initial channel manager data is persisted as expected.
585586
let filepath = get_full_filepath("test_background_processor_persister_0".to_string(), "manager".to_string());
586-
let mut expected_bytes = Vec::new();
587-
check_persisted_data!(nodes[0].node, filepath.clone(), expected_bytes);
587+
check_persisted_data!(nodes[0].node, filepath.clone());
588588

589589
loop {
590590
if !nodes[0].node.get_persistence_condvar_value() { break }
@@ -594,18 +594,16 @@ mod tests {
594594
nodes[0].node.force_close_channel(&OutPoint { txid: tx.txid(), index: 0 }.to_channel_id()).unwrap();
595595

596596
// Check that the force-close updates are persisted.
597-
let mut expected_bytes = Vec::new();
598-
check_persisted_data!(nodes[0].node, filepath.clone(), expected_bytes);
597+
check_persisted_data!(nodes[0].node, filepath.clone());
599598
loop {
600599
if !nodes[0].node.get_persistence_condvar_value() { break }
601600
}
602601

603602
// Check network graph is persisted
604603
let filepath = get_full_filepath("test_background_processor_persister_0".to_string(), "network_graph".to_string());
605-
let mut expected_bytes = Vec::new();
606604
if let Some(ref handler) = nodes[0].net_graph_msg_handler {
607605
let network_graph = handler.network_graph();
608-
check_persisted_data!(network_graph, filepath.clone(), expected_bytes);
606+
check_persisted_data!(network_graph, filepath.clone());
609607
}
610608

611609
assert!(bg_processor.stop().is_ok());

0 commit comments

Comments
 (0)