mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
pytest: Replace wait_for_channels with an actual check
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
ba31dd2d9d
commit
202ce5e4ea
@@ -3857,7 +3857,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
assert l2.rpc.listinvoices('inv1')['invoices'][0]['status'] == 'paid'
|
assert l2.rpc.listinvoices('inv1')['invoices'][0]['status'] == 'paid'
|
||||||
|
|
||||||
# FIXME: We should re-add pre-announced routes on startup!
|
# FIXME: We should re-add pre-announced routes on startup!
|
||||||
self.wait_for_routes(l1, [chanid])
|
l1.bitcoin.rpc.generate(5)
|
||||||
|
l1.wait_channel_active(chanid)
|
||||||
|
|
||||||
# A duplicate should succeed immediately (nop) and return correct preimage.
|
# A duplicate should succeed immediately (nop) and return correct preimage.
|
||||||
preimage = l1.rpc.pay(inv1['bolt11'])['payment_preimage']
|
preimage = l1.rpc.pay(inv1['bolt11'])['payment_preimage']
|
||||||
|
|||||||
@@ -459,3 +459,11 @@ class LightningNode(object):
|
|||||||
# Intermittent decoding failure. See if it decodes badly twice?
|
# Intermittent decoding failure. See if it decodes badly twice?
|
||||||
decoded2 = self.bitcoin.rpc.decoderawtransaction(tx)
|
decoded2 = self.bitcoin.rpc.decoderawtransaction(tx)
|
||||||
raise ValueError("Can't find {} payment in {} (1={} 2={})".format(amount, tx, decoded, decoded2))
|
raise ValueError("Can't find {} payment in {} (1={} 2={})".format(amount, tx, decoded, decoded2))
|
||||||
|
|
||||||
|
def is_channel_active(self, chanid):
|
||||||
|
channels = self.rpc.listchannels()['channels']
|
||||||
|
active = [(c['short_channel_id'], c['flags']) for c in channels if c['active']]
|
||||||
|
return (chanid, 0) in active and (chanid, 1) in active
|
||||||
|
|
||||||
|
def wait_channel_active(self, chanid):
|
||||||
|
wait_for(lambda: self.is_channel_active(chanid), interval=1)
|
||||||
|
|||||||
Reference in New Issue
Block a user