mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 16:14:23 +01:00
tests: flake fix; l1 was waiting too long to reconnect
We were waiting too long for the reconnect to happen (60s default), which caused this test to timeout. When testing, let's speed up the reconnect. L2 tried to reconnect but didn't have connection information in its gossip -- is there a way to ask/save connection data from a node you're making a channel with that doesn't rely on their node_announcement?
This commit is contained in:
@@ -364,8 +364,10 @@ static void connect_failed(struct lightningd *ld,
|
|||||||
u32 delay;
|
u32 delay;
|
||||||
if (seconds_to_delay)
|
if (seconds_to_delay)
|
||||||
delay = *seconds_to_delay;
|
delay = *seconds_to_delay;
|
||||||
|
else if (peer->delay_reconnect)
|
||||||
|
delay = DEV_FAST_RECONNECT(ld->dev_fast_reconnect, 3, 60);
|
||||||
else
|
else
|
||||||
delay = peer->delay_reconnect ? 60 : 1;
|
delay = 1;
|
||||||
log_peer_debug(ld->log, id, "Reconnecting in %u seconds", delay);
|
log_peer_debug(ld->log, id, "Reconnecting in %u seconds", delay);
|
||||||
try_reconnect(peer, peer, delay, addrhint);
|
try_reconnect(peer, peer, delay, addrhint);
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -3,12 +3,17 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
|
#include <common/utils.h>
|
||||||
|
|
||||||
struct lightningd;
|
struct lightningd;
|
||||||
struct peer;
|
struct peer;
|
||||||
struct pubkey;
|
struct pubkey;
|
||||||
struct wireaddr_internal;
|
struct wireaddr_internal;
|
||||||
|
|
||||||
|
/* Speedy reconnect timeout! */
|
||||||
|
#define DEV_FAST_RECONNECT(dev_fast_reconnect_flag, fast, normal) \
|
||||||
|
IFDEV((dev_fast_reconnect_flag) ? (fast) : (normal), (normal))
|
||||||
|
|
||||||
/* Returns fd for gossipd to talk to connectd */
|
/* Returns fd for gossipd to talk to connectd */
|
||||||
int connectd_init(struct lightningd *ld);
|
int connectd_init(struct lightningd *ld);
|
||||||
void connectd_activate(struct lightningd *ld);
|
void connectd_activate(struct lightningd *ld);
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
|||||||
ld->dev_gossip_time = 0;
|
ld->dev_gossip_time = 0;
|
||||||
ld->dev_fast_gossip = false;
|
ld->dev_fast_gossip = false;
|
||||||
ld->dev_fast_gossip_prune = false;
|
ld->dev_fast_gossip_prune = false;
|
||||||
|
ld->dev_fast_reconnect = false;
|
||||||
ld->dev_force_privkey = NULL;
|
ld->dev_force_privkey = NULL;
|
||||||
ld->dev_force_bip32_seed = NULL;
|
ld->dev_force_bip32_seed = NULL;
|
||||||
ld->dev_force_channel_secrets = NULL;
|
ld->dev_force_channel_secrets = NULL;
|
||||||
|
|||||||
@@ -244,6 +244,9 @@ struct lightningd {
|
|||||||
bool dev_fast_gossip;
|
bool dev_fast_gossip;
|
||||||
bool dev_fast_gossip_prune;
|
bool dev_fast_gossip_prune;
|
||||||
|
|
||||||
|
/* Speedup reconnect delay, for testing. */
|
||||||
|
bool dev_fast_reconnect;
|
||||||
|
|
||||||
/* This is the forced private key for the node. */
|
/* This is the forced private key for the node. */
|
||||||
struct privkey *dev_force_privkey;
|
struct privkey *dev_force_privkey;
|
||||||
|
|
||||||
|
|||||||
@@ -691,6 +691,10 @@ static void dev_register_opts(struct lightningd *ld)
|
|||||||
opt_register_noarg("--dev-no-reconnect", opt_set_invbool,
|
opt_register_noarg("--dev-no-reconnect", opt_set_invbool,
|
||||||
&ld->reconnect,
|
&ld->reconnect,
|
||||||
"Disable automatic reconnect-attempts by this node, but accept incoming");
|
"Disable automatic reconnect-attempts by this node, but accept incoming");
|
||||||
|
opt_register_noarg("--dev-fast-reconnect", opt_set_bool,
|
||||||
|
&ld->dev_fast_reconnect,
|
||||||
|
"Make default reconnect delay 3 (not 60) seconds");
|
||||||
|
|
||||||
opt_register_noarg("--dev-fail-on-subdaemon-fail", opt_set_bool,
|
opt_register_noarg("--dev-fail-on-subdaemon-fail", opt_set_bool,
|
||||||
&ld->dev_subdaemon_fail, opt_hidden);
|
&ld->dev_subdaemon_fail, opt_hidden);
|
||||||
opt_register_arg("--dev-disconnect=<filename>", opt_subd_dev_disconnect,
|
opt_register_arg("--dev-disconnect=<filename>", opt_subd_dev_disconnect,
|
||||||
|
|||||||
@@ -1132,7 +1132,7 @@ def test_funding_reorg_private(node_factory, bitcoind):
|
|||||||
l2.daemon.wait_for_log(r'Deleting channel')
|
l2.daemon.wait_for_log(r'Deleting channel')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.developer("needs DEVELOPER=1")
|
@pytest.mark.developer("needs DEVELOPER=1", "uses --dev-fast-reconnect")
|
||||||
@pytest.mark.openchannel('v1')
|
@pytest.mark.openchannel('v1')
|
||||||
@pytest.mark.openchannel('v2')
|
@pytest.mark.openchannel('v2')
|
||||||
def test_funding_reorg_remote_lags(node_factory, bitcoind):
|
def test_funding_reorg_remote_lags(node_factory, bitcoind):
|
||||||
@@ -1140,7 +1140,7 @@ def test_funding_reorg_remote_lags(node_factory, bitcoind):
|
|||||||
"""
|
"""
|
||||||
# may_reconnect so channeld will restart; bad gossip can happen due to reorg
|
# may_reconnect so channeld will restart; bad gossip can happen due to reorg
|
||||||
opts = {'funding-confirms': 1, 'may_reconnect': True, 'allow_bad_gossip': True,
|
opts = {'funding-confirms': 1, 'may_reconnect': True, 'allow_bad_gossip': True,
|
||||||
'allow_warning': True}
|
'allow_warning': True, 'dev-fast-reconnect': None}
|
||||||
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
|
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
|
||||||
l1.fundwallet(10000000)
|
l1.fundwallet(10000000)
|
||||||
sync_blockheight(bitcoind, [l1]) # height 102
|
sync_blockheight(bitcoind, [l1]) # height 102
|
||||||
|
|||||||
Reference in New Issue
Block a user