X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Ftest_utils.rs;h=6647020f6b3d266d9b683796e9c76e1d75f13333;hb=4f644f225c059e2731d848077adac11edb9cdcca;hp=4502bccec1bd9dc28bff06cf46b838f2c9bf91ff;hpb=2d8afeccdb4f5aa6232e6d87c6096e980b836072;p=rust-lightning diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs index 4502bcce..6647020f 100644 --- a/src/util/test_utils.rs +++ b/src/util/test_utils.rs @@ -1,9 +1,9 @@ use chain::chaininterface; use chain::chaininterface::ConfirmationTarget; +use chain::transaction::OutPoint; use ln::channelmonitor; use bitcoin::blockdata::transaction::Transaction; -use bitcoin::util::hash::Sha256dHash; use std::sync::{Arc,Mutex}; @@ -17,8 +17,8 @@ impl chaininterface::FeeEstimator for TestFeeEstimator { } pub struct TestChannelMonitor { - pub added_monitors: Mutex>, - pub simple_monitor: Arc>, + pub added_monitors: Mutex>, + pub simple_monitor: Arc>, } impl TestChannelMonitor { pub fn new(chain_monitor: Arc, broadcaster: Arc) -> Self { @@ -29,7 +29,11 @@ impl TestChannelMonitor { } } impl channelmonitor::ManyChannelMonitor for TestChannelMonitor { - fn add_update_monitor(&self, funding_txo: (Sha256dHash, u16), monitor: channelmonitor::ChannelMonitor) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> { + fn add_update_monitor(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> { + // At every point where we get a monitor update, we should be able to send a useful monitor + // to a watchtower and disk... + assert!(channelmonitor::ChannelMonitor::deserialize(&monitor.serialize_for_disk()[..]).unwrap() == monitor); + monitor.serialize_for_watchtower(); // 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) }