Skip to content

Commit 72d3263

Browse files
committed
pay: add missing deprecation annotation
- add missing deprecation annotation to "pay" command, - fix tests that required allow-deprecated-apis=True in order to continue using "pay", - change "pay" to "xpay" in those tests that are NOT testing "pay" directly but just want to make a payment, - and in tests that could be relevant for both "xpay" and "pay", use both. Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
1 parent d99d86f commit 72d3263

4 files changed

Lines changed: 46 additions & 26 deletions

File tree

plugins/pay.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,8 @@ static const struct plugin_command commands[] = {
11681168
},
11691169
{
11701170
"pay",
1171-
json_pay
1171+
json_pay,
1172+
"v26.06", "v27.03",
11721173
},
11731174
};
11741175

tests/test_clnrest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ def test_numeric_msat_notification(node_factory):
422422
# create rune authorizing listclnrest-notifications method
423423
rune_clnrest_notifications = l2.rpc.createrune(restrictions=[["method=listclnrest-notifications"]])['rune']
424424
http_session.headers.update({"rune": rune_clnrest_notifications})
425-
notifications = notifications_received_via_websocket(l1, base_url, http_session, 'pay', [inv['bolt11']])
425+
notifications = notifications_received_via_websocket(l1, base_url,
426+
http_session, 'xpay', [inv['bolt11']])
426427
filtered_notifications = [n for n in notifications if 'invoice_payment' in n]
427428

428429
assert isinstance(filtered_notifications[0]['invoice_payment']['msat'], int)
@@ -875,7 +876,7 @@ def test_dynamic_path_rune(node_factory):
875876
dynamic_res.json()["message"] == "Not permitted: method is not equal to notpay"
876877
)
877878

878-
rune = l1.rpc.createrune(restrictions=[["method=pay"]])["rune"]
879+
rune = l1.rpc.createrune(restrictions=[["method=xpay"]])["rune"]
879880
dynamic_res = http_session.post(
880881
base_url + "/test/dynamic/clnrest", headers={"Rune": rune}, verify=ca_cert
881882
)

tests/test_pay.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
@pytest.mark.openchannel('v1')
2525
@pytest.mark.openchannel('v2')
2626
def test_pay(node_factory):
27-
l1, l2 = node_factory.line_graph(2)
27+
l1, l2 = node_factory.line_graph(2, opts={"allow-deprecated-apis": True,
28+
"xpay-handle-pay": False})
2829

2930
inv = l2.rpc.invoice(123000, 'test_pay', 'description')['bolt11']
3031
before = int(time.time())
@@ -84,8 +85,10 @@ def test_pay(node_factory):
8485
assert apys_1[0]['routed_in_msat'] == apys_2[0]['routed_out_msat']
8586

8687

87-
def test_pay_invstring(node_factory):
88-
l1, l2 = node_factory.line_graph(2, opts={'allow-deprecated-apis': True})
88+
@pytest.mark.parametrize("xpay_handle_pay", [True, False])
89+
def test_pay_invstring(node_factory, xpay_handle_pay):
90+
l1, l2 = node_factory.line_graph(2, opts={'allow-deprecated-apis': True,
91+
"xpay-handle-pay": xpay_handle_pay})
8992

9093
l1.rpc.check_request_schemas = False
9194
inv = l2.rpc.invoice(123000, 'test_pay_invstring', 'description')['bolt11']
@@ -2381,7 +2384,8 @@ def test_setchannel_routing(node_factory, bitcoind):
23812384
assert 'warning_capacity' in inv
23822385

23832386

2384-
def test_setchannel_zero(node_factory, bitcoind):
2387+
@pytest.mark.parametrize("xpay_handle_pay", [True, False])
2388+
def test_setchannel_zero(node_factory, bitcoind, xpay_handle_pay):
23852389
# TEST SETUP
23862390
#
23872391
# [l1] <--default_fees--> [l2] <--specific_fees--> [l3]
@@ -2395,7 +2399,8 @@ def test_setchannel_zero(node_factory, bitcoind):
23952399

23962400
l1, l2, l3 = node_factory.line_graph(
23972401
3, announce_channels=True, wait_for_announce=True,
2398-
opts={'fee-base': DEF_BASE, 'fee-per-satoshi': DEF_PPM})
2402+
opts={'fee-base': DEF_BASE, 'fee-per-satoshi': DEF_PPM,
2403+
"allow-deprecated-apis": True, "xpay-handle-pay": xpay_handle_pay})
23992404

24002405
# get short channel id for 2->3
24012406
scid = l2.get_channel_scid(l3)
@@ -3428,13 +3433,16 @@ def test_reject_invalid_payload(node_factory):
34283433
l2.daemon.wait_for_log(r'Failing HTLC because of an invalid payload')
34293434

