Skip to content

Commit

Permalink
Don't rely on route-fetching rand in blinded_path_with_custom_tlv
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
TheBlueMatt committed Sep 11, 2024
1 parent 758747a commit 6e340c4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lightning/src/ln/max_payment_path_len_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6e340c4

Please sign in to comment.