mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
pytest: Stabilize LightningNode.openchannel for multiple channels
When opening a number channels from a single node we could end up not waiting for the funding tx to make it into the mempool, instead triggering on a previous `sendrawtransaction` or `CHANNEL_NORMAL` in the logs. This now checks that the actual funding transaction makes it into the mempool and that we wait for the depth change for that specific channel. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
c550fd1752
commit
27a186be9c
@ -338,12 +338,22 @@ class LightningNode(object):
|
||||
self.may_fail = may_fail
|
||||
self.may_reconnect = may_reconnect
|
||||
|
||||
def openchannel(self, remote_node, capacity, addrtype="p2sh-segwit"):
|
||||
def openchannel(self, remote_node, capacity, addrtype="p2sh-segwit", confirm=True, announce=True):
|
||||
addr, wallettxid = self.fundwallet(capacity, addrtype)
|
||||
fundingtx = self.rpc.fundchannel(remote_node.info['id'], capacity)
|
||||
self.daemon.wait_for_log('sendrawtx exit 0, gave')
|
||||
self.bitcoin.generate_block(6)
|
||||
self.daemon.wait_for_log('to CHANNELD_NORMAL|STATE_NORMAL')
|
||||
|
||||
# Wait for the funding transaction to be in bitcoind's mempool
|
||||
wait_for(lambda: fundingtx['txid'] in self.bitcoin.rpc.getrawmempool())
|
||||
|
||||
if confirm or announce:
|
||||
self.bitcoin.generate_block(1)
|
||||
|
||||
if announce:
|
||||
self.bitcoin.generate_block(5)
|
||||
|
||||
if confirm or announce:
|
||||
self.daemon.wait_for_log(
|
||||
r'Funding tx {} depth'.format(fundingtx['txid']))
|
||||
return {'address': addr, 'wallettxid': wallettxid, 'fundingtx': fundingtx}
|
||||
|
||||
def fundwallet(self, sats, addrtype="p2sh-segwit"):
|
||||
|
Loading…
Reference in New Issue
Block a user