X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Ftest_utils.rs;h=aff84735ece7e6a15355a1ef7710b80b97d8de9c;hb=5ee88ad9f2c9634eb5a1a5131614047028aba757;hp=5eec3f027897b609e453ff5ec91f130b8e2edeb6;hpb=c0bcb4b532aeade9717fa5103e0d0f3010b46193;p=rust-lightning diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs index 5eec3f02..aff84735 100644 --- a/src/util/test_utils.rs +++ b/src/util/test_utils.rs @@ -5,6 +5,7 @@ use ln::channelmonitor; use ln::msgs; use ln::msgs::{HandleError}; use util::events; +use util::logger::{Logger, Level, Record}; use bitcoin::blockdata::transaction::Transaction; @@ -14,11 +15,11 @@ use std::sync::{Arc,Mutex}; use std::{mem}; pub struct TestFeeEstimator { - pub sat_per_vbyte: u64, + pub sat_per_kw: u64, } impl chaininterface::FeeEstimator for TestFeeEstimator { - fn get_est_sat_per_vbyte(&self, _confirmation_target: ConfirmationTarget) -> u64 { - self.sat_per_vbyte + fn get_est_sat_per_1000_weight(&self, _confirmation_target: ConfirmationTarget) -> u64 { + self.sat_per_kw } } @@ -145,3 +146,26 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler { } fn handle_htlc_fail_channel_update(&self, _update: &msgs::HTLCFailChannelUpdate) {} } + +pub struct TestLogger { + level: Level, +} + +impl TestLogger { + pub fn new() -> TestLogger { + TestLogger { + level: Level::Trace, + } + } + pub fn enable(&mut self, level: Level) { + self.level = level; + } +} + +impl Logger for TestLogger { + fn log(&self, record: &Record) { + if self.level >= record.level { + println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args); + } + } +}