mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pyln-testing: cleanup of pay() helper function
This commit is contained in:
committed by
Christian Decker
parent
0998164214
commit
e71e44ac8b
@@ -817,24 +817,22 @@ class LightningNode(object):
|
|||||||
if not label:
|
if not label:
|
||||||
label = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
|
label = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
|
||||||
|
|
||||||
|
# check we are connected
|
||||||
|
dst_id = dst.info['id']
|
||||||
|
assert len(self.rpc.listpeers(dst_id).get('peers')) == 1
|
||||||
|
|
||||||
|
# make an invoice
|
||||||
rhash = dst.rpc.invoice(amt, label, label)['payment_hash']
|
rhash = dst.rpc.invoice(amt, label, label)['payment_hash']
|
||||||
invoices = dst.rpc.listinvoices(label)['invoices']
|
invoices = dst.rpc.listinvoices(label)['invoices']
|
||||||
assert len(invoices) == 1 and invoices[0]['status'] == 'unpaid'
|
assert len(invoices) == 1 and invoices[0]['status'] == 'unpaid'
|
||||||
|
|
||||||
routestep = {
|
routestep = {
|
||||||
'msatoshi': amt,
|
'msatoshi': amt,
|
||||||
'id': dst.info['id'],
|
'id': dst_id,
|
||||||
'delay': 5,
|
'delay': 5,
|
||||||
'channel': '1x1x1'
|
'channel': '1x1x1' # note: can be bogus for 1-hop direct payments
|
||||||
}
|
}
|
||||||
|
|
||||||
def wait_pay():
|
|
||||||
# Up to 10 seconds for payment to succeed.
|
|
||||||
start_time = time.time()
|
|
||||||
while dst.rpc.listinvoices(label)['invoices'][0]['status'] != 'paid':
|
|
||||||
if time.time() > start_time + 10:
|
|
||||||
raise TimeoutError('Payment timed out')
|
|
||||||
time.sleep(0.1)
|
|
||||||
# sendpay is async now
|
# sendpay is async now
|
||||||
self.rpc.sendpay([routestep], rhash)
|
self.rpc.sendpay([routestep], rhash)
|
||||||
# wait for sendpay to comply
|
# wait for sendpay to comply
|
||||||
|
|||||||
Reference in New Issue
Block a user