X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Ftest_utils.rs;h=4502bccec1bd9dc28bff06cf46b838f2c9bf91ff;hb=738638fad4bed3f0001bfbc50a5e5ea2a11165af;hp=5d657b13df585922626d37c9950d303838c3d8ae;hpb=f7dd69240afcd3a0087f7796824a9e2697ed85cf;p=rust-lightning diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs index 5d657b13..4502bcce 100644 --- a/src/util/test_utils.rs +++ b/src/util/test_utils.rs @@ -1,12 +1,11 @@ use chain::chaininterface; use chain::chaininterface::ConfirmationTarget; use ln::channelmonitor; -use ln::msgs::HandleError; use bitcoin::blockdata::transaction::Transaction; use bitcoin::util::hash::Sha256dHash; -use std::sync::Mutex; +use std::sync::{Arc,Mutex}; pub struct TestFeeEstimator { pub sat_per_vbyte: u64, @@ -18,12 +17,21 @@ impl chaininterface::FeeEstimator for TestFeeEstimator { } pub struct TestChannelMonitor { - + pub added_monitors: Mutex>, + pub simple_monitor: Arc>, +} +impl TestChannelMonitor { + pub fn new(chain_monitor: Arc, broadcaster: Arc) -> Self { + Self { + added_monitors: Mutex::new(Vec::new()), + simple_monitor: channelmonitor::SimpleManyChannelMonitor::new(chain_monitor, broadcaster), + } + } } impl channelmonitor::ManyChannelMonitor for TestChannelMonitor { - fn add_update_monitor(&self, _funding_txo: (Sha256dHash, u16), _monitor: channelmonitor::ChannelMonitor) -> Result<(), HandleError> { - //TODO! - Ok(()) + fn add_update_monitor(&self, funding_txo: (Sha256dHash, u16), monitor: channelmonitor::ChannelMonitor) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> { + self.added_monitors.lock().unwrap().push((funding_txo, monitor.clone())); + self.simple_monitor.add_update_monitor(funding_txo, monitor) } }