X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Ftest_utils.rs;h=5d657b13df585922626d37c9950d303838c3d8ae;hb=f7dd69240afcd3a0087f7796824a9e2697ed85cf;hp=beb50940e45dbedb7548c1b1dbfc4acf76f64c8f;hpb=6185a2819090bd077954244c5e2adaab5efcaa1a;p=rust-lightning diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs index beb50940..5d657b13 100644 --- a/src/util/test_utils.rs +++ b/src/util/test_utils.rs @@ -3,11 +3,10 @@ use chain::chaininterface::ConfirmationTarget; use ln::channelmonitor; use ln::msgs::HandleError; -use bitcoin::util::hash::Sha256dHash; use bitcoin::blockdata::transaction::Transaction; -use bitcoin::blockdata::script::Script; +use bitcoin::util::hash::Sha256dHash; -use std::sync::Weak; +use std::sync::Mutex; pub struct TestFeeEstimator { pub sat_per_vbyte: u64, @@ -18,34 +17,6 @@ impl chaininterface::FeeEstimator for TestFeeEstimator { } } -pub struct TestWatchInterface { - pub watch_util: chaininterface::ChainWatchInterfaceUtil, -} -impl chaininterface::ChainWatchInterface for TestWatchInterface { - fn install_watch_script(&self, _script_pub_key: Script) { - unimplemented!(); - } - fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32)) { - unimplemented!(); - } - fn watch_all_txn(&self) { - unimplemented!(); - } - fn broadcast_transaction(&self, _tx: &Transaction) { - unimplemented!(); - } - fn register_listener(&self, listener: Weak) { - self.watch_util.register_listener(listener); - } -} -impl TestWatchInterface { - pub fn new() -> TestWatchInterface { - TestWatchInterface { - watch_util: chaininterface::ChainWatchInterfaceUtil::new(), - } - } -} - pub struct TestChannelMonitor { } @@ -55,3 +26,12 @@ impl channelmonitor::ManyChannelMonitor for TestChannelMonitor { Ok(()) } } + +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()); + } +}