Skip to content

Commit

Permalink
Make lightning-background-processor test failures more debugable
Browse files Browse the repository at this point in the history
Instead of asserting a `Result` `is_ok`, we should always simply
`unwrap` to get a backgrace, and we should avoid doing so if the
thread is already panicking.
  • Loading branch information
TheBlueMatt committed Apr 4, 2023
1 parent 3b8bf93 commit fcf1282
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,9 @@ mod tests {
let filepath = get_full_filepath("test_background_processor_persister_0".to_string(), "scorer".to_string());
check_persisted_data!(nodes[0].scorer, filepath.clone());

assert!(bg_processor.stop().is_ok());
if !std::thread::panicking() {
bg_processor.stop().unwrap();
}
}

#[test]
Expand All @@ -1208,7 +1210,9 @@ mod tests {
}
}

assert!(bg_processor.stop().is_ok());
if !std::thread::panicking() {
bg_processor.stop().unwrap();
}
}

#[test]
Expand Down Expand Up @@ -1300,7 +1304,9 @@ mod tests {
nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_funding);
let _bs_channel_update = get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());

assert!(bg_processor.stop().is_ok());
if !std::thread::panicking() {
bg_processor.stop().unwrap();
}

// Set up a background event handler for SpendableOutputs events.
let (sender, receiver) = std::sync::mpsc::sync_channel(1);
Expand All @@ -1326,7 +1332,9 @@ mod tests {
_ => panic!("Unexpected event: {:?}", event),
}

assert!(bg_processor.stop().is_ok());
if !std::thread::panicking() {
bg_processor.stop().unwrap();
}
}

#[test]
Expand All @@ -1345,7 +1353,9 @@ mod tests {
}
}

assert!(bg_processor.stop().is_ok());
if !std::thread::panicking() {
bg_processor.stop().unwrap();
}
}

#[test]
Expand Down Expand Up @@ -1519,6 +1529,8 @@ mod tests {
_ => panic!("Unexpected event"),
}

assert!(bg_processor.stop().is_ok());
if !std::thread::panicking() {
bg_processor.stop().unwrap();
}
}
}

0 comments on commit fcf1282

Please sign in to comment.