Merge pull request #19 from TheBlueMatt/2018-04-error-handling-framework
[rust-lightning] / src / util / test_utils.rs
index df13e1c90252fc4427321ca9944d1cdc1e0f8a90..5d657b13df585922626d37c9950d303838c3d8ae 100644 (file)
@@ -3,8 +3,11 @@ use chain::chaininterface::ConfirmationTarget;
 use ln::channelmonitor;
 use ln::msgs::HandleError;
 
+use bitcoin::blockdata::transaction::Transaction;
 use bitcoin::util::hash::Sha256dHash;
 
+use std::sync::Mutex;
+
 pub struct TestFeeEstimator {
        pub sat_per_vbyte: u64,
 }
@@ -23,3 +26,12 @@ impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
                Ok(())
        }
 }
+
+pub struct TestBroadcaster {
+       pub txn_broadcasted: Mutex<Vec<Transaction>>,
+}
+impl chaininterface::BroadcasterInterface for TestBroadcaster {
+       fn broadcast_transaction(&self, tx: &Transaction) {
+               self.txn_broadcasted.lock().unwrap().push(tx.clone());
+       }
+}