@@ -439,7 +439,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
439
439
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
440
440
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 0 ] , & updates_0_1. commitment_signed , true , true ) ;
441
441
442
- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
442
+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
443
443
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
444
444
445
445
if intro_fails {
@@ -477,7 +477,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
477
477
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
478
478
do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & updates_1_2. commitment_signed , true , true ) ;
479
479
480
- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
480
+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
481
481
let failed_destination = match check {
482
482
ForwardCheckFail :: InboundOnionCheck |ForwardCheckFail :: ForwardPayloadEncodedAsReceive => HTLCHandlingFailureType :: InvalidOnion ,
483
483
ForwardCheckFail :: OutboundChannelCheck =>
@@ -534,7 +534,7 @@ fn failed_backwards_to_intro_node() {
534
534
nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
535
535
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
536
536
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 ) ;
538
538
check_added_monitors ! ( & nodes[ 1 ] , 1 ) ;
539
539
540
540
let mut events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
@@ -548,7 +548,7 @@ fn failed_backwards_to_intro_node() {
548
548
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
549
549
do_commitment_signed_dance ( & nodes[ 2 ] , & nodes[ 1 ] , & payment_event. commitment_msg , true , true ) ;
550
550
551
- expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
551
+ expect_and_process_pending_htlcs ( & nodes[ 2 ] , false ) ;
552
552
expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: InvalidOnion ] ) ;
553
553
check_added_monitors ( & nodes[ 2 ] , 1 ) ;
554
554
@@ -626,7 +626,7 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
626
626
// Disconnect the next-hop peer so when we go to forward in process_pending_htlc_forwards, the
627
627
// intro node will error backwards.
628
628
$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 ) ;
630
630
expect_htlc_handling_failed_destinations!( $curr_node. node. get_and_clear_pending_events( ) ,
631
631
vec![ HTLCHandlingFailureType :: Forward { node_id: Some ( $next_node. node. get_our_node_id( ) ) , channel_id: $failed_chan_id } ] ) ;
632
632
} ,
@@ -636,10 +636,6 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
636
636
$curr_node. node. force_close_broadcasting_latest_txn( & $failed_chan_id, & $next_node. node. get_our_node_id( ) , error_message. to_string( ) ) . unwrap( ) ;
637
637
let events = $curr_node. node. get_and_clear_pending_events( ) ;
638
638
match events[ 0 ] {
639
- crate :: events:: Event :: PendingHTLCsForwardable { .. } => { } ,
640
- _ => panic!( "Unexpected event {:?}" , events) ,
641
- } ;
642
- match events[ 1 ] {
643
639
crate :: events:: Event :: ChannelClosed { .. } => { } ,
644
640
_ => panic!( "Unexpected event {:?}" , events) ,
645
641
}
@@ -649,7 +645,6 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
649
645
$curr_node. node. process_pending_htlc_forwards( ) ;
650
646
expect_htlc_handling_failed_destinations!( $curr_node. node. get_and_clear_pending_events( ) ,
651
647
vec![ HTLCHandlingFailureType :: InvalidForward { requested_forward_scid: $failed_scid } ] ) ;
652
- $curr_node. node. process_pending_htlc_forwards( ) ;
653
648
} ,
654
649
}
655
650
}
@@ -662,7 +657,7 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
662
657
return
663
658
}
664
659
665
- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
660
+ expect_and_process_pending_htlcs ( & nodes[ 1 ] , false ) ;
666
661
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
667
662
668
663
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) {
729
724
} ;
730
725
nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
731
726
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 ) ;
733
728
734
729
let events = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
735
730
assert_eq ! ( events. len( ) , 1 ) ;
@@ -747,15 +742,15 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
747
742
748
743
if intercept_node_fails {
749
744
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 } ] ) ;
751
746
nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
752
747
check_added_monitors ! ( & nodes[ 1 ] , 1 ) ;
753
748
fail_blinded_htlc_backwards ( payment_hash, 1 , & [ & nodes[ 0 ] , & nodes[ 1 ] ] , false ) ;
754
749
return
755
750
}
756
751
757
752
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 ) ;
759
754
760
755
let payment_event = {
761
756
{
@@ -769,7 +764,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
769
764
} ;
770
765
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
771
766
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 ) ;
773
768
774
769
expect_payment_claimable ! ( & nodes[ 2 ] , payment_hash, payment_secret, amt_msat, None , nodes[ 2 ] . node. get_our_node_id( ) ) ;
775
770
do_claim_payment_along_route (
@@ -958,7 +953,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
958
953
nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event_0_1. msgs [ 0 ] ) ;
959
954
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
960
955
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 ) ;
962
957
check_added_monitors ! ( & nodes[ 1 ] , 1 ) ;
963
958
964
959
let mut payment_event_1_2 = {
@@ -973,7 +968,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
973
968
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event_1_2. msgs [ 0 ] ) ;
974
969
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
975
970
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 ) ;
977
972
check_payment_claimable (
978
973
& nodes[ 2 ] . node . get_and_clear_pending_events ( ) [ 0 ] , payment_hash, payment_secret, amt_msat,
979
974
None , nodes[ 2 ] . node . get_our_node_id ( )
@@ -1009,7 +1004,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
1009
1004
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , update_add) ;
1010
1005
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
1011
1006
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 ) ;
1013
1008
expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: InvalidOnion ] ) ;
1014
1009
check_added_monitors ( & nodes[ 2 ] , 1 ) ;
1015
1010
} ,
@@ -1019,7 +1014,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
1019
1014
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , update_add) ;
1020
1015
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
1021
1016
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 ) ;
1023
1018
expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: Receive { payment_hash } ] ) ;
1024
1019
check_added_monitors ( & nodes[ 2 ] , 1 ) ;
1025
1020
} ,
@@ -1035,7 +1030,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
1035
1030
1036
1031
nodes[ 2 ] . node . handle_shutdown ( nodes[ 1 ] . node . get_our_node_id ( ) , & node_1_shutdown) ;
1037
1032
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 ) ;
1039
1034
expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: Receive { payment_hash } ] ) ;
1040
1035
check_added_monitors ( & nodes[ 2 ] , 1 ) ;
1041
1036
} ,
@@ -1044,16 +1039,15 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
1044
1039
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event_1_2. msgs [ 0 ] ) ;
1045
1040
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
1046
1041
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 } ] ) ;
1050
1044
check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1051
1045
} ,
1052
1046
ReceiveCheckFail :: PaymentConstraints => {
1053
1047
nodes[ 2 ] . node . handle_update_add_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & payment_event_1_2. msgs [ 0 ] ) ;
1054
1048
check_added_monitors ! ( nodes[ 2 ] , 0 ) ;
1055
1049
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 ) ;
1057
1051
expect_htlc_handling_failed_destinations ! ( nodes[ 2 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: Receive { payment_hash } ] ) ;
1058
1052
check_added_monitors ( & nodes[ 2 ] , 1 ) ;
1059
1053
}
@@ -1162,18 +1156,14 @@ fn blinded_path_retries() {
1162
1156
do_commitment_signed_dance( & nodes[ 0 ] , & $intro_node, & updates. commitment_signed, false , false ) ;
1163
1157
1164
1158
let mut events = nodes[ 0 ] . node. get_and_clear_pending_events( ) ;
1165
- assert_eq!( events. len( ) , 2 ) ;
1159
+ assert_eq!( events. len( ) , 1 ) ;
1166
1160
match events[ 0 ] {
1167
1161
Event :: PaymentPathFailed { payment_hash: ev_payment_hash, payment_failed_permanently, .. } => {
1168
1162
assert_eq!( payment_hash, ev_payment_hash) ;
1169
1163
assert_eq!( payment_failed_permanently, false ) ;
1170
1164
} ,
1171
1165
_ => panic!( "Unexpected event" ) ,
1172
1166
}
1173
- match events[ 1 ] {
1174
- Event :: PendingHTLCsForwardable { .. } => { } ,
1175
- _ => panic!( "Unexpected event" ) ,
1176
- }
1177
1167
nodes[ 0 ] . node. process_pending_htlc_forwards( ) ;
1178
1168
}
1179
1169
}
@@ -1262,7 +1252,7 @@ fn min_htlc() {
1262
1252
nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event_0_1. msgs [ 0 ] ) ;
1263
1253
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
1264
1254
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 ) ;
1266
1256
expect_htlc_handling_failed_destinations ! (
1267
1257
nodes[ 1 ] . node. get_and_clear_pending_events( ) ,
1268
1258
& [ 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() {
1455
1445
1456
1446
nodes[ 1 ] . node . handle_update_add_htlc ( nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
1457
1447
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 ) ;
1459
1449
nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
1460
1450
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1461
1451
expect_htlc_handling_failed_destinations ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) , & [ HTLCHandlingFailureType :: InvalidOnion ] ) ;
0 commit comments