]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Don't rely on route-fetching rand in `blinded_path_with_custom_tlv`
authorMatt Corallo <git@bluematt.me>
Sun, 8 Sep 2024 20:13:40 +0000 (20:13 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 11 Sep 2024 20:01:43 +0000 (20:01 +0000)
`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.

lightning/src/ln/max_payment_path_len_tests.rs

index 69ae3cd7679786d7ec294b04b1c44a31f64139cb..944bacc020d61a4397f27b8cd364f5b8addba99e 100644 (file)
@@ -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);