Skip to content

Commit 9e1329c

Browse files
committed
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.
1 parent 2c5d4ab commit 9e1329c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lightning/src/onion_message/functional_tests.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,34 @@ fn one_blinded_hop() {
443443
pass_along_path(&nodes);
444444
}
445445

446+
#[test]
447+
fn blinded_path_with_dummy() {
448+
let nodes = create_nodes(2);
449+
let test_msg = TestCustomMessage::Pong;
450+
451+
let secp_ctx = Secp256k1::new();
452+
let context = MessageContext::Custom(Vec::new());
453+
let entropy = &*nodes[1].entropy_source;
454+
let receive_key = nodes[1].messenger.node_signer.get_receive_auth_key();
455+
let blinded_path = BlindedMessagePath::new_with_dummy_hops(
456+
&[],
457+
nodes[1].node_id,
458+
5,
459+
receive_key,
460+
context,
461+
entropy,
462+
&secp_ctx,
463+
)
464+
.unwrap();
465+
// Ensure that dummy hops are added to the blinded path.
466+
assert_eq!(blinded_path.blinded_hops().len(), 6);
467+
let destination = Destination::BlindedPath(blinded_path);
468+
let instructions = MessageSendInstructions::WithoutReplyPath { destination };
469+
nodes[0].messenger.send_onion_message(test_msg, instructions).unwrap();
470+
nodes[1].custom_message_handler.expect_message(TestCustomMessage::Pong);
471+
pass_along_path(&nodes);
472+
}
473+
446474
#[test]
447475
fn two_unblinded_two_blinded() {
448476
let nodes = create_nodes(5);

0 commit comments

Comments
 (0)