// Add the HTLC along the first hop.
let fail_path_msgs_1 = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
- let (update_add, commitment_signed) = match fail_path_msgs_1 {
- MessageSendEvent::UpdateHTLCs { node_id: _, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref update_fee, ref commitment_signed } } => {
- assert_eq!(update_add_htlcs.len(), 1);
- assert!(update_fail_htlcs.is_empty());
- assert!(update_fulfill_htlcs.is_empty());
- assert!(update_fail_malformed_htlcs.is_empty());
- assert!(update_fee.is_none());
- (update_add_htlcs[0].clone(), commitment_signed.clone())
- },
- _ => panic!("Unexpected event"),
- };
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
- commitment_signed_dance!(nodes[2], nodes[0], commitment_signed, false);
+ let send_event = SendEvent::from_event(fail_path_msgs_1);
+ nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ commitment_signed_dance!(nodes[2], nodes[0], &send_event.commitment_msg, false);
// Attempt to forward the payment and complete the 2nd path's failure.
expect_pending_htlcs_forwardable!(&nodes[2]);
// Add the HTLC along the first hop.
let fail_path_msgs_1 = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
- let (update_add, commitment_signed) = match fail_path_msgs_1 {
- MessageSendEvent::UpdateHTLCs {
- node_id: _,
- updates: msgs::CommitmentUpdate {
- ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs,
- ref update_fail_malformed_htlcs, ref update_fee, ref commitment_signed
- }
- } => {
- assert_eq!(update_add_htlcs.len(), 1);
- assert!(update_fail_htlcs.is_empty());
- assert!(update_fulfill_htlcs.is_empty());
- assert!(update_fail_malformed_htlcs.is_empty());
- assert!(update_fee.is_none());
- (update_add_htlcs[0].clone(), commitment_signed.clone())
- },
- _ => panic!("Unexpected event"),
- };
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
- commitment_signed_dance!(nodes[2], nodes[0], commitment_signed, false);
+ let send_event = SendEvent::from_event(fail_path_msgs_1);
+ nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ commitment_signed_dance!(nodes[2], nodes[0], &send_event.commitment_msg, false);
// Attempt to forward the payment and complete the 2nd path's failure.
expect_pending_htlcs_forwardable!(&nodes[2]);
route.paths.remove(0);
route_params.final_value_msat -= first_path_value;
+ route.route_params.as_mut().map(|p| p.final_value_msat -= first_path_value);
route_params.payment_params.previously_failed_channels.push(chan_4_update.contents.short_channel_id);
// Check the remaining max total routing fee for the second attempt accounts only for 1_000 msat
let payment_params = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id(), TEST_FINAL_CLTV)
.with_expiry_time(payment_expiry_secs as u64)
.with_bolt11_features(invoice_features).unwrap();
- let route_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat);
- // Configure the initial send, retry1 and retry2's paths.
+ // Configure the initial send path
+ let mut route_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat);
+ route_params.max_total_routing_fee_msat = None;
+
let send_route = Route {
paths: vec![
Path { hops: vec![RouteHop {
],
route_params: Some(route_params.clone()),
};
+ nodes[0].router.expect_find_route(route_params.clone(), Ok(send_route));
+
+ // Configure the retry1 paths
+ let mut payment_params = route_params.payment_params.clone();
+ payment_params.previously_failed_channels.push(chan_2_id);
+ let mut retry_1_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat / 2);
+ retry_1_params.max_total_routing_fee_msat = None;
+
let retry_1_route = Route {
paths: vec![
Path { hops: vec![RouteHop {
maybe_announced_channel: true,
}], blinded_tail: None },
],
- route_params: Some(route_params.clone()),
+ route_params: Some(retry_1_params.clone()),
};
+ nodes[0].router.expect_find_route(retry_1_params.clone(), Ok(retry_1_route));
+
+ // Configure the retry2 path
+ let mut payment_params = retry_1_params.payment_params.clone();
+ payment_params.previously_failed_channels.push(chan_3_id);
+ let mut retry_2_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat / 4);
+ retry_2_params.max_total_routing_fee_msat = None;
+
let retry_2_route = Route {
paths: vec![
Path { hops: vec![RouteHop {
maybe_announced_channel: true,
}], blinded_tail: None },
],
- route_params: Some(route_params.clone()),
+ route_params: Some(retry_2_params.clone()),
};
- nodes[0].router.expect_find_route(route_params.clone(), Ok(send_route));
- let mut payment_params = route_params.payment_params.clone();
- payment_params.previously_failed_channels.push(chan_2_id);
- nodes[0].router.expect_find_route(
- RouteParameters::from_payment_params_and_value(payment_params, amt_msat / 2),
- Ok(retry_1_route));
- let mut payment_params = route_params.payment_params.clone();
- payment_params.previously_failed_channels.push(chan_3_id);
- nodes[0].router.expect_find_route(
- RouteParameters::from_payment_params_and_value(payment_params, amt_msat / 4),
- Ok(retry_2_route));
+ nodes[0].router.expect_find_route(retry_2_params, Ok(retry_2_route));
// Send a payment that will partially fail on send, then partially fail on retry, then succeed.
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::secret_only(payment_secret),
let payment_params = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id(), TEST_FINAL_CLTV)
.with_expiry_time(payment_expiry_secs as u64)
.with_bolt11_features(invoice_features).unwrap();
- let route_params = RouteParameters::from_payment_params_and_value(
+ let mut route_params = RouteParameters::from_payment_params_and_value(
payment_params.clone(), amt_msat);
+ route_params.max_total_routing_fee_msat = None;
let chans = nodes[0].node.list_usable_channels();
let mut route = Route {
route.paths[1].hops[0].fee_msat = 50_000_000;
let mut pay_params = route.route_params.clone().unwrap().payment_params;
pay_params.previously_failed_channels.push(chans[1].short_channel_id.unwrap());
- nodes[0].router.expect_find_route(
- // Note that the second request here requests the amount we originally failed to send,
- // not the amount remaining on the full payment, which should be changed.
- RouteParameters::from_payment_params_and_value(pay_params, 100_000_001),
- Ok(route.clone()));
+
+ let mut retry_params = RouteParameters::from_payment_params_and_value(pay_params, 100_000_000);
+ retry_params.max_total_routing_fee_msat = None;
+ route.route_params.as_mut().unwrap().final_value_msat = 100_000_000;
+ nodes[0].router.expect_find_route(retry_params, Ok(route.clone()));
{
let scorer = chanmon_cfgs[0].scorer.read().unwrap();
let payment_params = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id(), TEST_FINAL_CLTV)
.with_expiry_time(payment_expiry_secs as u64)
.with_bolt11_features(invoice_features).unwrap();
- let route_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat);
+ let mut route_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat);
+ route_params.max_total_routing_fee_msat = None;
let mut route = Route {
paths: vec![
maybe_announced_channel: true,
}], blinded_tail: None }
],
- route_params: Some(RouteParameters::from_payment_params_and_value(
- PaymentParameters::from_node_id(nodes[2].node.get_our_node_id(), TEST_FINAL_CLTV),
- 100_000_000)),
+ route_params: Some(route_params.clone()),
};
+ route.route_params.as_mut().unwrap().max_total_routing_fee_msat = None;
nodes[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
let mut second_payment_params = route_params.payment_params.clone();
second_payment_params.previously_failed_channels = vec![chan_2_scid, chan_2_scid];
// On retry, we'll only return one path
route.paths.remove(1);
route.paths[0].hops[1].fee_msat = amt_msat;
- nodes[0].router.expect_find_route(
- RouteParameters::from_payment_params_and_value(second_payment_params, amt_msat),
- Ok(route.clone()));
+ let mut retry_params = RouteParameters::from_payment_params_and_value(second_payment_params, amt_msat);
+ retry_params.max_total_routing_fee_msat = None;
+ nodes[0].router.expect_find_route(retry_params, Ok(route.clone()));
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::secret_only(payment_secret),
PaymentId(payment_hash.0), route_params, Retry::Attempts(1)).unwrap();
let payment_params = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id(), TEST_FINAL_CLTV)
.with_expiry_time(payment_expiry_secs as u64)
.with_bolt11_features(invoice_features).unwrap();
- let route_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat);
+ let mut route_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat);
+ route_params.max_total_routing_fee_msat = None;
let mut route = Route {
paths: vec![
maybe_announced_channel: true,
}], blinded_tail: None }
],
- route_params: Some(RouteParameters::from_payment_params_and_value(
- PaymentParameters::from_node_id(nodes[2].node.get_our_node_id(), TEST_FINAL_CLTV),
- 100_000_000)),
+ route_params: Some(route_params.clone()),
};
+
nodes[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
+
let mut second_payment_params = route_params.payment_params.clone();
second_payment_params.previously_failed_channels = vec![chan_2_scid];
// On retry, we'll only be asked for one path (or 100k sats)
route.paths.remove(0);
- nodes[0].router.expect_find_route(
- RouteParameters::from_payment_params_and_value(second_payment_params, amt_msat / 2),
- Ok(route.clone()));
+ let mut retry_params = RouteParameters::from_payment_params_and_value(second_payment_params, amt_msat / 2);
+ retry_params.max_total_routing_fee_msat = None;
+ route.route_params.as_mut().unwrap().final_value_msat = amt_msat / 2;
+ nodes[0].router.expect_find_route(retry_params, Ok(route.clone()));
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::secret_only(payment_secret),
PaymentId(payment_hash.0), route_params, Retry::Attempts(1)).unwrap();
maybe_announced_channel: true,
}], blinded_tail: None }
],
- route_params: Some(RouteParameters {
- payment_params: PaymentParameters::from_node_id(nodes[1].node.get_our_node_id(), TEST_FINAL_CLTV),
- final_value_msat: amt_msat - amt_msat / 1000,
- max_total_routing_fee_msat: Some(500_000),
- }),
+ route_params: Some(route_params.clone()),
};
nodes[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
// from here on out, the retry `RouteParameters` amount will be amt/1000
route_params.final_value_msat /= 1000;
+ route.route_params.as_mut().unwrap().final_value_msat /= 1000;
route.paths.pop();
let end_time = Instant::now() + Duration::from_secs(1);