From c110d0b068e500a7ca08a4b425a44c724f0bdc19 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 20 Apr 2022 07:24:04 +0930 Subject: [PATCH] pytest: test that node_announcement regeneration works as expected. We shorten 24 hours to 24 seconds using --dev--fast-gossip-prune. Signed-off-by: Rusty Russell --- gossipd/gossip_generation.c | 10 +++++++++- tests/test_gossip.py | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gossipd/gossip_generation.c b/gossipd/gossip_generation.c index a07a5f5da..04a920777 100644 --- a/gossipd/gossip_generation.c +++ b/gossipd/gossip_generation.c @@ -356,11 +356,19 @@ static void force_self_nannounce_regen(struct daemon *daemon) * 24 hours. */ static void setup_force_nannounce_regen_timer(struct daemon *daemon) { + struct timerel regen_time; + + /* For developers we can force a regen every 24 seconds to test */ + if (IFDEV(daemon->rstate->dev_fast_gossip_prune, false)) + regen_time = time_from_sec(24); + else + regen_time = time_from_sec(24 * 3600); + tal_free(daemon->node_announce_regen_timer); daemon->node_announce_regen_timer = new_reltimer(&daemon->timers, daemon, - time_from_sec(24 * 3600), + regen_time, force_self_nannounce_regen, daemon); } diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 9e6b463ce..e5d76d6af 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -45,6 +45,11 @@ def test_gossip_pruning(node_factory, bitcoind): wait_for(lambda: [c['active'] for c in l2.rpc.listchannels()['channels']] == [True] * 4) wait_for(lambda: [c['active'] for c in l3.rpc.listchannels()['channels']] == [True] * 4) + # Also check that it sends a redundant node_announcement. + ts1 = only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['last_timestamp'] + wait_for(lambda: only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['last_timestamp'] != ts1) + assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['last_timestamp'] >= ts1 + 24 + # All of them should send a keepalive message (after 30 seconds) l1.daemon.wait_for_logs([ 'Sending keepalive channel_update for {}'.format(scid1),