mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
pytest: make line_graph wait for gossip propagation if announce param is True
This is what the callers want; generalize it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -122,9 +122,6 @@ def test_invoice_routeboost(node_factory):
|
|||||||
"""
|
"""
|
||||||
l1, l2 = node_factory.line_graph(2, announce=True, fundamount=10**4)
|
l1, l2 = node_factory.line_graph(2, announce=True, fundamount=10**4)
|
||||||
|
|
||||||
# Make sure we've seen channel_update from peer.
|
|
||||||
wait_for(lambda: [a['active'] for a in l2.rpc.listchannels()['channels']] == [True, True])
|
|
||||||
|
|
||||||
# Make invoice and pay it
|
# Make invoice and pay it
|
||||||
inv = l2.rpc.invoice(msatoshi=123456, label="inv1", description="?")
|
inv = l2.rpc.invoice(msatoshi=123456, label="inv1", description="?")
|
||||||
# Check routeboost.
|
# Check routeboost.
|
||||||
|
|||||||
@@ -133,15 +133,6 @@ def test_pay_get_error_with_update(node_factory):
|
|||||||
|
|
||||||
inv = l3.rpc.invoice(123000, 'test_pay_get_error_with_update', 'description')
|
inv = l3.rpc.invoice(123000, 'test_pay_get_error_with_update', 'description')
|
||||||
|
|
||||||
def try_route(src, dst):
|
|
||||||
try:
|
|
||||||
src.rpc.getroute(dst.info['id'], 1, 1)
|
|
||||||
return True
|
|
||||||
except Exception:
|
|
||||||
return False
|
|
||||||
|
|
||||||
wait_for(lambda: try_route(l1, l3))
|
|
||||||
|
|
||||||
route = l1.rpc.getroute(l3.info['id'], 12300, 1)["route"]
|
route = l1.rpc.getroute(l3.info['id'], 12300, 1)["route"]
|
||||||
|
|
||||||
# Make sure l2 doesn't tell l1 directly that channel is disabled.
|
# Make sure l2 doesn't tell l1 directly that channel is disabled.
|
||||||
|
|||||||
@@ -804,15 +804,27 @@ class NodeFactory(object):
|
|||||||
|
|
||||||
# Confirm all channels and wait for them to become usable
|
# Confirm all channels and wait for them to become usable
|
||||||
bitcoin.generate_block(1)
|
bitcoin.generate_block(1)
|
||||||
|
scids = []
|
||||||
for src, dst in connections:
|
for src, dst in connections:
|
||||||
wait_for(lambda: src.channel_state(dst) == 'CHANNELD_NORMAL')
|
wait_for(lambda: src.channel_state(dst) == 'CHANNELD_NORMAL')
|
||||||
scid = src.get_channel_scid(dst)
|
scid = src.get_channel_scid(dst)
|
||||||
src.daemon.wait_for_log(r'Received channel_update for channel {scid}\(.\) now ACTIVE'.format(scid=scid))
|
src.daemon.wait_for_log(r'Received channel_update for channel {scid}\(.\) now ACTIVE'.format(scid=scid))
|
||||||
|
scids.append(scid)
|
||||||
|
|
||||||
if not announce:
|
if not announce:
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
bitcoin.generate_block(5)
|
bitcoin.generate_block(5)
|
||||||
|
|
||||||
|
def both_dirs_ready(n, scid):
|
||||||
|
resp = n.rpc.listchannels(scid)
|
||||||
|
return [a['active'] for a in resp['channels']] == [True, True]
|
||||||
|
|
||||||
|
# Make sure everyone sees all channels: we can cheat and
|
||||||
|
# simply check the ends (since it's a line).
|
||||||
|
wait_for(lambda: both_dirs_ready(nodes[0], scids[-1]))
|
||||||
|
wait_for(lambda: both_dirs_ready(nodes[-1], scids[0]))
|
||||||
|
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
def killall(self, expected_successes):
|
def killall(self, expected_successes):
|
||||||
|
|||||||
Reference in New Issue
Block a user