Skip to content

Commit c893ad5

Browse files
committed
pytest: bonus test to make sure xpay uses zeroconf channels correctly.
It needs to use the channel alias here, and it does. Signed-off-by: Rusty Russell <[email protected]>
1 parent c536fa0 commit c893ad5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_xpay.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import subprocess
1212
import sys
1313
from hashlib import sha256
14+
from pathlib import Path
1415
import tempfile
1516
import unittest
1617

@@ -547,3 +548,30 @@ def test_xpay_unannounced(node_factory):
547548
offer = l2.rpc.offer('any')['bolt12']
548549
b12 = l1.rpc.fetchinvoice(offer, '100000msat')['invoice']
549550
l1.rpc.xpay(b12)
551+
552+
553+
def test_xpay_zeroconf(node_factory):
554+
zeroconf_plugin = Path(__file__).parent / "plugins" / "zeroconf-selective.py"
555+
l1, l2 = node_factory.get_nodes(2,
556+
opts=[{},
557+
{'plugin': zeroconf_plugin,
558+
'zeroconf-allow': 'any'}])
559+
560+
l1.fundwallet(FUNDAMOUNT * 2)
561+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
562+
l1.rpc.fundchannel(l2.info['id'], amount=FUNDAMOUNT, announce=False, mindepth=0)
563+
564+
wait_for(lambda: all([c['state'] == 'CHANNELD_NORMAL' for c in l1.rpc.listpeerchannels()['channels'] + l2.rpc.listpeerchannels()['channels']]))
565+
566+
# BOLT 11, direct peer
567+
b11 = l2.rpc.invoice('10000msat', 'test_xpay_unannounced', 'test_xpay_unannounced bolt11')['bolt11']
568+
ret = l1.rpc.xpay(b11)
569+
assert ret['failed_parts'] == 0
570+
assert ret['successful_parts'] == 1
571+
assert ret['amount_msat'] == 10000
572+
assert ret['amount_sent_msat'] == 10000
573+
574+
# BOLT 12, direct peer
575+
offer = l2.rpc.offer('any')['bolt12']
576+
b12 = l1.rpc.fetchinvoice(offer, '100000msat')['invoice']
577+
l1.rpc.xpay(b12)

0 commit comments

Comments
 (0)