Use Persister to return errors in fuzzers not chain::Watch
[rust-lightning] / fuzz / src / utils / test_persister.rs
index 4dcaaa6ddf65953d8ff600dfc67bc482d4209f09..f02f8587af83fc098d897fe0f57d37cfc9637c0a 100644 (file)
@@ -3,13 +3,17 @@ use lightning::chain::{chainmonitor, channelmonitor};
 use lightning::chain::transaction::OutPoint;
 use lightning::util::enforcing_trait_impls::EnforcingSigner;
 
-pub struct TestPersister {}
+use std::sync::Mutex;
+
+pub struct TestPersister {
+       pub update_ret: Mutex<Result<(), chain::ChannelMonitorUpdateErr>>,
+}
 impl chainmonitor::Persist<EnforcingSigner> for TestPersister {
        fn persist_new_channel(&self, _funding_txo: OutPoint, _data: &channelmonitor::ChannelMonitor<EnforcingSigner>) -> Result<(), chain::ChannelMonitorUpdateErr> {
-               Ok(())
+               self.update_ret.lock().unwrap().clone()
        }
 
        fn update_persisted_channel(&self, _funding_txo: OutPoint, _update: &channelmonitor::ChannelMonitorUpdate, _data: &channelmonitor::ChannelMonitor<EnforcingSigner>) -> Result<(), chain::ChannelMonitorUpdateErr> {
-               Ok(())
+               self.update_ret.lock().unwrap().clone()
        }
 }