let ev = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
pass_along_path(&nodes[0], expected_route[1], amt_msat, payment_hash.clone(),
Some(payment_secret), ev.clone(), true, None);
- claim_payment_along_route(&nodes[0], expected_route, false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], expected_route, payment_preimage)
+ );
}
#[test]
let ev = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
pass_along_path(&nodes[0], expected_route[1], amt_msat, payment_hash.clone(),
Some(payment_secret), ev.clone(), true, None);
- claim_payment_along_route(&nodes[0], expected_route, false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], expected_route, payment_preimage)
+ );
}
enum ForwardCheckFail {
let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
pass_along_path(&nodes[0], expected_route[0], amt_msat, payment_hash, Some(payment_secret), ev.clone(), true, Some(keysend_preimage));
- claim_payment_along_route(&nodes[0], expected_route, false, keysend_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], expected_route, keysend_preimage)
+ );
}
#[test]
let ev = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
pass_along_path(&nodes[0], expected_route[1], amt_msat, payment_hash.clone(),
Some(payment_secret), ev.clone(), true, Some(keysend_preimage));
- claim_payment_along_route(&nodes[0], expected_route, false, keysend_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], expected_route, keysend_preimage)
+ );
}
#[test]
assert_eq!(events.len(), 1);
pass_along_path(&nodes[0], &[&nodes[2], &nodes[3]], 200_000, payment_hash.clone(), Some(payment_secret), events.pop().unwrap(), true, None);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], payment_preimage)
+ );
}
#[test]
expected_total_fee_msat
}
-pub fn claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, our_payment_preimage: PaymentPreimage) {
- let expected_total_fee_msat = do_claim_payment_along_route(
- ClaimAlongRouteArgs::new(origin_node, expected_paths, our_payment_preimage)
- .skip_last(skip_last)
- );
+pub fn claim_payment_along_route(args: ClaimAlongRouteArgs) {
+ let origin_node = args.origin_node;
+ let payment_preimage = args.payment_preimage;
+ let skip_last = args.skip_last;
+ let expected_total_fee_msat = do_claim_payment_along_route(args);
if !skip_last {
- expect_payment_sent!(origin_node, our_payment_preimage, Some(expected_total_fee_msat));
+ expect_payment_sent!(origin_node, payment_preimage, Some(expected_total_fee_msat));
}
}
pub fn claim_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], our_payment_preimage: PaymentPreimage) {
- claim_payment_along_route(origin_node, &[expected_route], false, our_payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(origin_node, &[expected_route], our_payment_preimage)
+ );
}
pub const TEST_FINAL_CLTV: u32 = 70;
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], true, payment_preimage_3);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage_3)
+ .skip_last(true)
+ );
fail_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], true, payment_hash_5);
let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
let ev = remove_first_msg_event_to_node(&expected_paths[1][0].node.get_our_node_id(), &mut events);
pass_along_path(&nodes[0], expected_paths[1], 101_000, our_payment_hash.clone(), Some(our_payment_secret), ev, true, None);
- claim_payment_along_route(&nodes[0], expected_paths, false, our_payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], expected_paths, our_payment_preimage)
+ );
}
fn do_test_overshoot_mpp(msat_amounts: &[u64], total_msat: u64) {
pass_along_path(&nodes[src_idx], expected_path, amount_received, our_payment_hash.clone(), Some(our_payment_secret), ev, became_claimable_now, None);
}
- claim_payment_along_route(&nodes[src_idx], &expected_paths, false, our_payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[src_idx], &expected_paths, our_payment_preimage)
+ );
}
#[test]
route.paths[1].hops[0].short_channel_id = chan_2_id;
route.paths[1].hops[1].short_channel_id = chan_4_id;
send_along_route_with_secret(&nodes[0], route, &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], 200_000, payment_hash, payment_secret);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], payment_preimage)
+ );
}
#[test]
.with_payment_secret(payment_secret)
.with_payment_metadata(payment_metadata.clone());
do_pass_along_path(args);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], payment_preimage)
+ );
// Check that the payment parameter for max path length will prevent us from routing past our
// next-hop peer given the payment_metadata size.
.with_payment_secret(payment_secret_2)
.with_payment_metadata(recipient_onion_allows_2_hops.payment_metadata.unwrap());
do_pass_along_path(args);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], false, payment_preimage_2);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage_2)
+ );
}
#[test]
.with_payment_secret(payment_secret)
.with_custom_tlvs(recipient_onion_max_custom_tlv_size.custom_tlvs.clone());
do_pass_along_path(args);
- claim_payment_along_route(&nodes[1], &[&[&nodes[2]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[1], &[&[&nodes[2]]], payment_preimage)
+ );
// If 1 byte is added to the custom TLV value, we'll fail to send prior to pathfinding.
let mut recipient_onion_too_large_custom_tlv = recipient_onion_max_custom_tlv_size.clone();
.with_payment_secret(payment_secret)
.with_custom_tlvs(recipient_onion_allows_2_hops.custom_tlvs);
do_pass_along_path(args);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
+ );
}
#[test]
.with_payment_secret(payment_secret)
.with_custom_tlvs(recipient_onion_max_custom_tlv_size.custom_tlvs.clone());
do_pass_along_path(args);
- claim_payment_along_route(&nodes[1], &[&[&nodes[2], &nodes[3]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[1], &[&[&nodes[2], &nodes[3]]], payment_preimage)
+ );
// If 1 byte is added to the custom TLV value, we'll fail to send prior to pathfinding.
let mut recipient_onion_too_large_custom_tlv = recipient_onion_max_custom_tlv_size.clone();
.with_payment_secret(payment_secret)
.with_custom_tlvs(recipient_onion_allows_2_hops.custom_tlvs);
do_pass_along_path(args);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2], &nodes[3]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2], &nodes[3]]], payment_preimage)
+ );
}
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
pass_along_path(&nodes[0], &[&nodes[2], &nodes[3]], 2_000_000, payment_hash, Some(payment_secret), events.pop().unwrap(), true, None);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], payment_preimage)
+ );
}
#[test]
nodes[3].node.timer_tick_occurred();
}
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], payment_preimage)
+ );
}
}
let ev = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
pass_along_path(&nodes[0], expected_route[1], recv_value, payment_hash.clone(),
Some(payment_secret), ev.clone(), true, Some(payment_preimage));
- claim_payment_along_route(&nodes[0], expected_route, false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], expected_route, payment_preimage)
+ );
}
#[test]
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
pass_along_path(&nodes[0], &[&nodes[1]], amt_msat, payment_hash, Some(payment_secret), events.pop().unwrap(), true, Some(payment_preimage));
- claim_payment_along_route(&nodes[0], &[&[&nodes[1]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], payment_preimage)
+ );
}
#[test]
let mut msg_events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 1);
pass_along_path(&nodes[0], &[&nodes[1], &nodes[2]], amt_msat, payment_hash, Some(payment_secret), msg_events.pop().unwrap(), true, None);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
+ );
} else if test == AutoRetry::Spontaneous {
nodes[0].node.send_spontaneous_payment_with_retry(Some(payment_preimage),
RecipientOnionFields::spontaneous_empty(), PaymentId(payment_hash.0), route_params,
let mut msg_events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 1);
pass_along_path(&nodes[0], &[&nodes[1], &nodes[2]], amt_msat, payment_hash, None, msg_events.pop().unwrap(), true, Some(payment_preimage));
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
+ );
} else if test == AutoRetry::FailAttempts {
// Ensure ChannelManager will not retry a payment if it has run out of payment attempts.
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::secret_only(payment_secret),
.with_payment_secret(payment_secret)
.with_custom_tlvs(custom_tlvs);
do_pass_along_path(args);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
+ );
}
#[test]
} else {
expect_pending_htlcs_forwardable!(nodes[3]);
expect_payment_claimable!(nodes[3], payment_hash, payment_secret, amt_msat);
- claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], payment_preimage)
+ );
}
}