Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 581 Lines • ▼ Show 20 Lines | class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): | ||||
def sync_proofs(self, nodes=None, wait=1, timeout=60): | def sync_proofs(self, nodes=None, wait=1, timeout=60): | ||||
""" | """ | ||||
Wait until everybody has the same proofs in their proof pools | Wait until everybody has the same proofs in their proof pools | ||||
""" | """ | ||||
rpc_connections = nodes or self.nodes | rpc_connections = nodes or self.nodes | ||||
timeout = int(timeout * self.options.timeout_factor) | timeout = int(timeout * self.options.timeout_factor) | ||||
stop_time = time.time() + timeout | stop_time = time.time() + timeout | ||||
def format_ids(id_list): | |||||
"""Convert ProodIDs to hex strings for easier debugging""" | |||||
return list(f"{i:064x}" for i in id_list) | |||||
while time.time() <= stop_time: | while time.time() <= stop_time: | ||||
nodes_proofs = [set(get_proof_ids(r)) for r in rpc_connections] | nodes_proofs = [ | ||||
set(format_ids(get_proof_ids(r))) for r in rpc_connections] | |||||
if nodes_proofs.count(nodes_proofs[0]) == len(rpc_connections): | if nodes_proofs.count(nodes_proofs[0]) == len(rpc_connections): | ||||
return | return | ||||
# Check that each peer has at least one connection | # Check that each peer has at least one connection | ||||
assert (all([len(x.getpeerinfo()) for x in rpc_connections])) | assert (all([len(x.getpeerinfo()) for x in rpc_connections])) | ||||
time.sleep(wait) | time.sleep(wait) | ||||
raise AssertionError("Proofs sync timed out after {}s:{}".format( | raise AssertionError("Proofs sync timed out after {}s:{}".format( | ||||
timeout, | timeout, | ||||
"".join("\n {!r}".format(m) for m in nodes_proofs), | "".join("\n {!r}".format(m) for m in nodes_proofs), | ||||
▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines |