Correctly assert BackgroundProcessor error
authorJeffrey Czyz <jkczyz@gmail.com>
Sun, 18 Jul 2021 17:59:27 +0000 (12:59 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Sun, 18 Jul 2021 17:59:27 +0000 (12:59 -0500)
The specific error from the ChannelManager persister is not asserted for
in test_persist_error. Rather, any error will do. Update the test to use
BackgroundProcessor::stop and assert for the expected value.

lightning-background-processor/src/lib.rs

index 0b886f7bf4ea2e61bf94ff4ef54014c13b04385b..f5c914ed5dfe69d158b2d61289f58e64f3b4c5a5 100644 (file)
@@ -416,7 +416,13 @@ mod tests {
                let persister = |_: &_| Err(std::io::Error::new(std::io::ErrorKind::Other, "test"));
                let event_handler = |_| {};
                let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone());
-               let _ = bg_processor.thread_handle.join().unwrap().expect_err("Errored persisting manager: test");
+               match bg_processor.stop() {
+                       Ok(_) => panic!("Expected error persisting manager"),
+                       Err(e) => {
+                               assert_eq!(e.kind(), std::io::ErrorKind::Other);
+                               assert_eq!(e.get_ref().unwrap().to_string(), "test");
+                       },
+               }
        }
 
        #[test]