Parameterize ChannelManager by a Router trait
[rust-lightning] / lightning / src / util / test_utils.rs
index 4f74791a173d120f7f84e3c68c3951dd0a08af8b..2cac5a874a62f0b87770e642905527879ba058ff 100644 (file)
@@ -21,6 +21,7 @@ use crate::ln::channelmanager;
 use crate::ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
 use crate::ln::{msgs, wire};
 use crate::ln::script::ShutdownScript;
+use crate::routing::router::{InFlightHtlcs, Route, RouteHop, RouteParameters, Router};
 use crate::routing::scoring::FixedPenaltyScorer;
 use crate::util::enforcing_trait_impls::{EnforcingSigner, EnforcementState};
 use crate::util::events;
@@ -71,6 +72,24 @@ impl chaininterface::FeeEstimator for TestFeeEstimator {
        }
 }
 
+pub struct TestRouter {}
+
+impl Router for TestRouter {
+       fn find_route(
+               &self, _payer: &PublicKey, _params: &RouteParameters, _first_hops: Option<&[&channelmanager::ChannelDetails]>,
+               _inflight_htlcs: InFlightHtlcs
+       ) -> Result<Route, msgs::LightningError> {
+               Err(msgs::LightningError {
+                       err: String::from("Not implemented"),
+                       action: msgs::ErrorAction::IgnoreError
+               })
+       }
+       fn notify_payment_path_failed(&self, _path: &[&RouteHop], _short_channel_id: u64) {}
+       fn notify_payment_path_successful(&self, _path: &[&RouteHop]) {}
+       fn notify_payment_probe_successful(&self, _path: &[&RouteHop]) {}
+       fn notify_payment_probe_failed(&self, _path: &[&RouteHop], _short_channel_id: u64) {}
+}
+
 pub struct OnlyReadsKeysInterface {}
 
 impl EntropySource for OnlyReadsKeysInterface {