@@ -30,10 +30,35 @@ fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
3030 let logger: Arc < dyn Logger > =
3131 Arc :: new ( test_logger:: TestLogger :: new ( "" . to_owned ( ) , out) ) ;
3232
33- let first_hop_htlc_msat_bytes = match get_slice ! ( 8 ) . try_into ( ) {
34- Ok ( val) => val,
35- Err ( _) => return ,
36- } ;
33+ macro_rules! get_u64 {
34+ ( ) => {
35+ match get_slice!( 8 ) . try_into( ) {
36+ Ok ( val) => u64 :: from_be_bytes( val) ,
37+ Err ( _) => return ,
38+ }
39+ } ;
40+ }
41+
42+ macro_rules! get_u32 {
43+ ( ) => {
44+ match get_slice!( 4 ) . try_into( ) {
45+ Ok ( val) => u32 :: from_be_bytes( val) ,
46+ Err ( _) => return ,
47+ }
48+ } ;
49+ }
50+
51+ macro_rules! get_bool {
52+ ( ) => {
53+ get_slice!( 1 ) [ 0 ] != 0
54+ } ;
55+ }
56+
57+ macro_rules! get_u8 {
58+ ( ) => {
59+ get_slice!( 1 ) [ 0 ]
60+ } ;
61+ }
3762
3863 let session_priv = match SecretKey :: from_slice ( get_slice ! ( 32 ) ) {
3964 Ok ( val) => val,
@@ -54,74 +79,60 @@ fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
5479 } ;
5580 }
5681
57- let path = Path {
58- hops : vec ! [
59- // Bob
60- RouteHop {
61- pubkey: get_pubkey!( ) ,
62- node_features: NodeFeatures :: empty( ) ,
63- short_channel_id: 0 ,
64- channel_features: ChannelFeatures :: empty( ) ,
65- fee_msat: 3_000 ,
66- cltv_expiry_delta: 24 ,
67- maybe_announced_channel: false ,
68- } ,
69-
70- // Carol
71- RouteHop {
72- pubkey: get_pubkey!( ) ,
73- node_features: NodeFeatures :: empty( ) ,
74- short_channel_id: ( 572330 << 40 ) + ( 42 << 16 ) + 2821 ,
75- channel_features: ChannelFeatures :: empty( ) ,
76- fee_msat: 153_000 ,
77- cltv_expiry_delta: 0 ,
78- maybe_announced_channel: false ,
79- } ,
80- ] ,
81- blinded_tail : Some ( BlindedTail {
82- trampoline_hops : vec ! [
83- // Carol's pubkey
84- TrampolineHop {
85- pubkey: get_pubkey!( ) ,
86- node_features: Features :: empty( ) ,
87- fee_msat: 2_500 ,
88- cltv_expiry_delta: 24 ,
89- } ,
90-
91- // Dave's pubkey
92- TrampolineHop {
93- pubkey: get_pubkey!( ) ,
94- node_features: Features :: empty( ) ,
95- fee_msat: 2_500 ,
96- cltv_expiry_delta: 24 ,
97- } ,
82+ let mut hops = Vec :: < RouteHop > :: new ( ) ;
83+ let hop_count = get_slice ! ( 1 ) [ 0 ] as usize ;
84+ for i in 0 ..hop_count {
85+ hops. push ( RouteHop {
86+ pubkey : get_pubkey ! ( ) ,
87+ node_features : NodeFeatures :: empty ( ) ,
88+ short_channel_id : get_u64 ! ( ) ,
89+ channel_features : ChannelFeatures :: empty ( ) ,
90+ fee_msat : get_u64 ! ( ) ,
91+ cltv_expiry_delta : get_u32 ! ( ) ,
92+ maybe_announced_channel : get_bool ! ( ) ,
93+ } ) ;
94+ }
9895
99- // Emily's pubkey
100- TrampolineHop {
96+ let blinded_tail = match get_bool ! ( ) {
97+ true => {
98+ let mut trampoline_hops = Vec :: < TrampolineHop > :: new ( ) ;
99+ let trampoline_hop_count = get_slice ! ( 1 ) [ 0 ] as usize ;
100+ for i in 0 ..trampoline_hop_count {
101+ trampoline_hops. push ( TrampolineHop {
101102 pubkey : get_pubkey ! ( ) ,
102- node_features: Features :: empty( ) ,
103- fee_msat: 150_500 ,
104- cltv_expiry_delta: 36 ,
105- } ,
106- ] ,
107-
108- // Dummy blinded hop (because LDK doesn't allow unblinded Trampoline receives)
109- hops : vec ! [
110- // Emily's dummy blinded node id
111- BlindedHop {
103+ node_features : NodeFeatures :: empty ( ) ,
104+ fee_msat : get_u64 ! ( ) ,
105+ cltv_expiry_delta : get_u32 ! ( ) ,
106+ } ) ;
107+ }
108+ let mut blinded_hops = Vec :: < BlindedHop > :: new ( ) ;
109+ let blinded_hop_count = get_slice ! ( 1 ) [ 0 ] as usize ;
110+ for i in 0 ..blinded_hop_count {
111+ blinded_hops. push ( BlindedHop {
112112 blinded_node_id : get_pubkey ! ( ) ,
113- encrypted_payload: vec![ ] ,
114- }
115- ] ,
116- blinding_point : get_pubkey ! ( ) ,
117- excess_final_cltv_expiry_delta : 0 ,
118- final_value_msat : 150_000_000 ,
119- } ) } ;
113+ encrypted_payload : get_slice ! ( get_u8!( ) ) . to_vec ( ) ,
114+ } ) ;
115+ }
116+ Some ( BlindedTail {
117+ trampoline_hops,
118+ hops : blinded_hops,
119+ blinding_point : get_pubkey ! ( ) ,
120+ excess_final_cltv_expiry_delta : get_u32 ! ( ) ,
121+ final_value_msat : get_u64 ! ( ) ,
122+ } )
123+ } ,
124+ false => None ,
125+ } ;
126+
127+ let path = Path {
128+ hops,
129+ blinded_tail,
130+ } ;
120131
121132 let htlc_source = HTLCSource :: OutboundRoute {
122133 path,
123134 session_priv,
124- first_hop_htlc_msat : u64 :: from_be_bytes ( first_hop_htlc_msat_bytes ) ,
135+ first_hop_htlc_msat : get_u64 ! ( ) ,
125136 payment_id,
126137 } ;
127138
0 commit comments