@@ -26,6 +26,7 @@ use crate::blinded_path::message::{
26
26
use crate :: blinded_path:: utils:: is_padded;
27
27
use crate :: blinded_path:: EmptyNodeIdLookUp ;
28
28
use crate :: events:: { Event , EventsProvider } ;
29
+ use crate :: ln:: inbound_payment:: ExpandedKey ;
29
30
use crate :: ln:: msgs:: { self , BaseMessageHandler , DecodeError , OnionMessageHandler } ;
30
31
use crate :: routing:: gossip:: { NetworkGraph , P2PGossipSync } ;
31
32
use crate :: routing:: test_utils:: { add_channel, add_or_update_node} ;
@@ -421,6 +422,34 @@ fn one_blinded_hop() {
421
422
pass_along_path ( & nodes) ;
422
423
}
423
424
425
+ #[ test]
426
+ fn blinded_path_with_dummy ( ) {
427
+ let nodes = create_nodes ( 2 ) ;
428
+ let test_msg = TestCustomMessage :: Pong ;
429
+
430
+ let secp_ctx = Secp256k1 :: new ( ) ;
431
+ let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
432
+ let entropy = & * nodes[ 1 ] . entropy_source ;
433
+ let expanded_key = ExpandedKey :: new ( [ 42 ; 32 ] ) ;
434
+ let blinded_path = BlindedMessagePath :: new_with_dummy_hops (
435
+ & [ ] ,
436
+ 5 ,
437
+ nodes[ 1 ] . node_id ,
438
+ context,
439
+ entropy,
440
+ & expanded_key,
441
+ & secp_ctx,
442
+ )
443
+ . unwrap ( ) ;
444
+ // Ensure that dummy hops are added to the blinded path.
445
+ assert_eq ! ( blinded_path. blinded_hops( ) . len( ) , 6 ) ;
446
+ let destination = Destination :: BlindedPath ( blinded_path) ;
447
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
448
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions) . unwrap ( ) ;
449
+ nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
450
+ pass_along_path ( & nodes) ;
451
+ }
452
+
424
453
#[ test]
425
454
fn two_unblinded_two_blinded ( ) {
426
455
let nodes = create_nodes ( 5 ) ;
@@ -614,11 +643,14 @@ fn test_blinded_path_padding_for_full_length_path() {
614
643
// Update the context to create a larger final receive TLVs, ensuring that
615
644
// the hop sizes vary before padding.
616
645
let context = MessageContext :: Custom ( vec ! [ 0u8 ; 42 ] ) ;
617
- let blinded_path = BlindedMessagePath :: new (
646
+ let expanded_key = ExpandedKey :: new ( [ 42 ; 32 ] ) ;
647
+ let blinded_path = BlindedMessagePath :: new_with_dummy_hops (
618
648
& intermediate_nodes,
649
+ 5 ,
619
650
nodes[ 3 ] . node_id ,
620
651
context,
621
652
& * nodes[ 3 ] . entropy_source ,
653
+ & expanded_key,
622
654
& secp_ctx,
623
655
)
624
656
. unwrap ( ) ;
@@ -647,15 +679,19 @@ fn test_blinded_path_no_padding_for_compact_path() {
647
679
// Update the context to create a larger final receive TLVs, ensuring that
648
680
// the hop sizes vary before padding.
649
681
let context = MessageContext :: Custom ( vec ! [ 0u8 ; 42 ] ) ;
650
- let blinded_path = BlindedMessagePath :: new (
682
+ let expanded_key = ExpandedKey :: new ( [ 42 ; 32 ] ) ;
683
+ let blinded_path = BlindedMessagePath :: new_with_dummy_hops (
651
684
& intermediate_nodes,
685
+ 5 ,
652
686
nodes[ 3 ] . node_id ,
653
687
context,
654
688
& * nodes[ 3 ] . entropy_source ,
689
+ & expanded_key,
655
690
& secp_ctx,
656
691
)
657
692
. unwrap ( ) ;
658
693
694
+ // Ensure that the hops are not padded.
659
695
assert ! ( !is_padded( & blinded_path. blinded_hops( ) , MESSAGE_PADDING_ROUND_OFF ) ) ;
660
696
}
661
697
0 commit comments