mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-18 19:10:11 +00:00
1126c85 [qa] Change sync_blocks to pick smarter maxheight (Russell Yanofsky)
This commit is contained in:
commit
0de7fd36de
@ -129,17 +129,19 @@ def sync_blocks(rpc_connections, *, wait=1, timeout=60):
|
|||||||
one node already synced to the latest, stable tip, otherwise there's a
|
one node already synced to the latest, stable tip, otherwise there's a
|
||||||
chance it might return before all nodes are stably synced.
|
chance it might return before all nodes are stably synced.
|
||||||
"""
|
"""
|
||||||
maxheight = 0
|
# Use getblockcount() instead of waitforblockheight() to determine the
|
||||||
|
# initial max height because the two RPCs look at different internal global
|
||||||
|
# variables (chainActive vs latestBlock) and the former gets updated
|
||||||
|
# earlier.
|
||||||
|
maxheight = max(x.getblockcount() for x in rpc_connections)
|
||||||
start_time = cur_time = time.time()
|
start_time = cur_time = time.time()
|
||||||
while cur_time <= start_time + timeout:
|
while cur_time <= start_time + timeout:
|
||||||
tips = [r.waitforblockheight(maxheight, int(wait * 1000)) for r in rpc_connections]
|
tips = [r.waitforblockheight(maxheight, int(wait * 1000)) for r in rpc_connections]
|
||||||
heights = [t["height"] for t in tips]
|
if all(t["height"] == maxheight for t in tips):
|
||||||
if all(t == tips[0] for t in tips):
|
if all(t["hash"] == tips[0]["hash"] for t in tips):
|
||||||
return
|
return
|
||||||
if all(h == heights[0] for h in heights):
|
|
||||||
raise AssertionError("Block sync failed, mismatched block hashes:{}".format(
|
raise AssertionError("Block sync failed, mismatched block hashes:{}".format(
|
||||||
"".join("\n {!r}".format(tip) for tip in tips)))
|
"".join("\n {!r}".format(tip) for tip in tips)))
|
||||||
maxheight = max(heights)
|
|
||||||
cur_time = time.time()
|
cur_time = time.time()
|
||||||
raise AssertionError("Block sync to height {} timed out:{}".format(
|
raise AssertionError("Block sync to height {} timed out:{}".format(
|
||||||
maxheight, "".join("\n {!r}".format(tip) for tip in tips)))
|
maxheight, "".join("\n {!r}".format(tip) for tip in tips)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user