Add support for initiating channel closure to Channel{,Manager}
[rust-lightning] / src / util / test_utils.rs
1 use chain::chaininterface;
2 use chain::chaininterface::ConfirmationTarget;
3 use ln::channelmonitor;
4 use ln::msgs::HandleError;
5
6 use bitcoin::blockdata::transaction::Transaction;
7 use bitcoin::util::hash::Sha256dHash;
8
9 use std::sync::Mutex;
10
11 pub struct TestFeeEstimator {
12         pub sat_per_vbyte: u64,
13 }
14 impl chaininterface::FeeEstimator for TestFeeEstimator {
15         fn get_est_sat_per_vbyte(&self, _confirmation_target: ConfirmationTarget) -> u64 {
16                 self.sat_per_vbyte
17         }
18 }
19
20 pub struct TestChannelMonitor {
21
22 }
23 impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
24         fn add_update_monitor(&self, _funding_txo: (Sha256dHash, u16), _monitor: channelmonitor::ChannelMonitor) -> Result<(), HandleError> {
25                 //TODO!
26                 Ok(())
27         }
28 }
29
30 pub struct TestBroadcaster {
31         pub txn_broadcasted: Mutex<Vec<Transaction>>,
32 }
33 impl chaininterface::BroadcasterInterface for TestBroadcaster {
34         fn broadcast_transaction(&self, tx: &Transaction) {
35                 self.txn_broadcasted.lock().unwrap().push(tx.clone());
36         }
37 }