Skip to content

Commit 6e340c4

Browse files
committed
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.
1 parent 758747a commit 6e340c4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/ln/max_payment_path_len_tests.rs

+7
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ fn blinded_path_with_custom_tlv() {
255255
create_announced_chan_between_nodes(&nodes, 1, 2);
256256
let chan_upd_2_3 = create_announced_chan_between_nodes_with_value(&nodes, 2, 3, 1_000_000, 0).0.contents;
257257

258+
// Ensure all nodes are at the same height
259+
let node_max_height = nodes.iter().map(|node| node.blocks.lock().unwrap().len()).max().unwrap() as u32;
260+
connect_blocks(&nodes[0], node_max_height - nodes[0].best_block_info().1);
261+
connect_blocks(&nodes[1], node_max_height - nodes[1].best_block_info().1);
262+
connect_blocks(&nodes[2], node_max_height - nodes[2].best_block_info().1);
263+
connect_blocks(&nodes[3], node_max_height - nodes[3].best_block_info().1);
264+
258265
// Construct the route parameters for sending to nodes[3]'s blinded path.
259266
let amt_msat = 100_000;
260267
let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[3], Some(amt_msat), None);

0 commit comments

Comments
 (0)