]> git.bitcoin.ninja Git - rust-lightning/commitdiff
HTLC intercept test: swap hardcoded value for const
authorValentine Wallace <vwallace@protonmail.com>
Thu, 1 Dec 2022 05:16:31 +0000 (00:16 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Thu, 1 Dec 2022 05:16:31 +0000 (00:16 -0500)
lightning/src/ln/payment_tests.rs

index 034913ba9308224e54e4e53ff34ac03891d474bb..d9d22b6ca6b5bac82ac8c66b26b1e08124c4c878 100644 (file)
@@ -20,7 +20,7 @@ use crate::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChannelManager, MPP_TIM
 use crate::ln::msgs;
 use crate::ln::msgs::ChannelMessageHandler;
 use crate::routing::gossip::RoutingFees;
-use crate::routing::router::{find_route, get_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters};
+use crate::routing::router::{get_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters};
 use crate::util::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider};
 use crate::util::test_utils;
 use crate::util::errors::APIError;
@@ -1429,9 +1429,10 @@ fn do_test_intercepted_payment(test: InterceptTest) {
                final_value_msat: amt_msat,
                final_cltv_expiry_delta: TEST_FINAL_CLTV,
        };
-       let route = find_route(
-               &nodes[0].node.get_our_node_id(), &route_params, &nodes[0].network_graph, None, nodes[0].logger,
-               &scorer, &random_seed_bytes
+       let route = get_route(
+               &nodes[0].node.get_our_node_id(), &route_params.payment_params,
+               &nodes[0].network_graph.read_only(), None, route_params.final_value_msat,
+               route_params.final_cltv_expiry_delta, nodes[0].logger, &scorer, &random_seed_bytes
        ).unwrap();
 
        let (payment_hash, payment_secret) = nodes[2].node.create_inbound_payment(Some(amt_msat), 60 * 60).unwrap();
@@ -1540,8 +1541,7 @@ fn do_test_intercepted_payment(test: InterceptTest) {
                };
                connect_block(&nodes[0], &block);
                connect_block(&nodes[1], &block);
-               let block_count = 183; // find_route adds a random CLTV offset, so hardcode rather than summing consts
-               for _ in 0..block_count {
+               for _ in 0..TEST_FINAL_CLTV {
                        block.header.prev_blockhash = block.block_hash();
                        connect_block(&nodes[0], &block);
                        connect_block(&nodes[1], &block);