mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 13:25:43 +01:00
pytest: tighten the query_channel_range test.
Make the two channels adjacent, and specify exactly the number of divide-and-conquer steps there are. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
4c57bf002e
commit
52750f2dcc
@ -562,17 +562,34 @@ def test_gossip_query_channel_range(node_factory, bitcoind):
|
|||||||
l1, l2, l3, l4 = node_factory.line_graph(4, opts={'log-level': 'io'},
|
l1, l2, l3, l4 = node_factory.line_graph(4, opts={'log-level': 'io'},
|
||||||
fundchannel=False)
|
fundchannel=False)
|
||||||
|
|
||||||
# Make public channels.
|
# Make public channels on consecutive blocks
|
||||||
scid12 = l1.fund_channel(l2, 10**5)
|
l1.fundwallet(10**6)
|
||||||
block12 = int(scid12.split('x')[0])
|
l2.fundwallet(10**6)
|
||||||
scid23 = l2.fund_channel(l3, 10**5)
|
|
||||||
block23 = int(scid23.split('x')[0])
|
num_tx = len(bitcoind.rpc.getrawmempool())
|
||||||
|
l1.rpc.fundchannel(l2.info['id'], 10**5)['tx']
|
||||||
|
wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == num_tx + 1)
|
||||||
|
bitcoind.generate_block(1)
|
||||||
|
|
||||||
|
num_tx = len(bitcoind.rpc.getrawmempool())
|
||||||
|
l2.rpc.fundchannel(l3.info['id'], 10**5)['tx']
|
||||||
|
wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == num_tx + 1)
|
||||||
|
bitcoind.generate_block(1)
|
||||||
|
|
||||||
|
# Get them both to gossip depth.
|
||||||
bitcoind.generate_block(5)
|
bitcoind.generate_block(5)
|
||||||
|
|
||||||
# Make sure l2 has received all the gossip.
|
# Make sure l2 has received all the gossip.
|
||||||
l2.daemon.wait_for_logs(['Received node_announcement for node ' + l1.info['id'],
|
l2.daemon.wait_for_logs(['Received node_announcement for node ' + l1.info['id'],
|
||||||
'Received node_announcement for node ' + l3.info['id']])
|
'Received node_announcement for node ' + l3.info['id']])
|
||||||
|
|
||||||
|
scid12 = only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'][0]['short_channel_id']
|
||||||
|
scid23 = only_one(l3.rpc.listpeers(l2.info['id'])['peers'])['channels'][0]['short_channel_id']
|
||||||
|
block12 = int(scid12.split('x')[0])
|
||||||
|
block23 = int(scid23.split('x')[0])
|
||||||
|
|
||||||
|
assert block23 == block12 + 1
|
||||||
|
|
||||||
# l1 asks for all channels, gets both.
|
# l1 asks for all channels, gets both.
|
||||||
ret = l1.rpc.dev_query_channel_range(id=l2.info['id'],
|
ret = l1.rpc.dev_query_channel_range(id=l2.info['id'],
|
||||||
first=0,
|
first=0,
|
||||||
@ -644,6 +661,9 @@ def test_gossip_query_channel_range(node_factory, bitcoind):
|
|||||||
assert ret['final_complete']
|
assert ret['final_complete']
|
||||||
assert len(ret['short_channel_ids']) == 0
|
assert len(ret['short_channel_ids']) == 0
|
||||||
|
|
||||||
|
# Turn on IO logging in l1 channeld.
|
||||||
|
subprocess.run(['kill', '-USR1', l1.subd_pid('channeld')])
|
||||||
|
|
||||||
# Make l2 split reply into two (technically async)
|
# Make l2 split reply into two (technically async)
|
||||||
l2.rpc.dev_set_max_scids_encode_size(max=9)
|
l2.rpc.dev_set_max_scids_encode_size(max=9)
|
||||||
l2.daemon.wait_for_log('Set max_scids_encode_bytes to 9')
|
l2.daemon.wait_for_log('Set max_scids_encode_bytes to 9')
|
||||||
@ -651,6 +671,9 @@ def test_gossip_query_channel_range(node_factory, bitcoind):
|
|||||||
first=0,
|
first=0,
|
||||||
num=1000000)
|
num=1000000)
|
||||||
|
|
||||||
|
# Turns out it sends huge number of empty replies here.
|
||||||
|
l1.daemon.wait_for_logs([r'\[IN\] 0108'] * 21)
|
||||||
|
|
||||||
# It should definitely have split
|
# It should definitely have split
|
||||||
assert ret['final_first_block'] != 0 or ret['final_num_blocks'] != 1000000
|
assert ret['final_first_block'] != 0 or ret['final_num_blocks'] != 1000000
|
||||||
assert ret['final_complete']
|
assert ret['final_complete']
|
||||||
@ -664,9 +687,6 @@ def test_gossip_query_channel_range(node_factory, bitcoind):
|
|||||||
bitcoind.generate_block(5)
|
bitcoind.generate_block(5)
|
||||||
l2.daemon.wait_for_log('Received node_announcement for node ' + l4.info['id'])
|
l2.daemon.wait_for_log('Received node_announcement for node ' + l4.info['id'])
|
||||||
|
|
||||||
# Turn on IO logging in l1 channeld.
|
|
||||||
subprocess.run(['kill', '-USR1', l1.subd_pid('channeld')])
|
|
||||||
|
|
||||||
# Restore infinite encode size.
|
# Restore infinite encode size.
|
||||||
l2.rpc.dev_set_max_scids_encode_size(max=(2**32 - 1))
|
l2.rpc.dev_set_max_scids_encode_size(max=(2**32 - 1))
|
||||||
l2.daemon.wait_for_log('Set max_scids_encode_bytes to {}'
|
l2.daemon.wait_for_log('Set max_scids_encode_bytes to {}'
|
||||||
|
Loading…
Reference in New Issue
Block a user