Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show First 20 Lines • Show All 440 Lines • ▼ Show 20 Lines | while timeout > 0: | ||||
best_hash = [x.getbestblockhash() for x in rpc_connections] | best_hash = [x.getbestblockhash() for x in rpc_connections] | ||||
if best_hash == [best_hash[0]] * len(best_hash): | if best_hash == [best_hash[0]] * len(best_hash): | ||||
return | return | ||||
time.sleep(wait) | time.sleep(wait) | ||||
timeout -= wait | timeout -= wait | ||||
raise AssertionError("Chain sync failed: Best block hashes don't match") | raise AssertionError("Chain sync failed: Best block hashes don't match") | ||||
def sync_mempools(rpc_connections, *, wait=1, timeout=60): | def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True): | ||||
""" | """ | ||||
Wait until everybody has the same transactions in their memory | Wait until everybody has the same transactions in their memory | ||||
pools | pools | ||||
""" | """ | ||||
while timeout > 0: | while timeout > 0: | ||||
pool = set(rpc_connections[0].getrawmempool()) | pool = set(rpc_connections[0].getrawmempool()) | ||||
num_match = 1 | num_match = 1 | ||||
for i in range(1, len(rpc_connections)): | for i in range(1, len(rpc_connections)): | ||||
if set(rpc_connections[i].getrawmempool()) == pool: | if set(rpc_connections[i].getrawmempool()) == pool: | ||||
num_match = num_match + 1 | num_match = num_match + 1 | ||||
if num_match == len(rpc_connections): | if num_match == len(rpc_connections): | ||||
if flush_scheduler: | |||||
for r in rpc_connections: | |||||
r.syncwithvalidationinterfacequeue() | |||||
return | return | ||||
time.sleep(wait) | time.sleep(wait) | ||||
timeout -= wait | timeout -= wait | ||||
raise AssertionError("Mempool sync failed") | raise AssertionError("Mempool sync failed") | ||||
# Transaction/Block functions | # Transaction/Block functions | ||||
############################# | ############################# | ||||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |