Clean up excess \ns in route debug, use all debug encoders
[rust-lightning] / src / util / test_utils.rs
index 5eec3f027897b609e453ff5ec91f130b8e2edeb6..aff84735ece7e6a15355a1ef7710b80b97d8de9c 100644 (file)
@@ -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);
+               }
+       }
+}