@@ -118,6 +118,7 @@ pub struct TestRouter<'a> {
118118 > ,
119119 pub network_graph : Arc < NetworkGraph < & ' a TestLogger > > ,
120120 pub next_routes : Mutex < VecDeque < ( RouteParameters , Option < Result < Route , LightningError > > ) > > ,
121+ pub next_blinded_payment_paths : Mutex < Vec < ( BlindedPayInfo , BlindedPath ) > > ,
121122 pub scorer : & ' a RwLock < TestScorer > ,
122123}
123124
@@ -131,6 +132,7 @@ impl<'a> TestRouter<'a> {
131132 router : DefaultRouter :: new ( network_graph. clone ( ) , logger, entropy_source, scorer, ( ) ) ,
132133 network_graph,
133134 next_routes : Mutex :: new ( VecDeque :: new ( ) ) ,
135+ next_blinded_payment_paths : Mutex :: new ( Vec :: new ( ) ) ,
134136 scorer,
135137 }
136138 }
@@ -144,6 +146,11 @@ impl<'a> TestRouter<'a> {
144146 let mut expected_routes = self . next_routes . lock ( ) . unwrap ( ) ;
145147 expected_routes. push_back ( ( query, None ) ) ;
146148 }
149+
150+ pub fn expect_blinded_payment_paths ( & self , mut paths : Vec < ( BlindedPayInfo , BlindedPath ) > ) {
151+ let mut expected_paths = self . next_blinded_payment_paths . lock ( ) . unwrap ( ) ;
152+ core:: mem:: swap ( & mut * expected_paths, & mut paths) ;
153+ }
147154}
148155
149156impl < ' a > Router for TestRouter < ' a > {
@@ -235,9 +242,14 @@ impl<'a> Router for TestRouter<'a> {
235242 & self , recipient : PublicKey , first_hops : Vec < ChannelDetails > , tlvs : ReceiveTlvs ,
236243 amount_msats : u64 , secp_ctx : & Secp256k1 < T > ,
237244 ) -> Result < Vec < ( BlindedPayInfo , BlindedPath ) > , ( ) > {
238- self . router . create_blinded_payment_paths (
239- recipient, first_hops, tlvs, amount_msats, secp_ctx
240- )
245+ let mut expected_paths = self . next_blinded_payment_paths . lock ( ) . unwrap ( ) ;
246+ if expected_paths. is_empty ( ) {
247+ self . router . create_blinded_payment_paths (
248+ recipient, first_hops, tlvs, amount_msats, secp_ctx
249+ )
250+ } else {
251+ Ok ( core:: mem:: take ( & mut * expected_paths) )
252+ }
241253 }
242254}
243255
0 commit comments