mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-04 03:03:51 +01:00
pytest: Simplify test_routing_gossip
Settling first and then asserting is longer than just waiting for it to succeed. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
1a45efd0a9
commit
f2b89a9965
1 changed files with 7 additions and 21 deletions
|
@ -2657,22 +2657,6 @@ class LightningDTests(BaseLightningDTests):
|
||||||
# Allow announce messages.
|
# Allow announce messages.
|
||||||
l1.bitcoin.generate_block(5)
|
l1.bitcoin.generate_block(5)
|
||||||
|
|
||||||
def settle_gossip(n):
|
|
||||||
"""Wait for gossip to settle at the node
|
|
||||||
"""
|
|
||||||
expected_connections = 2 * (len(nodes) - 1)
|
|
||||||
start_time = time.time()
|
|
||||||
# Wait at most 10 seconds, broadcast interval is 1 second
|
|
||||||
while time.time() - start_time < utils.TIMEOUT:
|
|
||||||
channels = n.rpc.listchannels()['channels']
|
|
||||||
if len(channels) == expected_connections:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
for n in nodes:
|
|
||||||
settle_gossip(n)
|
|
||||||
|
|
||||||
# Deep check that all channels are in there
|
# Deep check that all channels are in there
|
||||||
comb = []
|
comb = []
|
||||||
for i in range(len(nodes) - 1):
|
for i in range(len(nodes) - 1):
|
||||||
|
@ -2680,11 +2664,13 @@ class LightningDTests(BaseLightningDTests):
|
||||||
comb.append((nodes[i + 1].info['id'], nodes[i].info['id']))
|
comb.append((nodes[i + 1].info['id'], nodes[i].info['id']))
|
||||||
|
|
||||||
for n in nodes:
|
for n in nodes:
|
||||||
seen = []
|
def check_gossip():
|
||||||
channels = n.rpc.listchannels()['channels']
|
seen = []
|
||||||
for c in channels:
|
channels = n.rpc.listchannels()['channels']
|
||||||
seen.append((c['source'], c['destination']))
|
for c in channels:
|
||||||
assert set(seen) == set(comb)
|
seen.append((c['source'], c['destination']))
|
||||||
|
return set(seen) == set(comb)
|
||||||
|
wait_for(check_gossip)
|
||||||
|
|
||||||
@unittest.skipIf(not DEVELOPER, "Too slow without --dev-bitcoind-poll")
|
@unittest.skipIf(not DEVELOPER, "Too slow without --dev-bitcoind-poll")
|
||||||
def test_forward(self):
|
def test_forward(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue