@@ -118,6 +118,7 @@ pub struct TestRouter<'a> {
118
118
> ,
119
119
pub network_graph : Arc < NetworkGraph < & ' a TestLogger > > ,
120
120
pub next_routes : Mutex < VecDeque < ( RouteParameters , Option < Result < Route , LightningError > > ) > > ,
121
+ pub next_blinded_payment_paths : Mutex < Vec < ( BlindedPayInfo , BlindedPath ) > > ,
121
122
pub scorer : & ' a RwLock < TestScorer > ,
122
123
}
123
124
@@ -131,6 +132,7 @@ impl<'a> TestRouter<'a> {
131
132
router : DefaultRouter :: new ( network_graph. clone ( ) , logger, entropy_source, scorer, ( ) ) ,
132
133
network_graph,
133
134
next_routes : Mutex :: new ( VecDeque :: new ( ) ) ,
135
+ next_blinded_payment_paths : Mutex :: new ( Vec :: new ( ) ) ,
134
136
scorer,
135
137
}
136
138
}
@@ -144,6 +146,11 @@ impl<'a> TestRouter<'a> {
144
146
let mut expected_routes = self . next_routes . lock ( ) . unwrap ( ) ;
145
147
expected_routes. push_back ( ( query, None ) ) ;
146
148
}
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
+ }
147
154
}
148
155
149
156
impl < ' a > Router for TestRouter < ' a > {
@@ -235,9 +242,14 @@ impl<'a> Router for TestRouter<'a> {
235
242
& self , recipient : PublicKey , first_hops : Vec < ChannelDetails > , tlvs : ReceiveTlvs ,
236
243
amount_msats : u64 , secp_ctx : & Secp256k1 < T > ,
237
244
) -> 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
+ }
241
253
}
242
254
}
243
255
0 commit comments