pytest: Migrate connection tests to new fixture model

This commit is contained in:
Christian Decker
2018-08-03 17:29:38 +02:00
committed by Rusty Russell
parent 19092a8f1b
commit 58709cf190
3 changed files with 1060 additions and 1010 deletions

1048
tests/test_connection.py Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -372,7 +372,7 @@ class LightningNode(object):
self.may_reconnect = may_reconnect
def openchannel(self, remote_node, capacity, addrtype="p2sh-segwit", confirm=True, announce=True):
addr, wallettxid = self.fundwallet(capacity, addrtype)
addr, wallettxid = self.fundwallet(10 * capacity, addrtype)
fundingtx = self.rpc.fundchannel(remote_node.info['id'], capacity)
# Wait for the funding transaction to be in bitcoind's mempool
@@ -391,7 +391,7 @@ class LightningNode(object):
def fundwallet(self, sats, addrtype="p2sh-segwit"):
addr = self.rpc.newaddr(addrtype)['address']
txid = self.bitcoin.rpc.sendtoaddress(addr, sats / 10**6)
txid = self.bitcoin.rpc.sendtoaddress(addr, sats / 10**8)
self.bitcoin.generate_block(1)
self.daemon.wait_for_log('Owning output .* txid {}'.format(txid))
return addr, txid
@@ -583,6 +583,16 @@ class LightningNode(object):
# wait for sendpay to comply
self.rpc.waitsendpay(rhash)
def fake_bitcoind_fail(self, exitcode):
# Create and rename, for atomicity.
f = os.path.join(self.daemon.lightning_dir, "bitcoin-cli-fail.tmp")
with open(f, "w") as text_file:
text_file.write("%d" % exitcode)
os.rename(f, os.path.join(self.daemon.lightning_dir, "bitcoin-cli-fail"))
def fake_bitcoind_unfail(self):
os.remove(os.path.join(self.daemon.lightning_dir, "bitcoin-cli-fail"))
class NodeFactory(object):
"""A factory to setup and start `lightningd` daemons.