@@ -453,3 +453,45 @@ fn two_hop_blinded_path_success() {
453453 pass_along_route ( & nodes[ 0 ] , & [ & [ & nodes[ 1 ] , & nodes[ 2 ] ] ] , amt_msat, payment_hash, payment_secret) ;
454454 claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , payment_preimage) ;
455455}
456+
457+ #[ test]
458+ fn multi_hop_receiver_fail ( ) {
459+ let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
460+ let node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
461+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
462+ let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
463+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 1_000_000 , 0 ) ;
464+ let chan_upd_1_2 = create_announced_chan_between_nodes_with_value ( & nodes, 1 , 2 , 1_000_000 , 0 ) . 0 . contents ;
465+
466+ let amt_msat = 5000 ;
467+ let ( _, payment_hash, payment_secret) = get_payment_preimage_hash ( & nodes[ 2 ] , Some ( amt_msat) , None ) ;
468+ let route_params = get_blinded_route_parameters ( amt_msat, payment_secret,
469+ nodes. iter ( ) . skip ( 1 ) . map ( |n| n. node . get_our_node_id ( ) ) . collect ( ) , & [ & chan_upd_1_2] ,
470+ & chanmon_cfgs[ 2 ] . keys_manager ) ;
471+
472+ nodes[ 0 ] . node . send_payment ( payment_hash, RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_hash. 0 ) , route_params, Retry :: Attempts ( 0 ) ) . unwrap ( ) ;
473+ check_added_monitors ( & nodes[ 0 ] , 1 ) ;
474+ pass_along_route ( & nodes[ 0 ] , & [ & [ & nodes[ 1 ] , & nodes[ 2 ] ] ] , amt_msat, payment_hash, payment_secret) ;
475+
476+ nodes[ 2 ] . node . fail_htlc_backwards ( & payment_hash) ;
477+ expect_pending_htlcs_forwardable_conditions (
478+ nodes[ 2 ] . node . get_and_clear_pending_events ( ) , & [ HTLCDestination :: FailedPayment { payment_hash } ]
479+ ) ;
480+ nodes[ 2 ] . node . process_pending_htlc_forwards ( ) ;
481+ check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
482+
483+ let updates_2_1 = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
484+ assert_eq ! ( updates_2_1. update_fail_malformed_htlcs. len( ) , 1 ) ;
485+ let update_malformed = & updates_2_1. update_fail_malformed_htlcs [ 0 ] ;
486+ assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
487+ assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
488+ nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( & nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
489+ do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates_2_1. commitment_signed , true , false ) ;
490+
491+ let updates_1_0 = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
492+ assert_eq ! ( updates_1_0. update_fail_htlcs. len( ) , 1 ) ;
493+ nodes[ 0 ] . node . handle_update_fail_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & updates_1_0. update_fail_htlcs [ 0 ] ) ;
494+ do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates_1_0. commitment_signed , false , false ) ;
495+ expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
496+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
497+ }
0 commit comments