X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Ftest_utils.rs;h=b5fbbd5940924483545fb5d11c298658dc75feda;hb=7c24fea4fe8af6ae1b51c5ef6e792113d7830abb;hp=5eec3f027897b609e453ff5ec91f130b8e2edeb6;hpb=20fa9d331d4fadb766199011eac3aef852531809;p=rust-lightning diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs index 5eec3f027..b5fbbd594 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::Off, + } + } + 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); + } + } +}