34303435

3431-
def test_excluded_adjacent_routehint(node_factory, bitcoind):
3436+
@pytest.mark.parametrize("xpay_handle_pay", [True, False])
3437+
def test_excluded_adjacent_routehint(node_factory, bitcoind, xpay_handle_pay):
34323438
"""Test case where we try have a routehint which leads to an adjacent
34333439
node, but the result exceeds our maxfee; we crashed trying to find
34343440
what part of the path was most expensive in that case
34353441
34363442
"""
3437-
l1, l2, l3 = node_factory.line_graph(3)
3443+
l1, l2, l3 = node_factory.line_graph(3, opts={"allow-deprecated-apis": True,
3444+
"xpay-handle-pay":
3445+
xpay_handle_pay})
34383446

34393447
# Make sure l2->l3 is usable.
34403448
wait_for(lambda: 'remote' in only_one(l3.rpc.listpeerchannels()['channels'])['updates'])
@@ -3446,7 +3454,10 @@ def test_excluded_adjacent_routehint(node_factory, bitcoind):
34463454
wait_for(lambda: 'remote' in only_one(l1.rpc.listpeerchannels()['channels'])['updates'])
34473455

34483456
# This will make it reject the routehint.
3449-
err = 'Failed: Could not find route without excessive cost'
3457+
if xpay_handle_pay:
3458+
err = 'Failed: Could not find route without excessive cost'
3459+
else:
3460+
err = 'Fee exceeds our fee budget: 1msat > 0msat'
34503461
with pytest.raises(RpcError, match=err):
34513462
l1.rpc.pay(bolt11=inv['bolt11'], maxfeepercent=0, exemptfee=0)
34523463

@@ -4837,13 +4848,13 @@ def test_recurrence_expired_offer(node_factory, bitcoind):
48374848
ret = l1.rpc.fetchinvoice(offer=offer['bolt12'],
48384849
recurrence_counter=0,
48394850
recurrence_label='test_recurrence_expired_offer')
4840-
l1.rpc.pay(ret['invoice'], label='test_recurrence_expired_offer')
4851+
l1.rpc.xpay(ret['invoice'], label='test_recurrence_expired_offer')
48414852

48424853
time.sleep(16)
48434854
ret = l1.rpc.fetchinvoice(offer=offer['bolt12'],
48444855
recurrence_counter=1,
48454856
recurrence_label='test_recurrence_expired_offer')
4846-
l1.rpc.pay(ret['invoice'], label='test_recurrence_expired_offer')
4857+
l1.rpc.xpay(ret['invoice'], label='test_recurrence_expired_offer')
48474858

48484859

48494860
def test_fetchinvoice_autoconnect(node_factory, bitcoind):
@@ -4921,7 +4932,8 @@ def test_fetchinvoice_disconnected_reply(node_factory, bitcoind):
49214932
assert l3.rpc.listpeers(l1.info['id']) == {'peers': []}
49224933

49234934

