Merge pull request #213 from TheBlueMatt/2018-10-monitor-fail-pause
[rust-lightning] / src / util / test_utils.rs
index 49aa269b3b44cbe018401cc0386afe5478ccb2aa..2577bc9f9badae0f6bd2acbb89f2011424cf1e4e 100644 (file)
@@ -38,12 +38,14 @@ impl chaininterface::FeeEstimator for TestFeeEstimator {
 pub struct TestChannelMonitor {
        pub added_monitors: Mutex<Vec<(OutPoint, channelmonitor::ChannelMonitor)>>,
        pub simple_monitor: Arc<channelmonitor::SimpleManyChannelMonitor<OutPoint>>,
+       pub update_ret: Mutex<Result<(), channelmonitor::ChannelMonitorUpdateErr>>,
 }
 impl TestChannelMonitor {
        pub fn new(chain_monitor: Arc<chaininterface::ChainWatchInterface>, broadcaster: Arc<chaininterface::BroadcasterInterface>) -> Self {
                Self {
                        added_monitors: Mutex::new(Vec::new()),
                        simple_monitor: channelmonitor::SimpleManyChannelMonitor::new(chain_monitor, broadcaster),
+                       update_ret: Mutex::new(Ok(())),
                }
        }
 }
@@ -57,7 +59,8 @@ impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
                w.0.clear();
                monitor.write_for_watchtower(&mut w).unwrap(); // This at least shouldn't crash...
                self.added_monitors.lock().unwrap().push((funding_txo, monitor.clone()));
-               self.simple_monitor.add_update_monitor(funding_txo, monitor)
+               assert!(self.simple_monitor.add_update_monitor(funding_txo, monitor).is_ok());
+               self.update_ret.lock().unwrap().clone()
        }
 }
 
@@ -110,7 +113,7 @@ impl msgs::ChannelMessageHandler for TestChannelMessageHandler {
        fn handle_update_fulfill_htlc(&self, _their_node_id: &PublicKey, _msg: &msgs::UpdateFulfillHTLC) -> Result<(), HandleError> {
                Err(HandleError { err: "", action: None })
        }
-       fn handle_update_fail_htlc(&self, _their_node_id: &PublicKey, _msg: &msgs::UpdateFailHTLC) -> Result<Option<msgs::HTLCFailChannelUpdate>, HandleError> {
+       fn handle_update_fail_htlc(&self, _their_node_id: &PublicKey, _msg: &msgs::UpdateFailHTLC) -> Result<(), HandleError> {
                Err(HandleError { err: "", action: None })
        }
        fn handle_update_fail_malformed_htlc(&self, _their_node_id: &PublicKey, _msg: &msgs::UpdateFailMalformedHTLC) -> Result<(), HandleError> {
@@ -128,7 +131,7 @@ impl msgs::ChannelMessageHandler for TestChannelMessageHandler {
        fn handle_announcement_signatures(&self, _their_node_id: &PublicKey, _msg: &msgs::AnnouncementSignatures) -> Result<(), HandleError> {
                Err(HandleError { err: "", action: None })
        }
-       fn handle_channel_reestablish(&self, _their_node_id: &PublicKey, _msg: &msgs::ChannelReestablish) -> Result<(Option<msgs::FundingLocked>, Option<msgs::RevokeAndACK>, Option<msgs::CommitmentUpdate>), HandleError> {
+       fn handle_channel_reestablish(&self, _their_node_id: &PublicKey, _msg: &msgs::ChannelReestablish) -> Result<(Option<msgs::FundingLocked>, Option<msgs::RevokeAndACK>, Option<msgs::CommitmentUpdate>, msgs::RAACommitmentOrder), HandleError> {
                Err(HandleError { err: "", action: None })
        }
        fn peer_disconnected(&self, _their_node_id: &PublicKey, _no_connection_possible: bool) {}