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:
Rusty Russell 2018-10-09 19:11:52 +10:30
parent aa9e15edb0
commit b3fb23f921
3 changed files with 12 additions and 12 deletions

View file

@ -122,9 +122,6 @@ def test_invoice_routeboost(node_factory):
"""
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
inv = l2.rpc.invoice(msatoshi=123456, label="inv1", description="?")
# Check routeboost.

View file

@ -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')
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"]
# Make sure l2 doesn't tell l1 directly that channel is disabled.

View file

@ -804,15 +804,27 @@ class NodeFactory(object):
# Confirm all channels and wait for them to become usable
bitcoin.generate_block(1)
scids = []
for src, dst in connections:
wait_for(lambda: src.channel_state(dst) == 'CHANNELD_NORMAL')
scid = src.get_channel_scid(dst)
src.daemon.wait_for_log(r'Received channel_update for channel {scid}\(.\) now ACTIVE'.format(scid=scid))
scids.append(scid)
if not announce:
return nodes
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
def killall(self, expected_successes):