@@ -3779,3 +3779,43 @@ async fn test_trampoline_mpp_with_oneway() {
37793779 run_with_hash_algo ( & node1, & node2, & node4, HashAlgorithm :: CkbHash ) . await ;
37803780 run_with_hash_algo ( & node1, & node2, & node4, HashAlgorithm :: Sha256 ) . await ;
37813781}
3782+
3783+ #[ tokio:: test]
3784+ async fn test_trampoline_routing_with_self_payment_should_fail ( ) {
3785+ init_tracing ( ) ;
3786+
3787+ // Create a simple network with 2 nodes
3788+ let ( nodes, _channels) = create_n_nodes_network_with_visibility (
3789+ & [ ( ( 0 , 1 ) , ( MIN_RESERVED_CKB + 100000 , HUGE_CKB_AMOUNT ) , true ) ] ,
3790+ 2 ,
3791+ )
3792+ . await ;
3793+
3794+ let [ node_a, node_b] = nodes. try_into ( ) . expect ( "2 nodes" ) ;
3795+
3796+ // Wait until A learns B supports trampoline routing.
3797+ wait_until_node_supports_trampoline_routing ( & node_a, & node_b) . await ;
3798+
3799+ let amount: u128 = 1000 ;
3800+
3801+ // Try to send payment to self with trampoline routing enabled
3802+ // This should fail with validation error
3803+ let res = node_a
3804+ . send_payment ( SendPaymentCommand {
3805+ target_pubkey : Some ( node_a. get_public_key ( ) ) ,
3806+ amount : Some ( amount) ,
3807+ allow_self_payment : true ,
3808+ trampoline_hops : Some ( vec ! [ node_b. get_public_key( ) ] ) ,
3809+ max_fee_amount : Some ( 500 ) ,
3810+ keysend : Some ( true ) ,
3811+ ..Default :: default ( )
3812+ } )
3813+ . await ;
3814+
3815+ let err_msg = res. err ( ) . unwrap ( ) ;
3816+ assert ! (
3817+ err_msg. contains( "allow_self_payment cannot be enabled with trampoline routing" ) ,
3818+ "Expected error, got: {}" ,
3819+ err_msg
3820+ ) ;
3821+ }
0 commit comments