Skip to content

Commit c7f158c

Browse files
Add test for dummy hop insertion
Introduces a test to verify correct handling of dummy hops in constructed blinded paths. Ensures that the added dummy hops are properly included and do not interfere with the real path. Co-authored-by: valentinewallace <[email protected]>
1 parent 7a46f3d commit c7f158c

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

lightning/src/onion_message/functional_tests.rs

+32-2
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,34 @@ fn one_blinded_hop() {
424424
pass_along_path(&nodes);
425425
}
426426

427+
#[test]
428+
fn blinded_path_with_dummy() {
429+
let nodes = create_nodes(2);
430+
let test_msg = TestCustomMessage::Pong;
431+
432+
let secp_ctx = Secp256k1::new();
433+
let context = MessageContext::Custom(Vec::new());
434+
let entropy = &*nodes[1].entropy_source;
435+
let expanded_key = ExpandedKey::new([42; 32]);
436+
let blinded_path = BlindedMessagePath::new_with_dummy_hops(
437+
&[],
438+
5,
439+
nodes[1].node_id,
440+
context,
441+
entropy,
442+
expanded_key,
443+
&secp_ctx,
444+
)
445+
.unwrap();
446+
// Make sure that dummy hops are do added to the blinded path.
447+
assert_eq!(blinded_path.blinded_hops().len(), 6);
448+
let destination = Destination::BlindedPath(blinded_path);
449+
let instructions = MessageSendInstructions::WithoutReplyPath { destination };
450+
nodes[0].messenger.send_onion_message(test_msg, instructions).unwrap();
451+
nodes[1].custom_message_handler.expect_message(TestCustomMessage::Pong);
452+
pass_along_path(&nodes);
453+
}
454+
427455
#[test]
428456
fn two_unblinded_two_blinded() {
429457
let nodes = create_nodes(5);
@@ -648,8 +676,9 @@ fn test_blinded_path_padding_for_full_length_path() {
648676
// Update the context to create a larger final receive TLVs, ensuring that
649677
// the hop sizes vary before padding.
650678
let context = MessageContext::Custom(vec![0u8; 42]);
651-
let blinded_path = BlindedMessagePath::new(
679+
let blinded_path = BlindedMessagePath::new_with_dummy_hops(
652680
&intermediate_nodes,
681+
5,
653682
nodes[3].node_id,
654683
context,
655684
&*nodes[3].entropy_source,
@@ -683,8 +712,9 @@ fn test_blinded_path_no_padding_for_compact_path() {
683712
// Update the context to create a larger final receive TLVs, ensuring that
684713
// the hop sizes vary before padding.
685714
let context = MessageContext::Custom(vec![0u8; 42]);
686-
let blinded_path = BlindedMessagePath::new(
715+
let blinded_path = BlindedMessagePath::new_with_dummy_hops(
687716
&intermediate_nodes,
717+
5,
688718
nodes[3].node_id,
689719
context,
690720
&*nodes[3].entropy_source,

0 commit comments

Comments
 (0)