@@ -290,8 +290,10 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
290
290
// We need the session priv to construct a bogus onion packet later.
291
291
* nodes[ 0 ] . keys_manager . override_random_bytes . lock ( ) . unwrap ( ) = Some ( [ 3 ; 32 ] ) ;
292
292
create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 1_000_000 , 0 ) ;
293
- let chan_upd_1_2 = create_announced_chan_between_nodes_with_value ( & nodes, 1 , 2 , 1_000_000 , 0 ) . 0 . contents ;
294
- let chan_upd_2_3 = create_announced_chan_between_nodes_with_value ( & nodes, 2 , 3 , 1_000_000 , 0 ) . 0 . contents ;
293
+ let chan_1_2 = create_announced_chan_between_nodes_with_value ( & nodes, 1 , 2 , 1_000_000 , 0 ) ;
294
+ let chan_upd_1_2 = chan_1_2. 0 . contents ;
295
+ let chan_2_3 = create_announced_chan_between_nodes_with_value ( & nodes, 2 , 3 , 1_000_000 , 0 ) ;
296
+ let chan_upd_2_3 = chan_2_3. 0 . contents ;
295
297
296
298
let amt_msat = 5000 ;
297
299
let ( _, payment_hash, payment_secret) = get_payment_preimage_hash ( & nodes[ 3 ] , Some ( amt_msat) , None ) ;
@@ -345,18 +347,27 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
345
347
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
346
348
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 0 ] , & updates_0_1. commitment_signed , true , true ) ;
347
349
350
+ expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
351
+ check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
352
+
348
353
if intro_fails {
349
354
let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
350
355
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
351
356
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
357
+ let failed_destination = match check {
358
+ ForwardCheckFail :: InboundOnionCheck => HTLCDestination :: InvalidOnion ,
359
+ ForwardCheckFail :: ForwardPayloadEncodedAsReceive => HTLCDestination :: FailedPayment { payment_hash } ,
360
+ ForwardCheckFail :: OutboundChannelCheck =>
361
+ HTLCDestination :: NextHopChannel { node_id : Some ( nodes[ 2 ] . node . get_our_node_id ( ) ) , channel_id : chan_1_2. 2 } ,
362
+ } ;
363
+ expect_htlc_handling_failed_destinations ! (
364
+ nodes[ 1 ] . node. get_and_clear_pending_events( ) , & [ failed_destination. clone( ) ]
365
+ ) ;
352
366
expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
353
367
PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
354
368
return
355
369
}
356
370
357
- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
358
- check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
359
-
360
371
let mut updates_1_2 = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 2 ] . node. get_our_node_id( ) ) ;
361
372
let mut update_add = & mut updates_1_2. update_add_htlcs [ 0 ] ;
362
373
@@ -366,6 +377,17 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
366
377
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
367
378
do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & updates_1_2. commitment_signed , true , true ) ;
368
379
380
+ expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
381
+ let failed_destination = match check {
382
+ ForwardCheckFail :: InboundOnionCheck |ForwardCheckFail :: ForwardPayloadEncodedAsReceive => HTLCDestination :: InvalidOnion ,
383
+ ForwardCheckFail :: OutboundChannelCheck =>
384
+ HTLCDestination :: NextHopChannel { node_id : Some ( nodes[ 3 ] . node . get_our_node_id ( ) ) , channel_id : chan_2_3. 2 } ,
385
+ } ;
386
+ expect_htlc_handling_failed_destinations ! (
387
+ nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ failed_destination. clone( ) ]
388
+ ) ;
389
+ check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
390
+
369
391
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
370
392
let update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
371
393
assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
@@ -425,7 +447,10 @@ fn failed_backwards_to_intro_node() {
425
447
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
426
448
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
427
449
do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event. commitment_msg , true , true ) ;
428
- nodes[ 2 ] . node . process_pending_htlc_forwards ( ) ;
450
+
451
+ expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
452
+ expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCDestination :: InvalidOnion ] ) ;
453
+ check_added_monitors ( & nodes[ 2 ] , 1 ) ;
429
454
430
455
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
431
456
let mut update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
@@ -502,7 +527,7 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
502
527
// intro node will error backwards.
503
528
$curr_node. node. peer_disconnected( $next_node. node. get_our_node_id( ) ) ;
504
529
expect_pending_htlcs_forwardable!( $curr_node) ;
505
- expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore !( $curr_node,
530
+ expect_htlc_handling_failed_destinations !( $curr_node. node . get_and_clear_pending_events ( ) ,
506
531
vec![ HTLCDestination :: NextHopChannel { node_id: Some ( $next_node. node. get_our_node_id( ) ) , channel_id: $failed_chan_id } ] ) ;
507
532
} ,
508
533
ProcessPendingHTLCsCheck :: FwdChannelClosed => {
@@ -518,12 +543,12 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
518
543
crate :: events:: Event :: ChannelClosed { .. } => { } ,
519
544
_ => panic!( "Unexpected event {:?}" , events) ,
520
545
}
546
+ check_closed_broadcast( & $curr_node, 1 , true ) ;
547
+ check_added_monitors!( $curr_node, 1 ) ;
521
548
522
549
$curr_node. node. process_pending_htlc_forwards( ) ;
523
- expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore !( $curr_node,
550
+ expect_htlc_handling_failed_destinations !( $curr_node. node . get_and_clear_pending_events ( ) ,
524
551
vec![ HTLCDestination :: UnknownNextHop { requested_forward_scid: $failed_scid } ] ) ;
525
- check_closed_broadcast( & $curr_node, 1 , true ) ;
526
- check_added_monitors!( $curr_node, 1 ) ;
527
552
$curr_node. node. process_pending_htlc_forwards( ) ;
528
553
} ,
529
554
}
@@ -609,6 +634,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
609
634
} ;
610
635
nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
611
636
commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 0 ] , & payment_event. commitment_msg, false , true ) ;
637
+ expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
612
638
613
639
let events = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
614
640
assert_eq ! ( events. len( ) , 1 ) ;
@@ -914,13 +940,19 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
914
940
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , update_add) ;
915
941
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
916
942
do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event_1_2. commitment_msg , true , true ) ;
943
+ expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
944
+ expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCDestination :: InvalidOnion ] ) ;
945
+ check_added_monitors ( & nodes[ 2 ] , 1 ) ;
917
946
} ,
918
947
ReceiveCheckFail :: ReceiveRequirements => {
919
948
let update_add = & mut payment_event_1_2. msgs [ 0 ] ;
920
949
update_add. amount_msat -= 1 ;
921
950
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , update_add) ;
922
951
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
923
952
do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event_1_2. commitment_msg , true , true ) ;
953
+ expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
954
+ expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCDestination :: FailedPayment { payment_hash } ] ) ;
955
+ check_added_monitors ( & nodes[ 2 ] , 1 ) ;
924
956
} ,
925
957
ReceiveCheckFail :: ChannelCheck => {
926
958
nodes[ 2 ] . node . close_channel ( & chan_id_1_2, & nodes[ 1 ] . node . get_our_node_id ( ) ) . unwrap ( ) ;
@@ -934,6 +966,9 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
934
966
935
967
nodes[ 2 ] . node . handle_shutdown ( nodes[ 1 ] . node . get_our_node_id ( ) , & node_1_shutdown) ;
936
968
commitment_signed_dance ! ( nodes[ 2 ] , nodes[ 1 ] , ( ) , false , true , false , false ) ;
969
+ expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
970
+ expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCDestination :: FailedPayment { payment_hash } ] ) ;
971
+ check_added_monitors ( & nodes[ 2 ] , 1 ) ;
937
972
} ,
938
973
ReceiveCheckFail :: ProcessPendingHTLCsCheck => {
939
974
assert_eq ! ( payment_event_1_2. msgs[ 0 ] . cltv_expiry, nodes[ 0 ] . best_block_info( ) . 1 + 1 + excess_final_cltv_delta_opt. unwrap( ) as u32 + TEST_FINAL_CLTV ) ;
@@ -949,6 +984,9 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
949
984
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event_1_2. msgs [ 0 ] ) ;
950
985
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
951
986
do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event_1_2. commitment_msg , true , true ) ;
987
+ expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
988
+ expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCDestination :: FailedPayment { payment_hash } ] ) ;
989
+ check_added_monitors ( & nodes[ 2 ] , 1 ) ;
952
990
}
953
991
}
954
992
@@ -1149,6 +1187,12 @@ fn min_htlc() {
1149
1187
nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event_0_1. msgs [ 0 ] ) ;
1150
1188
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
1151
1189
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 0 ] , & payment_event_0_1. commitment_msg , true , true ) ;
1190
+ expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1191
+ expect_htlc_handling_failed_destinations ! (
1192
+ nodes[ 1 ] . node. get_and_clear_pending_events( ) ,
1193
+ & [ HTLCDestination :: NextHopChannel { node_id: Some ( nodes[ 2 ] . node. get_our_node_id( ) ) , channel_id: chan_1_2. 2 } ]
1194
+ ) ;
1195
+ check_added_monitors ( & nodes[ 1 ] , 1 ) ;
1152
1196
let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
1153
1197
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
1154
1198
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
0 commit comments