X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Ftest_utils.rs;h=6a652aa6b39c0016c0ac3705cfcf9206733e04a8;hb=HEAD;hp=6647020f6b3d266d9b683796e9c76e1d75f13333;hpb=de523c4ca38c4f671df11fa4c7f5781ba0ab00fc;p=rust-lightning diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs deleted file mode 100644 index 6647020f..00000000 --- a/src/util/test_utils.rs +++ /dev/null @@ -1,49 +0,0 @@ -use chain::chaininterface; -use chain::chaininterface::ConfirmationTarget; -use chain::transaction::OutPoint; -use ln::channelmonitor; - -use bitcoin::blockdata::transaction::Transaction; - -use std::sync::{Arc,Mutex}; - -pub struct TestFeeEstimator { - pub sat_per_vbyte: u64, -} -impl chaininterface::FeeEstimator for TestFeeEstimator { - fn get_est_sat_per_vbyte(&self, _confirmation_target: ConfirmationTarget) -> u64 { - self.sat_per_vbyte - } -} - -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: 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) - } -} - -pub struct TestBroadcaster { - pub txn_broadcasted: Mutex>, -} -impl chaininterface::BroadcasterInterface for TestBroadcaster { - fn broadcast_transaction(&self, tx: &Transaction) { - self.txn_broadcasted.lock().unwrap().push(tx.clone()); - } -}