>,
pub network_graph: Arc<NetworkGraph<&'a TestLogger>>,
pub next_routes: Mutex<VecDeque<(RouteParameters, Option<Result<Route, LightningError>>)>>,
+ pub next_blinded_payment_paths: Mutex<Vec<(BlindedPayInfo, BlindedPath)>>,
pub scorer: &'a RwLock<TestScorer>,
}
router: DefaultRouter::new(network_graph.clone(), logger, entropy_source, scorer, ()),
network_graph,
next_routes: Mutex::new(VecDeque::new()),
+ next_blinded_payment_paths: Mutex::new(Vec::new()),
scorer,
}
}
let mut expected_routes = self.next_routes.lock().unwrap();
expected_routes.push_back((query, None));
}
+
+ pub fn expect_blinded_payment_paths(&self, mut paths: Vec<(BlindedPayInfo, BlindedPath)>) {
+ let mut expected_paths = self.next_blinded_payment_paths.lock().unwrap();
+ core::mem::swap(&mut *expected_paths, &mut paths);
+ }
}
impl<'a> Router for TestRouter<'a> {
&self, recipient: PublicKey, first_hops: Vec<ChannelDetails>, tlvs: ReceiveTlvs,
amount_msats: u64, secp_ctx: &Secp256k1<T>,
) -> Result<Vec<(BlindedPayInfo, BlindedPath)>, ()> {
- self.router.create_blinded_payment_paths(
- recipient, first_hops, tlvs, amount_msats, secp_ctx
- )
+ let mut expected_paths = self.next_blinded_payment_paths.lock().unwrap();
+ if expected_paths.is_empty() {
+ self.router.create_blinded_payment_paths(
+ recipient, first_hops, tlvs, amount_msats, secp_ctx
+ )
+ } else {
+ Ok(core::mem::take(&mut *expected_paths))
+ }
}
}