@@ -5144,7 +5144,14 @@ def test_listpays_with_filter_by_status(node_factory, bitcoind):
51445144
51455145
51465146def test_sendpay_grouping (node_factory , bitcoind ):
5147- """Paying an invoice multiple times, listpays should list them individually
5147+ """`listpays` should be smart enough to group repeated `pay` calls.
5148+
5149+ We always use slightly decreasing values for the payment, in order
5150+ to avoid having to adjust the channel_hints that are being
5151+ remembered across attempts. In case of a failure the
5152+ `channel_hint` will be `attempted amount - 1msat` so use that as
5153+ the next payment's amount.
5154+
51485155 """
51495156 l1 , l2 , l3 = node_factory .line_graph (
51505157 3 ,
@@ -5164,13 +5171,13 @@ def test_sendpay_grouping(node_factory, bitcoind):
51645171 assert (len (l1 .rpc .listpays ()['pays' ]) == 0 )
51655172
51665173 with pytest .raises (RpcError , match = r'Ran out of routes to try after [0-9]+ attempts' ):
5167- l1 .rpc .pay (inv , amount_msat = '100000msat ' )
5174+ l1 .rpc .pay (inv , amount_msat = '100002msat ' )
51685175
51695176 # After this one invocation we have one entry in `listpays`
51705177 assert (len (l1 .rpc .listpays ()['pays' ]) == 1 )
51715178
51725179 with pytest .raises (RpcError , match = r'Ran out of routes to try after [0-9]+ attempts' ):
5173- l1 .rpc .pay (inv , amount_msat = '200000msat ' )
5180+ l1 .rpc .pay (inv , amount_msat = '100001msat ' )
51745181
51755182 # Surprise: we should have 2 entries after 2 invocations
51765183 assert (len (l1 .rpc .listpays ()['pays' ]) == 2 )
@@ -5183,7 +5190,7 @@ def test_sendpay_grouping(node_factory, bitcoind):
51835190 wait_for (lambda : only_one (l3 .rpc .listpeers ()['peers' ])['connected' ] is True )
51845191 scid = l3 .rpc .listpeerchannels ()['channels' ][0 ]['short_channel_id' ]
51855192 wait_for (lambda : [c ['active' ] for c in l1 .rpc .listchannels (scid )['channels' ]] == [True , True ])
5186- l1 .rpc .pay (inv , amount_msat = '420000msat ' )
5193+ l1 .rpc .pay (inv , amount_msat = '10000msat ' )
51875194
51885195 # And finally we should have all 3 attempts to pay the invoice
51895196 pays = l1 .rpc .listpays ()['pays' ]
0 commit comments