Skip to content

Commit 177a612

Browse files
committed
Correct route construction in chanmon_consistency fuzz
bcaba29 started returning pre-built `Route`s from the router in the `chanmon_consistency` fuzzer. In doing so, it didn't properly fill in the `route_parms` field which is expected to match the requested parameters. This causes a debug assertion when sending. Here we fix this by setting the correct `route_params`.
1 parent 351d414 commit 177a612

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ fn send_payment(
552552
.find(|chan| chan.short_channel_id == Some(dest_chan_id))
553553
.map(|chan| (chan.next_outbound_htlc_minimum_msat, chan.next_outbound_htlc_limit_msat))
554554
.unwrap_or((0, 0));
555+
let route_params = RouteParameters::from_payment_params_and_value(
556+
PaymentParameters::from_node_id(source.get_our_node_id(), TEST_FINAL_CLTV),
557+
amt,
558+
);
555559
source.router.next_routes.lock().unwrap().push_back(Route {
556560
paths: vec![Path {
557561
hops: vec![RouteHop {
@@ -565,12 +569,8 @@ fn send_payment(
565569
}],
566570
blinded_tail: None,
567571
}],
568-
route_params: None,
572+
route_params: Some(route_params.clone()),
569573
});
570-
let route_params = RouteParameters::from_payment_params_and_value(
571-
PaymentParameters::from_node_id(source.get_our_node_id(), TEST_FINAL_CLTV),
572-
amt,
573-
);
574574
if let Err(err) = source.send_payment(
575575
payment_hash,
576576
RecipientOnionFields::secret_only(payment_secret),
@@ -622,6 +622,10 @@ fn send_hop_payment(
622622
.map(|chan| (chan.next_outbound_htlc_minimum_msat, chan.next_outbound_htlc_limit_msat))
623623
.unwrap_or((0, 0));
624624
let first_hop_fee = 50_000;
625+
let route_params = RouteParameters::from_payment_params_and_value(
626+
PaymentParameters::from_node_id(source.get_our_node_id(), TEST_FINAL_CLTV),
627+
amt,
628+
);
625629
source.router.next_routes.lock().unwrap().push_back(Route {
626630
paths: vec![Path {
627631
hops: vec![
@@ -646,12 +650,8 @@ fn send_hop_payment(
646650
],
647651
blinded_tail: None,
648652
}],
649-
route_params: None,
653+
route_params: Some(route_params.clone()),
650654
});
651-
let route_params = RouteParameters::from_payment_params_and_value(
652-
PaymentParameters::from_node_id(source.get_our_node_id(), TEST_FINAL_CLTV),
653-
amt,
654-
);
655655
if let Err(err) = source.send_payment(
656656
payment_hash,
657657
RecipientOnionFields::secret_only(payment_secret),

lightning/src/ln/outbound_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,8 @@ impl OutboundPayments {
12261226

12271227
if route.route_params.as_ref() != Some(route_params) {
12281228
debug_assert!(false,
1229-
"Routers are expected to return a Route which includes the requested RouteParameters");
1229+
"Routers are expected to return a Route which includes the requested RouteParameters. Got {:?}, expected {:?}",
1230+
route.route_params, route_params);
12301231
route.route_params = Some(route_params.clone());
12311232
}
12321233

0 commit comments

Comments
 (0)