From d5effcb96167c90fc681d0eace6b5bba00b94102 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 7 Feb 2018 11:28:36 +1030 Subject: [PATCH] test_lightning: fix race on testing, esp. test_closing_different_fees. We get intermittant failure: WIRE_UNKNOWN_NEXT_PEER (First peer not ready) because CHANNELD_NORMAL and actually telling gossipd that the channel is available are distinct things: we need both. (For test_closing_different_fees, we were testing CHANNELD_NORMAL on the peer, not on l1, too). But we may also directly send the announcement sigs if the height is sufficient, so the simplest is to unify the messages. Signed-off-by: Rusty Russell --- gossipd/gossip.c | 3 ++- gossipd/routing.c | 5 +++-- tests/test_lightningd.py | 9 ++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 5d2a67b3c..eb4bfba9e 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -809,7 +809,8 @@ static void handle_local_add_channel(struct peer *peer, u8 *msg) c->htlc_minimum_msat = htlc_minimum_msat; c->base_fee = fee_base_msat; c->proportional_fee = fee_proportional_millionths; - status_trace("Channel %s(%d) was updated (LOCAL)", + /* Designed to match msg in handle_channel_update, for easy testing */ + status_trace("Received local update for channel %s(%d) now ACTIVE", type_to_string(msg, struct short_channel_id, &scid), direction); } diff --git a/gossipd/routing.c b/gossipd/routing.c index d9452e9be..36ec09643 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -931,10 +931,11 @@ void handle_channel_update(struct routing_state *rstate, const u8 *update) return; } - status_trace("Received channel_update for channel %s(%d)", + status_trace("Received channel_update for channel %s(%d) now %s", type_to_string(trc, struct short_channel_id, &short_channel_id), - flags & 0x01); + flags & 0x01, + flags & ROUTING_FLAGS_DISABLED ? "DISABLED" : "ACTIVE"); c->last_timestamp = timestamp; c->delay = expiry; diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index b6363ed88..5cacd2870 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -264,8 +264,10 @@ class LightningDTests(BaseLightningDTests): # Technically, this is async to fundchannel. l1.daemon.wait_for_log('sendrawtx exit 0') l1.bitcoin.generate_block(1) - l1.daemon.wait_for_log(' to CHANNELD_NORMAL') - l2.daemon.wait_for_log(' to CHANNELD_NORMAL') + # We wait until gossipd sees local update, as well as status NORMAL, + # so it can definitely route through. + l1.daemon.wait_for_logs(['update for channel .* now ACTIVE', 'to CHANNELD_NORMAL']) + l2.daemon.wait_for_logs(['update for channel .* now ACTIVE', 'to CHANNELD_NORMAL']) # Hacky way to find our output. decoded=bitcoind.rpc.decoderawtransaction(tx) @@ -1036,8 +1038,9 @@ class LightningDTests(BaseLightningDTests): bitcoind.generate_block(6) # Now wait for them all to hit normal state, do payments + l1.daemon.wait_for_logs(['update for channel .* now ACTIVE'] * num_peers + + ['to CHANNELD_NORMAL'] * num_peers) for p in peers: - p.daemon.wait_for_log('to CHANNELD_NORMAL') if p.amount != 0: self.pay(l1,p,100000000)