1 use chain::chaininterface;
2 use chain::chaininterface::ConfirmationTarget;
3 use chain::transaction::OutPoint;
4 use ln::channelmonitor;
6 use bitcoin::blockdata::transaction::Transaction;
8 use std::sync::{Arc,Mutex};
10 pub struct TestFeeEstimator {
11 pub sat_per_vbyte: u64,
13 impl chaininterface::FeeEstimator for TestFeeEstimator {
14 fn get_est_sat_per_vbyte(&self, _confirmation_target: ConfirmationTarget) -> u64 {
19 pub struct TestChannelMonitor {
20 pub added_monitors: Mutex<Vec<(OutPoint, channelmonitor::ChannelMonitor)>>,
21 pub simple_monitor: Arc<channelmonitor::SimpleManyChannelMonitor<OutPoint>>,
23 impl TestChannelMonitor {
24 pub fn new(chain_monitor: Arc<chaininterface::ChainWatchInterface>, broadcaster: Arc<chaininterface::BroadcasterInterface>) -> Self {
26 added_monitors: Mutex::new(Vec::new()),
27 simple_monitor: channelmonitor::SimpleManyChannelMonitor::new(chain_monitor, broadcaster),
31 impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
32 fn add_update_monitor(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> {
33 self.added_monitors.lock().unwrap().push((funding_txo, monitor.clone()));
34 self.simple_monitor.add_update_monitor(funding_txo, monitor)
38 pub struct TestBroadcaster {
39 pub txn_broadcasted: Mutex<Vec<Transaction>>,
41 impl chaininterface::BroadcasterInterface for TestBroadcaster {
42 fn broadcast_transaction(&self, tx: &Transaction) {
43 self.txn_broadcasted.lock().unwrap().push(tx.clone());