initial checkin
[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 broadcast_transaction(&self, _tx: &Transaction) {
35                 unimplemented!();
36         }
37         fn register_listener(&self, listener: Weak<chaininterface::ChainListener>) {
38                 self.watch_util.register_listener(listener);
39         }
40 }
41 impl TestWatchInterface {
42         pub fn new() -> TestWatchInterface {
43                 TestWatchInterface {
44                         watch_util: chaininterface::ChainWatchInterfaceUtil::new(),
45                 }
46         }
47 }
48
49 pub struct TestChannelMonitor {
50
51 }
52 impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
53         fn add_update_monitor(&self, _funding_txo: (Sha256dHash, u16), _monitor: channelmonitor::ChannelMonitor) -> Result<(), HandleError> {
54                 //TODO!
55                 Ok(())
56         }
57 }