@@ -15,7 +15,7 @@ use crate::ln::msgs::{self, DecodeError, OnionMessageHandler};
15
15
use crate :: sign:: { NodeSigner , Recipient } ;
16
16
use crate :: util:: ser:: { FixedLengthReader , LengthReadable , Writeable , Writer } ;
17
17
use crate :: util:: test_utils;
18
- use super :: { CustomOnionMessageContents , CustomOnionMessageHandler , Destination , MessageRouter , OffersMessage , OffersMessageHandler , OnionMessageContents , OnionMessagePath , OnionMessenger , SendError } ;
18
+ use super :: { CustomOnionMessageContents , CustomOnionMessageHandler , Destination , MessageRouter , OffersMessage , OffersMessageHandler , ParsedOnionMessageContents , OnionMessagePath , OnionMessenger , SendError } ;
19
19
20
20
use bitcoin:: network:: constants:: Network ;
21
21
use bitcoin:: secp256k1:: { PublicKey , Secp256k1 , SecretKey } ;
@@ -196,7 +196,7 @@ fn pass_along_path(path: &Vec<MessengerNode>) {
196
196
#[ test]
197
197
fn one_hop ( ) {
198
198
let nodes = create_nodes ( 2 ) ;
199
- let test_msg = OnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
199
+ let test_msg = ParsedOnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
200
200
201
201
let path = OnionMessagePath {
202
202
intermediate_nodes : vec ! [ ] ,
@@ -210,7 +210,7 @@ fn one_hop() {
210
210
#[ test]
211
211
fn two_unblinded_hops ( ) {
212
212
let nodes = create_nodes ( 3 ) ;
213
- let test_msg = OnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
213
+ let test_msg = ParsedOnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
214
214
215
215
let path = OnionMessagePath {
216
216
intermediate_nodes : vec ! [ nodes[ 1 ] . get_node_pk( ) ] ,
@@ -224,7 +224,7 @@ fn two_unblinded_hops() {
224
224
#[ test]
225
225
fn two_unblinded_two_blinded ( ) {
226
226
let nodes = create_nodes ( 5 ) ;
227
- let test_msg = OnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
227
+ let test_msg = ParsedOnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
228
228
229
229
let secp_ctx = Secp256k1 :: new ( ) ;
230
230
let blinded_path = BlindedPath :: new_for_message ( & [ nodes[ 3 ] . get_node_pk ( ) , nodes[ 4 ] . get_node_pk ( ) ] , & * nodes[ 4 ] . keys_manager , & secp_ctx) . unwrap ( ) ;
@@ -241,7 +241,7 @@ fn two_unblinded_two_blinded() {
241
241
#[ test]
242
242
fn three_blinded_hops ( ) {
243
243
let nodes = create_nodes ( 4 ) ;
244
- let test_msg = OnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
244
+ let test_msg = ParsedOnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
245
245
246
246
let secp_ctx = Secp256k1 :: new ( ) ;
247
247
let blinded_path = BlindedPath :: new_for_message ( & [ nodes[ 1 ] . get_node_pk ( ) , nodes[ 2 ] . get_node_pk ( ) , nodes[ 3 ] . get_node_pk ( ) ] , & * nodes[ 3 ] . keys_manager , & secp_ctx) . unwrap ( ) ;
@@ -259,7 +259,7 @@ fn three_blinded_hops() {
259
259
fn too_big_packet_error ( ) {
260
260
// Make sure we error as expected if a packet is too big to send.
261
261
let nodes = create_nodes ( 2 ) ;
262
- let test_msg = OnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
262
+ let test_msg = ParsedOnionMessageContents :: Custom ( TestCustomMessage :: Response ) ;
263
263
264
264
let hop_node_id = nodes[ 1 ] . get_node_pk ( ) ;
265
265
let hops = vec ! [ hop_node_id; 400 ] ;
@@ -285,7 +285,7 @@ fn we_are_intro_node() {
285
285
destination : Destination :: BlindedPath ( blinded_path) ,
286
286
} ;
287
287
288
- nodes[ 0 ] . messenger . send_onion_message ( path, OnionMessageContents :: Custom ( test_msg. clone ( ) ) , None ) . unwrap ( ) ;
288
+ nodes[ 0 ] . messenger . send_onion_message ( path, ParsedOnionMessageContents :: Custom ( test_msg. clone ( ) ) , None ) . unwrap ( ) ;
289
289
nodes[ 2 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
290
290
pass_along_path ( & nodes) ;
291
291
@@ -295,7 +295,7 @@ fn we_are_intro_node() {
295
295
intermediate_nodes : vec ! [ ] ,
296
296
destination : Destination :: BlindedPath ( blinded_path) ,
297
297
} ;
298
- nodes[ 0 ] . messenger . send_onion_message ( path, OnionMessageContents :: Custom ( test_msg) , None ) . unwrap ( ) ;
298
+ nodes[ 0 ] . messenger . send_onion_message ( path, ParsedOnionMessageContents :: Custom ( test_msg) , None ) . unwrap ( ) ;
299
299
nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
300
300
nodes. remove ( 2 ) ;
301
301
pass_along_path ( & nodes) ;
@@ -315,7 +315,7 @@ fn invalid_blinded_path_error() {
315
315
intermediate_nodes : vec ! [ ] ,
316
316
destination : Destination :: BlindedPath ( blinded_path) ,
317
317
} ;
318
- let err = nodes[ 0 ] . messenger . send_onion_message ( path, OnionMessageContents :: Custom ( test_msg. clone ( ) ) , None ) . unwrap_err ( ) ;
318
+ let err = nodes[ 0 ] . messenger . send_onion_message ( path, ParsedOnionMessageContents :: Custom ( test_msg. clone ( ) ) , None ) . unwrap_err ( ) ;
319
319
assert_eq ! ( err, SendError :: TooFewBlindedHops ) ;
320
320
321
321
// 1 hop
@@ -326,7 +326,7 @@ fn invalid_blinded_path_error() {
326
326
intermediate_nodes : vec ! [ ] ,
327
327
destination : Destination :: BlindedPath ( blinded_path) ,
328
328
} ;
329
- let err = nodes[ 0 ] . messenger . send_onion_message ( path, OnionMessageContents :: Custom ( test_msg) , None ) . unwrap_err ( ) ;
329
+ let err = nodes[ 0 ] . messenger . send_onion_message ( path, ParsedOnionMessageContents :: Custom ( test_msg) , None ) . unwrap_err ( ) ;
330
330
assert_eq ! ( err, SendError :: TooFewBlindedHops ) ;
331
331
}
332
332
@@ -342,7 +342,7 @@ fn reply_path() {
342
342
destination : Destination :: Node ( nodes[ 3 ] . get_node_pk ( ) ) ,
343
343
} ;
344
344
let reply_path = BlindedPath :: new_for_message ( & [ nodes[ 2 ] . get_node_pk ( ) , nodes[ 1 ] . get_node_pk ( ) , nodes[ 0 ] . get_node_pk ( ) ] , & * nodes[ 0 ] . keys_manager , & secp_ctx) . unwrap ( ) ;
345
- nodes[ 0 ] . messenger . send_onion_message ( path, OnionMessageContents :: Custom ( test_msg. clone ( ) ) , Some ( reply_path) ) . unwrap ( ) ;
345
+ nodes[ 0 ] . messenger . send_onion_message ( path, ParsedOnionMessageContents :: Custom ( test_msg. clone ( ) ) , Some ( reply_path) ) . unwrap ( ) ;
346
346
nodes[ 3 ] . custom_message_handler . expect_message ( TestCustomMessage :: Request ) ;
347
347
pass_along_path ( & nodes) ;
348
348
// Make sure the last node successfully decoded the reply path.
@@ -358,7 +358,7 @@ fn reply_path() {
358
358
} ;
359
359
let reply_path = BlindedPath :: new_for_message ( & [ nodes[ 2 ] . get_node_pk ( ) , nodes[ 1 ] . get_node_pk ( ) , nodes[ 0 ] . get_node_pk ( ) ] , & * nodes[ 0 ] . keys_manager , & secp_ctx) . unwrap ( ) ;
360
360
361
- nodes[ 0 ] . messenger . send_onion_message ( path, OnionMessageContents :: Custom ( test_msg) , Some ( reply_path) ) . unwrap ( ) ;
361
+ nodes[ 0 ] . messenger . send_onion_message ( path, ParsedOnionMessageContents :: Custom ( test_msg) , Some ( reply_path) ) . unwrap ( ) ;
362
362
nodes[ 3 ] . custom_message_handler . expect_message ( TestCustomMessage :: Request ) ;
363
363
pass_along_path ( & nodes) ;
364
364
@@ -384,7 +384,7 @@ fn invalid_custom_message_type() {
384
384
fn write < W : Writer > ( & self , _w : & mut W ) -> Result < ( ) , io:: Error > { unreachable ! ( ) }
385
385
}
386
386
387
- let test_msg = OnionMessageContents :: Custom ( InvalidCustomMessage { } ) ;
387
+ let test_msg = ParsedOnionMessageContents :: Custom ( InvalidCustomMessage { } ) ;
388
388
let path = OnionMessagePath {
389
389
intermediate_nodes : vec ! [ ] ,
390
390
destination : Destination :: Node ( nodes[ 1 ] . get_node_pk ( ) ) ,
@@ -402,9 +402,9 @@ fn peer_buffer_full() {
402
402
destination : Destination :: Node ( nodes[ 1 ] . get_node_pk ( ) ) ,
403
403
} ;
404
404
for _ in 0 ..188 { // Based on MAX_PER_PEER_BUFFER_SIZE in OnionMessenger
405
- nodes[ 0 ] . messenger . send_onion_message ( path. clone ( ) , OnionMessageContents :: Custom ( test_msg. clone ( ) ) , None ) . unwrap ( ) ;
405
+ nodes[ 0 ] . messenger . send_onion_message ( path. clone ( ) , ParsedOnionMessageContents :: Custom ( test_msg. clone ( ) ) , None ) . unwrap ( ) ;
406
406
}
407
- let err = nodes[ 0 ] . messenger . send_onion_message ( path, OnionMessageContents :: Custom ( test_msg) , None ) . unwrap_err ( ) ;
407
+ let err = nodes[ 0 ] . messenger . send_onion_message ( path, ParsedOnionMessageContents :: Custom ( test_msg) , None ) . unwrap_err ( ) ;
408
408
assert_eq ! ( err, SendError :: BufferFull ) ;
409
409
}
410
410
@@ -425,7 +425,7 @@ fn many_hops() {
425
425
intermediate_nodes,
426
426
destination : Destination :: Node ( nodes[ num_nodes-1 ] . get_node_pk ( ) ) ,
427
427
} ;
428
- nodes[ 0 ] . messenger . send_onion_message ( path, OnionMessageContents :: Custom ( test_msg) , None ) . unwrap ( ) ;
428
+ nodes[ 0 ] . messenger . send_onion_message ( path, ParsedOnionMessageContents :: Custom ( test_msg) , None ) . unwrap ( ) ;
429
429
nodes[ num_nodes-1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
430
430
pass_along_path ( & nodes) ;
431
431
}
0 commit comments