Skip to content

Commit 2e5befa

Browse files
TheBlueMattoptout21
authored andcommitted
Make lightning-background-processor test failures more debugable
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.
1 parent 1abe3a6 commit 2e5befa

File tree

1 file changed

+18
-6
lines changed
  • lightning-background-processor/src

1 file changed

+18
-6
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,9 @@ mod tests {
11861186
let filepath = get_full_filepath("test_background_processor_persister_0".to_string(), "scorer".to_string());
11871187
check_persisted_data!(nodes[0].scorer, filepath.clone());
11881188

1189-
assert!(bg_processor.stop().is_ok());
1189+
if !std::thread::panicking() {
1190+
bg_processor.stop().unwrap();
1191+
}
11901192
}
11911193

11921194
#[test]
@@ -1208,7 +1210,9 @@ mod tests {
12081210
}
12091211
}
12101212

1211-
assert!(bg_processor.stop().is_ok());
1213+
if !std::thread::panicking() {
1214+
bg_processor.stop().unwrap();
1215+
}
12121216
}
12131217

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

1303-
assert!(bg_processor.stop().is_ok());
1307+
if !std::thread::panicking() {
1308+
bg_processor.stop().unwrap();
1309+
}
13041310

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

1329-
assert!(bg_processor.stop().is_ok());
1335+
if !std::thread::panicking() {
1336+
bg_processor.stop().unwrap();
1337+
}
13301338
}
13311339

13321340
#[test]
@@ -1345,7 +1353,9 @@ mod tests {
13451353
}
13461354
}
13471355

1348-
assert!(bg_processor.stop().is_ok());
1356+
if !std::thread::panicking() {
1357+
bg_processor.stop().unwrap();
1358+
}
13491359
}
13501360

13511361
#[test]
@@ -1519,6 +1529,8 @@ mod tests {
15191529
_ => panic!("Unexpected event"),
15201530
}
15211531

1522-
assert!(bg_processor.stop().is_ok());
1532+
if !std::thread::panicking() {
1533+
bg_processor.stop().unwrap();
1534+
}
15231535
}
15241536
}

0 commit comments

Comments
 (0)