@@ -1020,6 +1020,53 @@ def test_xpay_bip353(node_factory):
10201020 l2 .
rpc .
xpay (
'[email protected] ' ,
100 )
10211021
10221022
1023+ @pytest .mark .xfail (strict = True )
1024+ def test_xpay_limited_max_accepted_htlcs (node_factory ):
1025+ """xpay should try to reduce flows to 6 if there is an unannounced channel, and only try more if that fails"""
1026+ CHANNEL_SIZE_SATS = 10 ** 6
1027+ l1 , l2 = node_factory .line_graph (2 ,
1028+ fundamount = CHANNEL_SIZE_SATS * 20 ,
1029+ opts = [{}, {'max-concurrent-htlcs' : 6 }],
1030+ announce_channels = False )
1031+
1032+ # We want 10 paths between l3 and l1.
1033+ l3 = node_factory .get_node ()
1034+ nodes = node_factory .get_nodes (10 )
1035+ for n in nodes :
1036+ node_factory .join_nodes ([l3 , n , l1 ], fundamount = CHANNEL_SIZE_SATS )
1037+
1038+ # We don't want to use up capacity, so we make payment fail.
1039+ inv1 = l1 .rpc .invoice (f"{ CHANNEL_SIZE_SATS * 5 } sat" ,
1040+ 'test_xpay_limited_max_accepted_htlcs' ,
1041+ 'test_xpay_limited_max_accepted_htlcs' )['bolt11' ]
1042+ l1 .rpc .delinvoice ('test_xpay_limited_max_accepted_htlcs' , 'unpaid' )
1043+
1044+ with pytest .raises (RpcError , match = "Destination said it doesn't know invoice" ):
1045+ l3 .rpc .xpay (inv1 )
1046+
1047+ # 7 flows.
1048+ l3 .daemon .wait_for_log ('Final answer has 7 flows' )
1049+
1050+ # If we have a routehint, it will squeeze into 6.
1051+ inv2 = l2 .rpc .invoice (f"{ CHANNEL_SIZE_SATS * 5 } sat" ,
1052+ 'test_xpay_limited_max_accepted_htlcs' ,
1053+ 'test_xpay_limited_max_accepted_htlcs' )['bolt11' ]
1054+ l2 .rpc .delinvoice ('test_xpay_limited_max_accepted_htlcs' , 'unpaid' )
1055+ with pytest .raises (RpcError , match = "Destination said it doesn't know invoice" ):
1056+ l3 .rpc .xpay (inv2 )
1057+
1058+ # 6 flows.
1059+ l3 .daemon .wait_for_log ('Final answer has 6 flows' )
1060+
1061+ # If we force it, it will use more flows.
1062+ inv2 = l2 .rpc .invoice (f"{ CHANNEL_SIZE_SATS * 6 } sat" ,
1063+ 'test_xpay_limited_max_accepted_htlcs2' ,
1064+ 'test_xpay_limited_max_accepted_htlcs2' )['bolt11' ]
1065+ l2 .rpc .delinvoice ('test_xpay_limited_max_accepted_htlcs2' , 'unpaid' )
1066+ with pytest .raises (RpcError , match = "We got temporary_channel_failure" ):
1067+ l3 .rpc .xpay (inv2 )
1068+
1069+
10231070def test_xpay_blockheight_mismatch (node_factory , bitcoind , executor ):
10241071 """We should wait a (reasonable) amount if the final node gives us a blockheight that would explain our failure."""
10251072 l1 , l2 , l3 = node_factory .line_graph (3 , wait_for_announce = True )
0 commit comments