Could use batch queries to speed things up. On my machine, fetching individually takes ~12s (2 x ~6s), fetching in batch just ~3s (2 x ~1.5s). Is there a reason we need to wait_until check_for_block? Batch approach seems to work fine without it?
<details>
<summary>git diff on 809fffdd6e</summary>
diff --git a/test/functional/feature_index_prune.py b/test/functional/feature_index_prune.py
index af6ef4c14c..e15ca7ac76 100755
--- a/test/functional/feature_index_prune.py
+++ b/test/functional/feature_index_prune.py
@@ -5,13 +5,25 @@
"""Test indices in conjunction with prune."""
import os
from test_framework.authproxy import JSONRPCException
-from test_framework.test_framework import BitcoinTestFramework
+from test_framework.test_framework import BitcoinTestFramework, TestNode
from test_framework.util import (
assert_equal,
assert_greater_than,
assert_raises_rpc_error,
)
+from typing import Dict, List, Any
+
+def send_batch_request(node: TestNode, method: str, params: List[Any]) -> List[Any]:
+ """Send batch request and parse all results"""
+ data = [{"method": method, "params": p} for p in params]
+ response = node.batch(data)
+ result = []
+ for item in response:
+ assert item["error"] is None, item["error"]
+ result.append(item["result"])
+
+ return result
class FeatureIndexPruneTest(BitcoinTestFramework):
def set_test_params(self):
@@ -159,12 +171,9 @@ class FeatureIndexPruneTest(BitcoinTestFramework):
assert_equal(len(peers), 1)
peer_id = peers[0]["id"]
- # 1500 is the height to where the indices were able to sync
- # previously
- for b in range(1500, prune_height):
- bh = node.getblockhash(b)
- node.getblockfrompeer(bh, peer_id)
- self.wait_until(lambda: check_for_block(node=i, hash=bh), timeout=10)
+ # 1500 is the height to where the indices were able to sync previously
+ hashes = send_batch_request(node, "getblockhash", [[a] for a in range(1500, prune_height)])
+ send_batch_request(node, "getblockfrompeer", [[bh, peer_id] for bh in hashes])
# Upon restart we expect the same errors as previously although all
# necessary blocks have been fetched. Both indices need the undo
</details>