@@ -552,7 +552,7 @@ fn test_onion_failure() {
552
552
for f in pending_forwards. iter_mut ( ) {
553
553
match f {
554
554
& mut HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo { ref mut forward_info, .. } ) =>
555
- forward_info. outgoing_cltv_value + = 1 ,
555
+ forward_info. outgoing_cltv_value - = 1 ,
556
556
_ => { } ,
557
557
}
558
558
}
@@ -602,6 +602,31 @@ fn test_onion_failure() {
602
602
} , true , Some ( 23 ) , None , None ) ;
603
603
}
604
604
605
+ #[ test]
606
+ #[ should_panic]
607
+ fn test_overshoot_final_cltv ( ) {
608
+ // Test that we can overshoot the final cltv_expiry set by the sender
609
+ // by making sure expecting it to fail panics
610
+ let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
611
+ let node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
612
+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None ; 3 ] ) ;
613
+ let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
614
+ let channels = [ create_announced_chan_between_nodes ( & nodes, 0 , 1 ) , create_announced_chan_between_nodes ( & nodes, 1 , 2 ) ] ;
615
+ let ( route, payment_hash, _, payment_secret) = get_route_and_payment_hash ! ( nodes[ 0 ] , nodes[ 2 ] , 40000 ) ;
616
+ send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , 40000 ) ;
617
+ run_onion_failure_test ( "final_incorrect_cltv_expiry" , 1 , & nodes, & route, & payment_hash, & payment_secret, |_| { } , || {
618
+ for ( _, pending_forwards) in nodes[ 1 ] . node . forward_htlcs . lock ( ) . unwrap ( ) . iter_mut ( ) {
619
+ for f in pending_forwards. iter_mut ( ) {
620
+ match f {
621
+ & mut HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo { ref mut forward_info, .. } ) =>
622
+ forward_info. outgoing_cltv_value += 1 ,
623
+ _ => { } ,
624
+ }
625
+ }
626
+ }
627
+ } , true , Some ( 18 ) , None , Some ( channels[ 1 ] . 0 . contents . short_channel_id ) ) ;
628
+ }
629
+
605
630
fn do_test_onion_failure_stale_channel_update ( announced_channel : bool ) {
606
631
// Create a network of three nodes and two channels connecting them. We'll be updating the
607
632
// HTLC relay policy of the second channel, causing forwarding failures at the first hop.
@@ -1096,7 +1121,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
1096
1121
& mut HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
1097
1122
forward_info : PendingHTLCInfo { ref mut outgoing_cltv_value, .. } , ..
1098
1123
} ) => {
1099
- * outgoing_cltv_value + = 1 ;
1124
+ * outgoing_cltv_value - = 1 ;
1100
1125
} ,
1101
1126
_ => panic ! ( "Unexpected forward" ) ,
1102
1127
}
@@ -1114,7 +1139,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
1114
1139
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , update_1. commitment_signed, false ) ;
1115
1140
1116
1141
// Ensure the payment fails with the expected error.
1117
- let expected_cltv: u32 = 82 ;
1142
+ let expected_cltv: u32 = 80 ;
1118
1143
let error_data = expected_cltv. to_be_bytes ( ) . to_vec ( ) ;
1119
1144
let mut fail_conditions = PaymentFailedConditions :: new ( )
1120
1145
. blamed_scid ( phantom_scid)
0 commit comments