mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pytest: Migrate connection tests to new fixture model
This commit is contained in:
committed by
Rusty Russell
parent
19092a8f1b
commit
58709cf190
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user