@@ -422,7 +422,7 @@ pub fn do_test(data: &[u8]) {
422
422
test_return!( ) ;
423
423
}
424
424
} } ;
425
- ( $source: expr, $middle: expr, $dest: expr) => { {
425
+ ( $source: expr, $middle: expr, $dest: expr, false ) => { {
426
426
let payment_hash = Sha256 :: hash( & [ payment_id; 1 ] ) ;
427
427
payment_id = payment_id. wrapping_add( 1 ) ;
428
428
if let Err ( _) = $source. send_payment( Route {
@@ -445,6 +445,46 @@ pub fn do_test(data: &[u8]) {
445
445
// Probably ran out of funds
446
446
test_return!( ) ;
447
447
}
448
+ } } ;
449
+ ( $source: expr, $middle: expr, $dest: expr, true ) => { {
450
+ let payment_hash = Sha256 :: hash( & [ payment_id; 1 ] ) ;
451
+ payment_id = payment_id. wrapping_add( 1 ) ;
452
+ let payment_secret = Sha256 :: hash( & [ payment_id; 1 ] ) ;
453
+ payment_id = payment_id. wrapping_add( 1 ) ;
454
+ if let Err ( _) = $source. send_payment( Route {
455
+ paths: vec![ vec![ RouteHop {
456
+ pubkey: $middle. 0 . get_our_node_id( ) ,
457
+ node_features: NodeFeatures :: empty( ) ,
458
+ short_channel_id: $middle. 1 ,
459
+ channel_features: ChannelFeatures :: empty( ) ,
460
+ fee_msat: 50000 ,
461
+ cltv_expiry_delta: 100 ,
462
+ } , RouteHop {
463
+ pubkey: $dest. 0 . get_our_node_id( ) ,
464
+ node_features: NodeFeatures :: empty( ) ,
465
+ short_channel_id: $dest. 1 ,
466
+ channel_features: ChannelFeatures :: empty( ) ,
467
+ fee_msat: 5000000 ,
468
+ cltv_expiry_delta: 200 ,
469
+ } ] , vec![ RouteHop {
470
+ pubkey: $middle. 0 . get_our_node_id( ) ,
471
+ node_features: NodeFeatures :: empty( ) ,
472
+ short_channel_id: $middle. 1 ,
473
+ channel_features: ChannelFeatures :: empty( ) ,
474
+ fee_msat: 50000 ,
475
+ cltv_expiry_delta: 100 ,
476
+ } , RouteHop {
477
+ pubkey: $dest. 0 . get_our_node_id( ) ,
478
+ node_features: NodeFeatures :: empty( ) ,
479
+ short_channel_id: $dest. 1 ,
480
+ channel_features: ChannelFeatures :: empty( ) ,
481
+ fee_msat: 5000000 ,
482
+ cltv_expiry_delta: 200 ,
483
+ } ] ] ,
484
+ } , PaymentHash ( payment_hash. into_inner( ) ) , Some ( & payment_secret. into_inner( ) ) ) {
485
+ // Probably ran out of funds
486
+ test_return!( ) ;
487
+ }
448
488
} }
449
489
}
450
490
@@ -599,12 +639,12 @@ pub fn do_test(data: &[u8]) {
599
639
} ) ;
600
640
for event in events. drain( ..) {
601
641
match event {
602
- events:: Event :: PaymentReceived { payment_hash, .. } => {
642
+ events:: Event :: PaymentReceived { payment_hash, payment_secret , .. } => {
603
643
if claim_set. insert( payment_hash. 0 ) {
604
644
if $fail {
605
- assert!( nodes[ $node] . fail_htlc_backwards( & payment_hash, & None ) ) ;
645
+ assert!( nodes[ $node] . fail_htlc_backwards( & payment_hash, & payment_secret ) ) ;
606
646
} else {
607
- assert!( nodes[ $node] . claim_funds( PaymentPreimage ( payment_hash. 0 ) , & None , 5_000_000 ) ) ;
647
+ assert!( nodes[ $node] . claim_funds( PaymentPreimage ( payment_hash. 0 ) , & payment_secret , 5_000_000 ) ) ;
608
648
}
609
649
}
610
650
} ,
@@ -650,8 +690,8 @@ pub fn do_test(data: &[u8]) {
650
690
0x0a => send_payment ! ( nodes[ 1 ] , ( & nodes[ 0 ] , chan_a) ) ,
651
691
0x0b => send_payment ! ( nodes[ 1 ] , ( & nodes[ 2 ] , chan_b) ) ,
652
692
0x0c => send_payment ! ( nodes[ 2 ] , ( & nodes[ 1 ] , chan_b) ) ,
653
- 0x0d => send_payment ! ( nodes[ 0 ] , ( & nodes[ 1 ] , chan_a) , ( & nodes[ 2 ] , chan_b) ) ,
654
- 0x0e => send_payment ! ( nodes[ 2 ] , ( & nodes[ 1 ] , chan_b) , ( & nodes[ 0 ] , chan_a) ) ,
693
+ 0x0d => send_payment ! ( nodes[ 0 ] , ( & nodes[ 1 ] , chan_a) , ( & nodes[ 2 ] , chan_b) , false ) ,
694
+ 0x0e => send_payment ! ( nodes[ 2 ] , ( & nodes[ 1 ] , chan_b) , ( & nodes[ 0 ] , chan_a) , false ) ,
655
695
0x0f => {
656
696
if !chan_a_disconnected {
657
697
nodes[ 0 ] . peer_disconnected ( & nodes[ 1 ] . get_our_node_id ( ) , false ) ;
@@ -734,6 +774,8 @@ pub fn do_test(data: &[u8]) {
734
774
nodes[ 2 ] = node_c. clone ( ) ;
735
775
monitor_c = new_monitor_c;
736
776
} ,
777
+ 0x22 => send_payment ! ( nodes[ 0 ] , ( & nodes[ 1 ] , chan_a) , ( & nodes[ 2 ] , chan_b) , true ) ,
778
+ 0x23 => send_payment ! ( nodes[ 2 ] , ( & nodes[ 1 ] , chan_b) , ( & nodes[ 0 ] , chan_a) , true ) ,
737
779
// 0x24 defined above
738
780
_ => test_return ! ( ) ,
739
781
}
0 commit comments