mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
pytest: fix gossipwith flake harder.
Even though we generally wait until a node has seen the gossip, that doesn't mean that connectd has processed it! This means when we connect it may still send us "old" gossip. So we set the OPT_GOSSIP_QUERIES bit, which means don't send until we ask. But now it sends us WIRE_QUERY_CHANNEL_RANGE, so everyone needs to filter that out. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e120b4afd6
commit
4970704d24
@ -1133,6 +1133,7 @@ class LightningNode(object):
|
||||
timeout=TIMEOUT,
|
||||
stdout=subprocess.PIPE).stdout.strip()
|
||||
out = subprocess.run(['devtools/gossipwith',
|
||||
'--features=40', # OPT_GOSSIP_QUERIES
|
||||
'--timeout-after={}'.format(int(math.sqrt(TIMEOUT) + 1)),
|
||||
'{}@localhost:{}'.format(self.info['id'],
|
||||
self.port),
|
||||
|
@ -278,7 +278,7 @@ def test_gossip_timestamp_filter(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('gossip_timestamp_filter',
|
||||
genesis_blockhash,
|
||||
'0', '0xFFFFFFFF',
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
|
||||
# 0x0100 = channel_announcement
|
||||
# 0x0102 = channel_update
|
||||
@ -291,7 +291,7 @@ def test_gossip_timestamp_filter(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('gossip_timestamp_filter',
|
||||
genesis_blockhash,
|
||||
'0', before_anything - backdate,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
assert msgs == []
|
||||
|
||||
# Now choose range which will only give first update.
|
||||
@ -299,7 +299,7 @@ def test_gossip_timestamp_filter(node_factory, bitcoind, chainparams):
|
||||
genesis_blockhash,
|
||||
before_anything - backdate,
|
||||
after_12 - before_anything + 1,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
|
||||
# 0x0100 = channel_announcement
|
||||
# 0x0102 = channel_update
|
||||
@ -313,7 +313,7 @@ def test_gossip_timestamp_filter(node_factory, bitcoind, chainparams):
|
||||
genesis_blockhash,
|
||||
before_23 - backdate,
|
||||
after_23 - before_23 + 1,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
|
||||
# 0x0100 = channel_announcement
|
||||
# 0x0102 = channel_update
|
||||
@ -633,7 +633,7 @@ def test_gossip_no_empty_announcements(node_factory, bitcoind, chainparams):
|
||||
assert l1.query_gossip('query_channel_range',
|
||||
chainparams['chain_hash'],
|
||||
0, 1000000,
|
||||
filters=['0109', '0012']) == ['0108'
|
||||
filters=['0109', '0107', '0012']) == ['0108'
|
||||
# blockhash
|
||||
+ chainparams['chain_hash']
|
||||
# first_blocknum, number_of_blocks, complete
|
||||
@ -718,7 +718,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
chainparams['chain_hash'],
|
||||
0, 1000000,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
encoded = subprocess.run(['devtools/mkencoded', '--scids', '00', scid12, scid23],
|
||||
check=True,
|
||||
timeout=TIMEOUT,
|
||||
@ -737,7 +737,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
genesis_blockhash,
|
||||
0, block12,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
# reply_channel_range == 264
|
||||
assert msgs == ['0108'
|
||||
# blockhash
|
||||
@ -751,7 +751,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
genesis_blockhash,
|
||||
0, block12 + 1,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
encoded = subprocess.run(['devtools/mkencoded', '--scids', '00', scid12],
|
||||
check=True,
|
||||
timeout=TIMEOUT,
|
||||
@ -770,7 +770,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
genesis_blockhash,
|
||||
0, block23,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
encoded = subprocess.run(['devtools/mkencoded', '--scids', '00', scid12],
|
||||
check=True,
|
||||
timeout=TIMEOUT,
|
||||
@ -789,7 +789,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
genesis_blockhash,
|
||||
block12, block23 - block12 + 1,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
encoded = subprocess.run(['devtools/mkencoded', '--scids', '00', scid12, scid23],
|
||||
check=True,
|
||||
timeout=TIMEOUT,
|
||||
@ -808,7 +808,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
genesis_blockhash,
|
||||
block23, 1,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
encoded = subprocess.run(['devtools/mkencoded', '--scids', '00', scid23],
|
||||
check=True,
|
||||
timeout=TIMEOUT,
|
||||
@ -827,7 +827,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
genesis_blockhash,
|
||||
block23 + 1, 1000000,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
# reply_channel_range == 264
|
||||
assert msgs == ['0108'
|
||||
# blockhash
|
||||
@ -844,7 +844,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
genesis_blockhash,
|
||||
0, 1000000,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
# It should definitely have split
|
||||
l4.daemon.wait_for_log('reply_channel_range: splitting 0-1 of 2')
|
||||
|
||||
@ -869,7 +869,7 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
|
||||
msgs = l4.query_gossip('query_channel_range',
|
||||
genesis_blockhash,
|
||||
1, 429496000,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
assert len(msgs) == 2
|
||||
|
||||
|
||||
@ -938,7 +938,7 @@ def test_query_short_channel_id(node_factory, bitcoind, chainparams):
|
||||
msgs = l1.query_gossip('query_short_channel_ids',
|
||||
chain_hash,
|
||||
encoded,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
|
||||
# Should just get the WIRE_REPLY_SHORT_CHANNEL_IDS_END = 262
|
||||
# (with chainhash and completeflag = 1)
|
||||
@ -961,7 +961,7 @@ def test_query_short_channel_id(node_factory, bitcoind, chainparams):
|
||||
msgs = l1.query_gossip('query_short_channel_ids',
|
||||
chain_hash,
|
||||
encoded,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
|
||||
assert len(msgs) == 6
|
||||
# 0x0100 = channel_announcement
|
||||
@ -981,7 +981,7 @@ def test_query_short_channel_id(node_factory, bitcoind, chainparams):
|
||||
msgs = l1.query_gossip('query_short_channel_ids',
|
||||
chain_hash,
|
||||
encoded,
|
||||
filters=['0109', '0012'])
|
||||
filters=['0109', '0107', '0012'])
|
||||
|
||||
# Technically, this order could be different, but this matches code.
|
||||
assert len(msgs) == 10
|
||||
@ -1255,7 +1255,7 @@ def test_node_reannounce(node_factory, bitcoind, chainparams):
|
||||
# Filter out gossip_timestamp_filter,
|
||||
# channel_announcement and channel_updates.
|
||||
# And pings.
|
||||
filters=['0109', '0102', '0100', '0012'])
|
||||
filters=['0109', '0107', '0102', '0100', '0012'])
|
||||
|
||||
assert len(msgs) == 2
|
||||
assert (bytes("SENIORBEAM", encoding="utf8").hex() in msgs[0]
|
||||
@ -1270,7 +1270,7 @@ def test_node_reannounce(node_factory, bitcoind, chainparams):
|
||||
# Filter out gossip_timestamp_filter,
|
||||
# channel_announcement and channel_updates.
|
||||
# And pings.
|
||||
filters=['0109', '0102', '0100', '0012'])
|
||||
filters=['0109', '0107', '0102', '0100', '0012'])
|
||||
assert msgs == msgs2
|
||||
# Won't have queued up another one, either.
|
||||
assert not l1.daemon.is_in_log('node_announcement: delaying')
|
||||
@ -1295,7 +1295,7 @@ def test_node_reannounce(node_factory, bitcoind, chainparams):
|
||||
# Filter out gossip_timestamp_filter,
|
||||
# channel_announcement and channel_updates.
|
||||
# And pings.
|
||||
filters=['0109', '0102', '0100', '0012'])
|
||||
filters=['0109', '0107', '0102', '0100', '0012'])
|
||||
assert msgs != msgs2
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user