From: Matt Corallo Date: Sun, 8 Sep 2024 20:13:40 +0000 (+0000) Subject: Don't rely on route-fetching rand in `blinded_path_with_custom_tlv` X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=6e340c43de50cdba88286d3fce1f65f57b1024b2;p=rust-lightning Don't rely on route-fetching rand in `blinded_path_with_custom_tlv` `blinded_path_with_custom_tlv` indirectly relied on route CLTV randomization when sending because nodes were at substantially different block heights after setup. Instead we make sure all nodes are at the same height which makes the test more robust. --- diff --git a/lightning/src/ln/max_payment_path_len_tests.rs b/lightning/src/ln/max_payment_path_len_tests.rs index 69ae3cd76..944bacc02 100644 --- a/lightning/src/ln/max_payment_path_len_tests.rs +++ b/lightning/src/ln/max_payment_path_len_tests.rs @@ -255,6 +255,13 @@ fn blinded_path_with_custom_tlv() { create_announced_chan_between_nodes(&nodes, 1, 2); let chan_upd_2_3 = create_announced_chan_between_nodes_with_value(&nodes, 2, 3, 1_000_000, 0).0.contents; + // Ensure all nodes are at the same height + let node_max_height = nodes.iter().map(|node| node.blocks.lock().unwrap().len()).max().unwrap() as u32; + connect_blocks(&nodes[0], node_max_height - nodes[0].best_block_info().1); + connect_blocks(&nodes[1], node_max_height - nodes[1].best_block_info().1); + connect_blocks(&nodes[2], node_max_height - nodes[2].best_block_info().1); + connect_blocks(&nodes[3], node_max_height - nodes[3].best_block_info().1); + // Construct the route parameters for sending to nodes[3]'s blinded path. let amt_msat = 100_000; let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[3], Some(amt_msat), None);