@@ -2256,6 +2256,36 @@ fn abandoned_send_payment_idempotent() {
22562256 claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , second_payment_preimage) ;
22572257}
22582258
2259+ #[ test]
2260+ fn abandoned_payment_fulfilled_preserves_fee_paid_msat ( ) {
2261+ // Previously, if we abandoned a payment with HTLCs in-flight and the payment eventually
2262+ // succeeded, we would set the `Event::PaymentSent::fee_paid_msat` to None, even though we had
2263+ // docs guaranteeing that it would always be Some after 0.0.103.
2264+ let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
2265+ let node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
2266+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
2267+ let nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
2268+
2269+ create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
2270+ create_announced_chan_between_nodes ( & nodes, 1 , 2 ) ;
2271+
2272+ let amt_msat = 10_000_000 ;
2273+ let ( route, payment_hash, payment_preimage, payment_secret) =
2274+ get_route_and_payment_hash ! ( & nodes[ 0 ] , nodes[ 2 ] , amt_msat) ;
2275+ let payment_id = PaymentId ( payment_hash. 0 ) ;
2276+ let onion = RecipientOnionFields :: secret_only ( payment_secret, amt_msat) ;
2277+ nodes[ 0 ] . node . send_payment_with_route ( route, payment_hash, onion, payment_id) . unwrap ( ) ;
2278+ check_added_monitors ( & nodes[ 0 ] , 1 ) ;
2279+
2280+ let path: & [ & Node ] = & [ & nodes[ 1 ] , & nodes[ 2 ] ] ;
2281+ pass_along_route ( & nodes[ 0 ] , & [ path] , amt_msat, payment_hash, payment_secret) ;
2282+
2283+ nodes[ 0 ] . node . abandon_payment ( payment_id) ;
2284+ assert ! ( nodes[ 0 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
2285+
2286+ claim_payment_along_route ( ClaimAlongRouteArgs :: new ( & nodes[ 0 ] , & [ path] , payment_preimage) ) ;
2287+ }
2288+
22592289#[ derive( PartialEq ) ]
22602290enum InterceptTest {
22612291 Forward ,
0 commit comments