Split out BroadcastInterface, ChainWatchInterface monitors re-enter from called listeners
[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::util::hash::Sha256dHash;
7 use bitcoin::blockdata::transaction::Transaction;
8 use bitcoin::blockdata::script::Script;
9
10 use std::sync::Weak;
11
12 pub struct TestFeeEstimator {
13         pub sat_per_vbyte: u64,
14 }
15 impl chaininterface::FeeEstimator for TestFeeEstimator {
16         fn get_est_sat_per_vbyte(&self, _confirmation_target: ConfirmationTarget) -> u64 {
17                 self.sat_per_vbyte
18         }
19 }
20
21 pub struct TestWatchInterface {
22         pub watch_util: chaininterface::ChainWatchInterfaceUtil,
23 }
24 impl chaininterface::ChainWatchInterface for TestWatchInterface {
25         fn install_watch_script(&self, _script_pub_key: Script) {
26                 unimplemented!();
27         }
28         fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32)) {
29                 unimplemented!();
30         }
31         fn watch_all_txn(&self) {
32                 unimplemented!();
33         }
34         fn register_listener(&self, listener: Weak<chaininterface::ChainListener>) {
35                 self.watch_util.register_listener(listener);
36         }
37 }
38 impl TestWatchInterface {
39         pub fn new() -> TestWatchInterface {
40                 TestWatchInterface {
41                         watch_util: chaininterface::ChainWatchInterfaceUtil::new(),
42                 }
43         }
44 }
45
46 pub struct TestChannelMonitor {
47
48 }
49 impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
50         fn add_update_monitor(&self, _funding_txo: (Sha256dHash, u16), _monitor: channelmonitor::ChannelMonitor) -> Result<(), HandleError> {
51                 //TODO!
52                 Ok(())
53         }
54 }