@@ -439,7 +439,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
439439 check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
440440 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 0 ] , & updates_0_1. commitment_signed , true , true ) ;
441441
442- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
442+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
443443 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
444444
445445 if intro_fails {
@@ -477,7 +477,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
477477 check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
478478 do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & updates_1_2. commitment_signed , true , true ) ;
479479
480- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
480+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
481481 let failed_destination = match check {
482482 ForwardCheckFail :: InboundOnionCheck |ForwardCheckFail :: ForwardPayloadEncodedAsReceive => HTLCHandlingFailureType :: InvalidOnion ,
483483 ForwardCheckFail :: OutboundChannelCheck =>
@@ -534,7 +534,7 @@ fn failed_backwards_to_intro_node() {
534534 nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
535535 check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
536536 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 0 ] , & payment_event. commitment_msg , false , false ) ;
537- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
537+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
538538 check_added_monitors ! ( & nodes[ 1 ] , 1 ) ;
539539
540540 let mut events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
@@ -548,7 +548,7 @@ fn failed_backwards_to_intro_node() {
548548 check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
549549 do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event. commitment_msg , true , true ) ;
550550
551- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
551+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
552552 expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: InvalidOnion ] ) ;
553553 check_added_monitors ( & nodes[ 2 ] , 1 ) ;
554554
@@ -626,7 +626,7 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
626626 // Disconnect the next-hop peer so when we go to forward in process_pending_htlc_forwards, the
627627 // intro node will error backwards.
628628 $curr_node. node. peer_disconnected( $next_node. node. get_our_node_id( ) ) ;
629- expect_pending_htlcs_forwardable! ( $curr_node) ;
629+ expect_and_process_pending_htlcs ( & $curr_node, false ) ;
630630 expect_htlc_handling_failed_destinations!( $curr_node. node. get_and_clear_pending_events( ) ,
631631 vec![ HTLCHandlingFailureType :: Forward { node_id: Some ( $next_node. node. get_our_node_id( ) ) , channel_id: $failed_chan_id } ] ) ;
632632 } ,
@@ -636,10 +636,6 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
636636 $curr_node. node. force_close_broadcasting_latest_txn( & $failed_chan_id, & $next_node. node. get_our_node_id( ) , error_message. to_string( ) ) . unwrap( ) ;
637637 let events = $curr_node. node. get_and_clear_pending_events( ) ;
638638 match events[ 0 ] {
639- crate :: events:: Event :: PendingHTLCsForwardable { .. } => { } ,
640- _ => panic!( "Unexpected event {:?}" , events) ,
641- } ;
642- match events[ 1 ] {
643639 crate :: events:: Event :: ChannelClosed { .. } => { } ,
644640 _ => panic!( "Unexpected event {:?}" , events) ,
645641 }
@@ -649,7 +645,6 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
649645 $curr_node. node. process_pending_htlc_forwards( ) ;
650646 expect_htlc_handling_failed_destinations!( $curr_node. node. get_and_clear_pending_events( ) ,
651647 vec![ HTLCHandlingFailureType :: InvalidForward { requested_forward_scid: $failed_scid } ] ) ;
652- $curr_node. node. process_pending_htlc_forwards( ) ;
653648 } ,
654649 }
655650 }
@@ -662,7 +657,7 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
662657 return
663658 }
664659
665- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
660+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
666661 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
667662
668663 let mut updates_1_2 = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 2 ] . node. get_our_node_id( ) ) ;
@@ -729,7 +724,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
729724 } ;
730725 nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
731726 commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 0 ] , & payment_event. commitment_msg, false , true ) ;
732- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
727+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
733728
734729 let events = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
735730 assert_eq ! ( events. len( ) , 1 ) ;
@@ -747,15 +742,15 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
747742
748743 if intercept_node_fails {
749744 nodes[ 1 ] . node . fail_intercepted_htlc ( intercept_id) . unwrap ( ) ;
750- expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore ! ( nodes[ 1 ] , [ HTLCHandlingFailureType :: InvalidForward { requested_forward_scid: intercept_scid } ] ) ;
745+ expect_pending_htlcs_forwardable_conditions ( nodes[ 1 ] . node . get_and_clear_pending_events ( ) , & [ HTLCHandlingFailureType :: InvalidForward { requested_forward_scid : intercept_scid } ] ) ;
751746 nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
752747 check_added_monitors ! ( & nodes[ 1 ] , 1 ) ;
753748 fail_blinded_htlc_backwards ( payment_hash, 1 , & [ & nodes[ 0 ] , & nodes[ 1 ] ] , false ) ;
754749 return
755750 }
756751
757752 nodes[ 1 ] . node . forward_intercepted_htlc ( intercept_id, & channel_id, nodes[ 2 ] . node . get_our_node_id ( ) , expected_outbound_amount_msat) . unwrap ( ) ;
758- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
753+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
759754
760755 let payment_event = {
761756 {
@@ -769,7 +764,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
769764 } ;
770765 nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
771766 commitment_signed_dance ! ( nodes[ 2 ] , nodes[ 1 ] , & payment_event. commitment_msg, false , true ) ;
772- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
767+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
773768
774769 expect_payment_claimable ! ( & nodes[ 2 ] , payment_hash, payment_secret, amt_msat, None , nodes[ 2 ] . node. get_our_node_id( ) ) ;
775770 do_claim_payment_along_route (
@@ -958,7 +953,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
958953 nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event_0_1. msgs [ 0 ] ) ;
959954 check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
960955 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 0 ] , & payment_event_0_1. commitment_msg , false , false ) ;
961- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
956+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
962957 check_added_monitors ! ( & nodes[ 1 ] , 1 ) ;
963958
964959 let mut payment_event_1_2 = {
@@ -973,7 +968,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
973968 nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event_1_2. msgs [ 0 ] ) ;
974969 check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
975970 do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event_1_2. commitment_msg , true , true ) ;
976- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
971+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
977972 check_payment_claimable (
978973 & nodes[ 2 ] . node . get_and_clear_pending_events ( ) [ 0 ] , payment_hash, payment_secret, amt_msat,
979974 None , nodes[ 2 ] . node . get_our_node_id ( )
@@ -1009,7 +1004,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10091004 nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , update_add) ;
10101005 check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
10111006 do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event_1_2. commitment_msg , true , true ) ;
1012- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
1007+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
10131008 expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: InvalidOnion ] ) ;
10141009 check_added_monitors ( & nodes[ 2 ] , 1 ) ;
10151010 } ,
@@ -1019,7 +1014,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10191014 nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , update_add) ;
10201015 check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
10211016 do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event_1_2. commitment_msg , true , true ) ;
1022- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
1017+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
10231018 expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: Receive { payment_hash } ] ) ;
10241019 check_added_monitors ( & nodes[ 2 ] , 1 ) ;
10251020 } ,
@@ -1035,7 +1030,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10351030
10361031 nodes[ 2 ] . node . handle_shutdown ( nodes[ 1 ] . node . get_our_node_id ( ) , & node_1_shutdown) ;
10371032 commitment_signed_dance ! ( nodes[ 2 ] , nodes[ 1 ] , ( ) , false , true , false , false ) ;
1038- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
1033+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
10391034 expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: Receive { payment_hash } ] ) ;
10401035 check_added_monitors ( & nodes[ 2 ] , 1 ) ;
10411036 } ,
@@ -1044,16 +1039,15 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10441039 nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event_1_2. msgs [ 0 ] ) ;
10451040 check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
10461041 do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event_1_2. commitment_msg , true , true ) ;
1047- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
1048- expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore ! ( nodes[ 2 ] ,
1049- [ HTLCHandlingFailureType :: Receive { payment_hash } ] ) ;
1042+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , true ) ;
1043+ expect_pending_htlcs_forwardable_conditions ( nodes[ 2 ] . node . get_and_clear_pending_events ( ) , & [ HTLCHandlingFailureType :: Receive { payment_hash } ] ) ;
10501044 check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
10511045 } ,
10521046 ReceiveCheckFail :: PaymentConstraints => {
10531047 nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event_1_2. msgs [ 0 ] ) ;
10541048 check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
10551049 do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event_1_2. commitment_msg , true , true ) ;
1056- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
1050+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
10571051 expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: Receive { payment_hash } ] ) ;
10581052 check_added_monitors ( & nodes[ 2 ] , 1 ) ;
10591053 }
@@ -1162,18 +1156,14 @@ fn blinded_path_retries() {
11621156 do_commitment_signed_dance( & nodes[ 0 ] , & $intro_node, & updates. commitment_signed, false , false ) ;
11631157
11641158 let mut events = nodes[ 0 ] . node. get_and_clear_pending_events( ) ;
1165- assert_eq!( events. len( ) , 2 ) ;
1159+ assert_eq!( events. len( ) , 1 ) ;
11661160 match events[ 0 ] {
11671161 Event :: PaymentPathFailed { payment_hash: ev_payment_hash, payment_failed_permanently, .. } => {
11681162 assert_eq!( payment_hash, ev_payment_hash) ;
11691163 assert_eq!( payment_failed_permanently, false ) ;
11701164 } ,
11711165 _ => panic!( "Unexpected event" ) ,
11721166 }
1173- match events[ 1 ] {
1174- Event :: PendingHTLCsForwardable { .. } => { } ,
1175- _ => panic!( "Unexpected event" ) ,
1176- }
11771167 nodes[ 0 ] . node. process_pending_htlc_forwards( ) ;
11781168 }
11791169 }
@@ -1262,7 +1252,7 @@ fn min_htlc() {
12621252 nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event_0_1. msgs [ 0 ] ) ;
12631253 check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
12641254 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 0 ] , & payment_event_0_1. commitment_msg , true , true ) ;
1265- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1255+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
12661256 expect_htlc_handling_failed_destinations ! (
12671257 nodes[ 1 ] . node. get_and_clear_pending_events( ) ,
12681258 & [ HTLCHandlingFailureType :: Forward { node_id: Some ( nodes[ 2 ] . node. get_our_node_id( ) ) , channel_id: chan_1_2. 2 } ]
@@ -1455,7 +1445,7 @@ fn fails_receive_tlvs_authentication() {
14551445
14561446 nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
14571447 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 0 ] , & payment_event. commitment_msg , true , true ) ;
1458- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1448+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
14591449 nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
14601450 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
14611451 expect_htlc_handling_failed_destinations ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: InvalidOnion ] ) ;
0 commit comments