Browse Source

pytest: Migrate close and onchain tests to test_closing.py

ppa-0.6.1
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
19092a8f1b
  1. 1175
      tests/test_closing.py
  2. 1383
      tests/test_lightningd.py
  3. 35
      tests/utils.py

1175
tests/test_closing.py

File diff suppressed because it is too large

1383
tests/test_lightningd.py

File diff suppressed because it is too large

35
tests/utils.py

@ -1,9 +1,11 @@
import logging
import os
import random
import re
import shutil
import sqlite3
import stat
import string
import subprocess
import threading
import time
@ -64,6 +66,12 @@ def only_one(arr):
return arr[0]
def sync_blockheight(bitcoind, nodes):
height = bitcoind.rpc.getblockchaininfo()['blocks']
for n in nodes:
wait_for(lambda: n.rpc.getinfo()['blockheight'] == height)
class TailableProc(object):
"""A monitorable process that we can start, stop and tail.
@ -548,6 +556,33 @@ class LightningNode(object):
['Received channel_update for channel {}\\(1\\)'.format(c)
for c in channel_ids])
def pay(self, dst, amt, label=None):
if not label:
label = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
rhash = dst.rpc.invoice(amt, label, label)['payment_hash']
invoices = dst.rpc.listinvoices(label)['invoices']
assert len(invoices) == 1 and invoices[0]['status'] == 'unpaid'
routestep = {
'msatoshi': amt,
'id': dst.info['id'],
'delay': 5,
'channel': '1:1:1'
}
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
self.rpc.sendpay([routestep], rhash)
# wait for sendpay to comply
self.rpc.waitsendpay(rhash)
class NodeFactory(object):
"""A factory to setup and start `lightningd` daemons.

Loading…
Cancel
Save