From 8a3abdd5ff3abd49d1e4102c79176d27262c47e9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 8 Oct 2019 11:39:24 +1030 Subject: [PATCH] pytest: fix test_restart_many_payments It sometimes fail with a bad_gossip error because the sending node might not have found out about the channel when it gets a channel_update. Make sure the whole network knows everything before we start. Signed-off-by: Rusty Russell --- tests/test_connection.py | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index 9d3edc4e6..d38c7efab 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1888,7 +1888,7 @@ def test_fulfill_incoming_first(node_factory, bitcoind): @unittest.skipIf(not DEVELOPER, "gossip without DEVELOPER=1 is slow") -def test_restart_many_payments(node_factory): +def test_restart_many_payments(node_factory, bitcoind): l1 = node_factory.get_node(may_reconnect=True) # On my laptop, these take 74 seconds and 44 seconds (with restart commented out) @@ -1911,31 +1911,20 @@ def test_restart_many_payments(node_factory): n.rpc.connect(l1.info['id'], 'localhost', l1.port) outchans.append(l1.fund_channel(n, 10**6, False)) + # Make sure they're all announced. + bitcoind.generate_block(5) + + # We wait for each node to see each dir active, and its own + # channel CHANNELD_NORMAL + logs = ([r'update for channel {}/0 now ACTIVE'.format(scid) + for scid in inchans + outchans] + + [r'update for channel {}/1 now ACTIVE'.format(scid) + for scid in inchans + outchans] + + ['to CHANNELD_NORMAL']) + # Now do all the waiting at once: if !DEVELOPER, this can be *very* slow! - l1_logs = [] - for i in range(len(innodes)): - scid = inchans[i] - l1_logs += [r'update for channel {}/0 now ACTIVE'.format(scid), - r'update for channel {}/1 now ACTIVE'.format(scid), - 'to CHANNELD_NORMAL'] - innodes[i].daemon.wait_for_logs([r'update for channel {}/0 now ACTIVE' - .format(scid), - r'update for channel {}/1 now ACTIVE' - .format(scid), - 'to CHANNELD_NORMAL']) - - for i in range(len(outnodes)): - scid = outchans[i] - l1_logs += [r'update for channel {}/0 now ACTIVE'.format(scid), - r'update for channel {}/1 now ACTIVE'.format(scid), - 'to CHANNELD_NORMAL'] - outnodes[i].daemon.wait_for_logs([r'update for channel {}/0 now ACTIVE' - .format(scid), - r'update for channel {}/1 now ACTIVE' - .format(scid), - 'to CHANNELD_NORMAL']) - - l1.daemon.wait_for_logs(l1_logs) + for n in innodes + outnodes: + n.daemon.wait_for_logs(logs) # Manually create routes, get invoices Payment = namedtuple('Payment', ['innode', 'route', 'payment_hash'])