Skip to content

Commit fbe4bf1

Browse files
Add find_route test util
And use it in the multihop blinded path receive failure test. Will be used in the next commit to test receiving an invalid blinded final onion payload. We can't use the existing get_route test util here because blinded payments rely on the sender adding a random shadow CLTV offset to the final hop; without this the payment will be failed with cltv-expiry-too-soon.
1 parent d99089e commit fbe4bf1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ fn multi_hop_receiver_fail() {
474474
nodes.iter().skip(1).map(|n| n.node.get_our_node_id()).collect(), &[&chan_upd_1_2],
475475
&chanmon_cfgs[2].keys_manager);
476476

477+
let route = find_route(&nodes[0], &route_params).unwrap();
478+
node_cfgs[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
477479
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::spontaneous_empty(), PaymentId(payment_hash.0), route_params, Retry::Attempts(0)).unwrap();
478480
check_added_monitors(&nodes[0], 1);
479481
pass_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], amt_msat, payment_hash, payment_secret);

lightning/src/ln/functional_test_utils.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,18 @@ pub fn get_route(send_node: &Node, route_params: &RouteParameters) -> Result<Rou
19711971
)
19721972
}
19731973

1974+
/// Like `get_route` above, but adds a random CLTV offset to the final hop.
1975+
pub fn find_route(send_node: &Node, route_params: &RouteParameters) -> Result<Route, msgs::LightningError> {
1976+
let scorer = TestScorer::new();
1977+
let keys_manager = TestKeysInterface::new(&[0u8; 32], bitcoin::network::constants::Network::Testnet);
1978+
let random_seed_bytes = keys_manager.get_secure_random_bytes();
1979+
router::find_route(
1980+
&send_node.node.get_our_node_id(), route_params, &send_node.network_graph,
1981+
Some(&send_node.node.list_usable_channels().iter().collect::<Vec<_>>()),
1982+
send_node.logger, &scorer, &Default::default(), &random_seed_bytes
1983+
)
1984+
}
1985+
19741986
/// Gets a route from the given sender to the node described in `payment_params`.
19751987
///
19761988
/// Don't use this, use the identically-named function instead.

0 commit comments

Comments
 (0)