@@ -143,7 +143,9 @@ impl<'a> Router for TestRouter<'a> {
143
143
& self , payer : & PublicKey , params : & RouteParameters , first_hops : Option < & [ & ChannelDetails ] > ,
144
144
inflight_htlcs : InFlightHtlcs
145
145
) -> Result < Route , msgs:: LightningError > {
146
- if let Some ( ( find_route_query, find_route_res) ) = self . next_routes . lock ( ) . unwrap ( ) . pop_front ( ) {
146
+ let route_res;
147
+ let next_route_opt = self . next_routes . lock ( ) . unwrap ( ) . pop_front ( ) ;
148
+ if let Some ( ( find_route_query, find_route_res) ) = next_route_opt {
147
149
assert_eq ! ( find_route_query, * params) ;
148
150
if let Ok ( ref route) = find_route_res {
149
151
assert_eq ! ( route. route_params, Some ( find_route_query) ) ;
@@ -201,10 +203,18 @@ impl<'a> Router for TestRouter<'a> {
201
203
}
202
204
}
203
205
}
204
- return find_route_res;
205
- }
206
+ route_res = find_route_res;
207
+ } else {
208
+ route_res = self . router . find_route ( payer, params, first_hops, inflight_htlcs) ;
209
+ } ;
206
210
207
- self . router . find_route ( payer, params, first_hops, inflight_htlcs)
211
+ if let Ok ( route) = & route_res {
212
+ // Previously, `Route`s failed to round-trip through serialization due to a write/read
213
+ // mismatch. Thus, here we test all test-generated routes round-trip:
214
+ let ser = route. encode ( ) ;
215
+ assert_eq ! ( Route :: read( & mut & ser[ ..] ) . unwrap( ) , * route) ;
216
+ }
217
+ route_res
208
218
}
209
219
210
220
fn create_blinded_payment_paths <
0 commit comments