rust-lightning/src/util/test_utils.rs

38 lines
980 B
Rust
Raw Normal View History

2017-12-25 01:05:27 -05:00
use chain::chaininterface;
use chain::chaininterface::ConfirmationTarget;
use ln::channelmonitor;
use ln::msgs::HandleError;
2018-03-26 16:48:18 -04:00
use bitcoin::blockdata::transaction::Transaction;
2017-12-25 01:05:27 -05:00
use bitcoin::util::hash::Sha256dHash;
use std::sync::Mutex;
2017-12-25 01:05:27 -05:00
pub struct TestFeeEstimator {
pub sat_per_vbyte: u64,
}
impl chaininterface::FeeEstimator for TestFeeEstimator {
fn get_est_sat_per_vbyte(&self, _confirmation_target: ConfirmationTarget) -> u64 {
self.sat_per_vbyte
}
}
pub struct TestChannelMonitor {
}
impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
fn add_update_monitor(&self, _funding_txo: (Sha256dHash, u16), _monitor: channelmonitor::ChannelMonitor) -> Result<(), HandleError> {
//TODO!
Ok(())
}
}
2018-03-26 16:48:18 -04:00
pub struct TestBroadcaster {
pub txn_broadcasted: Mutex<Vec<Transaction>>,
2018-03-26 16:48:18 -04:00
}
impl chaininterface::BroadcasterInterface for TestBroadcaster {
fn broadcast_transaction(&self, tx: &Transaction) {
self.txn_broadcasted.lock().unwrap().push(tx.clone());
2018-03-26 16:48:18 -04:00
}
}