@@ -9006,107 +9006,6 @@ fn test_tx_confirmed_skipping_blocks_immediate_broadcast() {
9006
9006
do_test_tx_confirmed_skipping_blocks_immediate_broadcast ( true ) ;
9007
9007
}
9008
9008
9009
- fn do_test_dup_htlc_second_rejected ( test_for_second_fail_panic : bool ) {
9010
- let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
9011
- let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
9012
- let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
9013
- let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
9014
-
9015
- let _chan = create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 10001 ) ;
9016
-
9017
- let payment_params = PaymentParameters :: from_node_id ( nodes[ 1 ] . node . get_our_node_id ( ) , TEST_FINAL_CLTV )
9018
- . with_features ( nodes[ 1 ] . node . invoice_features ( ) ) ;
9019
- let route = get_route ! ( nodes[ 0 ] , payment_params, 10_000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
9020
-
9021
- let ( our_payment_preimage, our_payment_hash, our_payment_secret) = get_payment_preimage_hash ! ( & nodes[ 1 ] ) ;
9022
-
9023
- {
9024
- nodes[ 0 ] . node . send_payment ( & route, our_payment_hash, & Some ( our_payment_secret) , PaymentId ( our_payment_hash. 0 ) ) . unwrap ( ) ;
9025
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
9026
- let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
9027
- assert_eq ! ( events. len( ) , 1 ) ;
9028
- let mut payment_event = SendEvent :: from_event ( events. pop ( ) . unwrap ( ) ) ;
9029
- nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
9030
- commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 0 ] , payment_event. commitment_msg, false ) ;
9031
- }
9032
- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
9033
- expect_payment_claimable ! ( nodes[ 1 ] , our_payment_hash, our_payment_secret, 10_000 ) ;
9034
-
9035
- {
9036
- // Note that we use a different PaymentId here to allow us to duplicativly pay
9037
- nodes[ 0 ] . node . send_payment ( & route, our_payment_hash, & Some ( our_payment_secret) , PaymentId ( our_payment_secret. 0 ) ) . unwrap ( ) ;
9038
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
9039
- let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
9040
- assert_eq ! ( events. len( ) , 1 ) ;
9041
- let mut payment_event = SendEvent :: from_event ( events. pop ( ) . unwrap ( ) ) ;
9042
- nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
9043
- commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 0 ] , payment_event. commitment_msg, false ) ;
9044
- // At this point, nodes[1] would notice it has too much value for the payment. It will
9045
- // assume the second is a privacy attack (no longer particularly relevant
9046
- // post-payment_secrets) and fail back the new HTLC. Previously, it'd also have failed back
9047
- // the first HTLC delivered above.
9048
- }
9049
-
9050
- expect_pending_htlcs_forwardable_ignore ! ( nodes[ 1 ] ) ;
9051
- nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
9052
-
9053
- if test_for_second_fail_panic {
9054
- // Now we go fail back the first HTLC from the user end.
9055
- nodes[ 1 ] . node . fail_htlc_backwards ( & our_payment_hash) ;
9056
-
9057
- let expected_destinations = vec ! [
9058
- HTLCDestination :: FailedPayment { payment_hash: our_payment_hash } ,
9059
- HTLCDestination :: FailedPayment { payment_hash: our_payment_hash } ,
9060
- ] ;
9061
- expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore ! ( nodes[ 1 ] , expected_destinations) ;
9062
- nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
9063
-
9064
- check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
9065
- let fail_updates_1 = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
9066
- assert_eq ! ( fail_updates_1. update_fail_htlcs. len( ) , 2 ) ;
9067
-
9068
- nodes[ 0 ] . node . handle_update_fail_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & fail_updates_1. update_fail_htlcs [ 0 ] ) ;
9069
- nodes[ 0 ] . node . handle_update_fail_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & fail_updates_1. update_fail_htlcs [ 1 ] ) ;
9070
- commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , fail_updates_1. commitment_signed, false ) ;
9071
-
9072
- let failure_events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
9073
- assert_eq ! ( failure_events. len( ) , 4 ) ;
9074
- if let Event :: PaymentPathFailed { .. } = failure_events[ 0 ] { } else { panic ! ( ) ; }
9075
- if let Event :: PaymentFailed { .. } = failure_events[ 1 ] { } else { panic ! ( ) ; }
9076
- if let Event :: PaymentPathFailed { .. } = failure_events[ 2 ] { } else { panic ! ( ) ; }
9077
- if let Event :: PaymentFailed { .. } = failure_events[ 3 ] { } else { panic ! ( ) ; }
9078
- } else {
9079
- // Let the second HTLC fail and claim the first
9080
- expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore ! ( nodes[ 1 ] , vec![ HTLCDestination :: FailedPayment { payment_hash: our_payment_hash } ] ) ;
9081
- nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
9082
-
9083
- check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
9084
- let fail_updates_1 = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
9085
- nodes[ 0 ] . node . handle_update_fail_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & fail_updates_1. update_fail_htlcs [ 0 ] ) ;
9086
- commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , fail_updates_1. commitment_signed, false ) ;
9087
-
9088
- expect_payment_failed_conditions ( & nodes[ 0 ] , our_payment_hash, true , PaymentFailedConditions :: new ( ) ) ;
9089
-
9090
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , our_payment_preimage) ;
9091
- }
9092
- }
9093
-
9094
- #[ test]
9095
- fn test_dup_htlc_second_fail_panic ( ) {
9096
- // Previously, if we received two HTLCs back-to-back, where the second overran the expected
9097
- // value for the payment, we'd fail back both HTLCs after generating a `PaymentClaimable` event.
9098
- // Then, if the user failed the second payment, they'd hit a "tried to fail an already failed
9099
- // HTLC" debug panic. This tests for this behavior, checking that only one HTLC is auto-failed.
9100
- do_test_dup_htlc_second_rejected ( true ) ;
9101
- }
9102
-
9103
- #[ test]
9104
- fn test_dup_htlc_second_rejected ( ) {
9105
- // Test that if we receive a second HTLC for an MPP payment that overruns the payment amount we
9106
- // simply reject the second HTLC but are still able to claim the first HTLC.
9107
- do_test_dup_htlc_second_rejected ( false ) ;
9108
- }
9109
-
9110
9009
#[ test]
9111
9010
fn test_inconsistent_mpp_params ( ) {
9112
9011
// Test that if we recieve two HTLCs with different payment parameters we fail back the first
0 commit comments