4924-
def test_pay_blockheight_mismatch(node_factory, bitcoind):
4935+
@pytest.mark.parametrize("xpay_handle_pay", [True, False])
4936+
def test_pay_blockheight_mismatch(node_factory, bitcoind, xpay_handle_pay):
49254937
"""Test that we can send a payment even if not caught up with the chain.
49264938
49274939
We removed the requirement for the node to be fully synced up with
@@ -4935,7 +4947,11 @@ def test_pay_blockheight_mismatch(node_factory, bitcoind):
49354947

49364948
send, direct, recv = node_factory.line_graph(3,
49374949
wait_for_announce=True,
4938-
opts={'may_reconnect': True})
4950+
opts={'may_reconnect': True,
4951+
"allow-deprecated-apis":
4952+
True,
4953+
"xpay-handle-pay":
4954+
xpay_handle_pay})
49394955
sync_blockheight(bitcoind, [send, recv])
49404956

49414957
height = bitcoind.rpc.getblockchaininfo()['blocks']
@@ -5611,15 +5627,17 @@ def test_self_sendpay(node_factory):
56115627
l1.rpc.sendpay([], inv['payment_hash'], label='selfpay', bolt11=inv['bolt11'], payment_secret=inv['payment_secret'], amount_msat='100000sat')
56125628

56135629

5614-
def test_strip_lightning_suffix_from_inv(node_factory):
5630+
@pytest.mark.parametrize("xpay_handle_pay", [True, False])
5631+
def test_strip_lightning_suffix_from_inv(node_factory, xpay_handle_pay):
56155632
"""
56165633
Reproducer for [1] that pay an invoice with the `lightning:<bolt11|bolt12>`
56175634
prefix and then, will check if core lightning is able to strip it during
56185635
list `listpays` command.
56195636
56205637
[1] https://github.com/ElementsProject/lightning/issues/6207
56215638
"""
5622-
l1, l2 = node_factory.line_graph(2)
5639+
l1, l2 = node_factory.line_graph(2, opts={"allow-deprecated-apis": True,
5640+
"xpay-handle-pay": xpay_handle_pay})
56235641
inv = l2.rpc.invoice(40, "strip-lightning-prefix", "test to be able to strip the `lightning:` prefix.")["bolt11"]
56245642
wait_for(lambda: only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['state'] == 'CHANNELD_NORMAL')
56255643

tests/test_splice.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def test_script_splice_msat(node_factory, bitcoind, chainparams):
220220
sent_msats = 1111
221221
# purposely pay in msats
222222
inv = l2.rpc.invoice(sent_msats, '1', 'no_1')
223-
l1.rpc.pay(inv['bolt11'])
223+
l1.rpc.xpay(inv['bolt11'])
224224
initial_channel_balance -= sent_msats
225225

226226
l1.rpc.splice(f"wallet -> {withdraw_amt}; {spliceamt} -> *:?", debug_log=True)
@@ -325,7 +325,7 @@ def test_script_splice_msat_roundup(node_factory, bitcoind, chainparams):
325325
sent_msats = 1999
326326
# purposely pay in msats
327327
inv = l2.rpc.invoice(sent_msats, '1', 'no_1')
328-
l1.rpc.pay(inv['bolt11'])
328+
l1.rpc.xpay(inv['bolt11'])
329329
initial_channel_balance -= sent_msats
330330

331331
l1.rpc.splice(f"wallet -> {withdraw_amt}; {spliceamt} -> *:?", debug_log=True)
@@ -432,12 +432,12 @@ def test_script_two_chan_splice_in(node_factory, bitcoind):
432432

433433
# l2 should now have funds on their side to pay l1
434434
inv = l1.rpc.invoice(10000, '1', 'no_1')
435-
l2.rpc.pay(inv['bolt11'])
435+
l2.rpc.xpay(inv['bolt11'])
436436

437437
# l2 spliced extra funds into chan with l3 (but l3 still has 0 on their side)
438438
# Send a payment l2->l3 just to check for channel stability
439439
inv = l3.rpc.invoice(10000, '2', 'no_2')
440-
l2.rpc.pay(inv['bolt11'])
440+
l2.rpc.xpay(inv['bolt11'])
441441

442442

443443
@pytest.mark.openchannel('v1')
@@ -448,7 +448,7 @@ def test_script_two_chan_splice_out(node_factory, bitcoind):
448448

449449
# We need to get funds into l1 -> l2 channel so we can splice it out
450450
inv = l2.rpc.invoice(100000000, '1', 'no_1')
451-
l1.rpc.pay(inv['bolt11'])
451+
l1.rpc.xpay(inv['bolt11'])
452452

453453
chan_id1 = l2.get_channel_id(l1)
454454
chan_id2 = l2.get_channel_id(l3)
@@ -472,10 +472,10 @@ def test_script_two_chan_splice_out(node_factory, bitcoind):
472472

473473
# no extra funds in channels but do some simple payments to test stability
474474
inv = l2.rpc.invoice(10000, '2', 'no_2')
475-
l1.rpc.pay(inv['bolt11'])
475+
l1.rpc.xpay(inv['bolt11'])
476476

477477
inv = l3.rpc.invoice(10000, '3', 'no_3')
478-
l2.rpc.pay(inv['bolt11'])
478+
l2.rpc.xpay(inv['bolt11'])
479479

480480

481481
@pytest.mark.openchannel('v1')
@@ -507,12 +507,12 @@ def test_script_two_chan_splice_inout(node_factory, bitcoind):
507507

508508
# l2 should now have funds on their side to pay l1
509509
inv = l1.rpc.invoice(10000, '2', 'no_2')
510-
l2.rpc.pay(inv['bolt11'])
510+
l2.rpc.xpay(inv['bolt11'])
511511

512512
# l2 spliced extra funds into chan with l3 (but l3 still has 0 on their side)
513513
# Send a payment l2->l3 just to check for channel stability
514514
inv = l3.rpc.invoice(10000, '3', 'no_3')
515-
l2.rpc.pay(inv['bolt11'])
515+
l2.rpc.xpay(inv['bolt11'])
516516

517517

518518
@pytest.mark.openchannel('v1')

0 commit comments

Comments
 (0)