aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2016-11-23 12:58:22 +0100
committerMarcoFalke <falke.marco@gmail.com>2016-11-23 13:01:53 +0100
commit0de7fd36de57a68e543b4c1f184fba192c398c73 (patch)
treeedb6d1e8e10e7e8d7fe6596dd8de7ca761c31b28 /qa/rpc-tests
parente662d281b837c25b2b70525aa8fe8af894339823 (diff)
parent1126c853d9a1a3d2a6a5d85f045e338d78df2296 (diff)
downloadbitcoin-0de7fd36de57a68e543b4c1f184fba192c398c73.tar.xz
Merge #9139: Change sync_blocks to pick smarter maxheight (on top of #9196)
1126c85 [qa] Change sync_blocks to pick smarter maxheight (Russell Yanofsky)
Diffstat (limited to 'qa/rpc-tests')
-rw-r--r--qa/rpc-tests/test_framework/util.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py
index 0b3585c6b2..24a9d434af 100644
--- a/qa/rpc-tests/test_framework/util.py
+++ b/qa/rpc-tests/test_framework/util.py
@@ -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
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()
while cur_time <= start_time + timeout:
tips = [r.waitforblockheight(maxheight, int(wait * 1000)) for r in rpc_connections]
- heights = [t["height"] for t in tips]
- if all(t == tips[0] for t in tips):
- return
- if all(h == heights[0] for h in heights):
+ if all(t["height"] == maxheight for t in tips):
+ if all(t["hash"] == tips[0]["hash"] for t in tips):
+ return
raise AssertionError("Block sync failed, mismatched block hashes:{}".format(
"".join("\n {!r}".format(tip) for tip in tips)))
- maxheight = max(heights)
cur_time = time.time()
raise AssertionError("Block sync to height {} timed out:{}".format(
maxheight, "".join("\n {!r}".format(tip) for tip in tips)))