@@ -2497,8 +2497,7 @@ fn test_trampoline_constraint_enforcement() {
24972497 }
24982498}
24992499
2500- #[ test]
2501- fn test_unblinded_trampoline_forward ( ) {
2500+ fn do_test_unblinded_trampoline_forward ( success : bool ) {
25022501 // Simulate a payment of A (0) -> B (1) -> C(Trampoline) (2) -> D(Trampoline(receive)) (3)
25032502 // trampoline hops C -> T0 (4) -> D
25042503 // make it fail at B, then at C's outer onion, then at C's inner onion
@@ -2512,7 +2511,9 @@ fn test_unblinded_trampoline_forward() {
25122511
25132512 let ( _, _, chan_id_alice_bob, _) = create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 1_000_000 , 0 ) ;
25142513 let ( _, _, chan_id_bob_carol, _) = create_announced_chan_between_nodes_with_value ( & nodes, 1 , 2 , 1_000_000 , 0 ) ;
2515- let ( _, _, _, _) = create_announced_chan_between_nodes_with_value ( & nodes, 2 , 4 , 1_000_000 , 0 ) ;
2514+ if success {
2515+ let ( _, _, _, _) = create_announced_chan_between_nodes_with_value ( & nodes, 2 , 4 , 1_000_000 , 0 ) ;
2516+ }
25162517 let ( _, _, _, _) = create_announced_chan_between_nodes_with_value ( & nodes, 4 , 3 , 1_000_000 , 0 ) ;
25172518
25182519 for i in 0 ..TOTAL_NODE_COUNT { // connect all nodes' blocks
@@ -2651,10 +2652,48 @@ fn test_unblinded_trampoline_forward() {
26512652 msg. onion_routing_packet = replacement_onion. clone ( ) ;
26522653 } ) ;
26532654
2654- let route: & [ & Node ] = & [ & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 4 ] , & nodes[ 3 ] ] ;
2655- let args = PassAlongPathArgs :: new ( & nodes[ 0 ] , route, amt_msat, payment_hash, first_message_event)
2656- . with_payment_secret ( payment_secret) ;
2655+ let route: & [ & Node ] = if success {
2656+ & [ & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 4 ] , & nodes[ 3 ] ]
2657+ } else {
2658+ & [ & nodes[ 1 ] , & nodes[ 2 ] ]
2659+ } ;
2660+ let args = PassAlongPathArgs :: new ( & nodes[ 0 ] , route, amt_msat, payment_hash, first_message_event) ;
2661+ let args = if success {
2662+ args. with_payment_secret ( payment_secret)
2663+ } else {
2664+ args. with_payment_preimage ( payment_preimage)
2665+ . without_claimable_event ( )
2666+ . expect_failure ( HTLCDestination :: FailedTrampolineForward { requested_next_node_id : dave_node_id, forward_scid : None } )
2667+ } ;
26572668 do_pass_along_path ( args) ;
26582669
2659- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 4 ] , & nodes[ 3 ] ] , payment_preimage) ;
2670+ if success {
2671+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 4 ] , & nodes[ 3 ] ] , payment_preimage) ;
2672+ } else {
2673+ {
2674+ let unblinded_node_updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
2675+ nodes[ 1 ] . node . handle_update_fail_htlc (
2676+ nodes[ 2 ] . node . get_our_node_id ( ) , & unblinded_node_updates. update_fail_htlcs [ 0 ]
2677+ ) ;
2678+ do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & unblinded_node_updates. commitment_signed , true , false ) ;
2679+ }
2680+ {
2681+ let unblinded_node_updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
2682+ nodes[ 0 ] . node . handle_update_fail_htlc (
2683+ nodes[ 1 ] . node . get_our_node_id ( ) , & unblinded_node_updates. update_fail_htlcs [ 0 ]
2684+ ) ;
2685+ do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & unblinded_node_updates. commitment_signed , false , false ) ;
2686+ }
2687+ {
2688+ let payment_failed_conditions = PaymentFailedConditions :: new ( )
2689+ . expected_htlc_error_data ( 0x2000 | 25 , & [ 0 ; 0 ] ) ;
2690+ expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false , payment_failed_conditions) ;
2691+ }
2692+ }
2693+ }
2694+
2695+ #[ test]
2696+ fn test_unblinded_trampoline_forward ( ) {
2697+ do_test_unblinded_trampoline_forward ( true ) ;
2698+ do_test_unblinded_trampoline_forward ( false ) ;
26602699}
0 commit comments