mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-14 12:10:42 +02:00
test: check that peer is connected when calling sync_*
This commit is contained in:
parent
7e1fc03b18
commit
fac3716b09
@ -393,6 +393,7 @@ def connect_nodes(from_connection, node_num):
|
|||||||
# with transaction relaying
|
# with transaction relaying
|
||||||
wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
|
wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
|
||||||
|
|
||||||
|
|
||||||
def sync_blocks(rpc_connections, *, wait=1, timeout=60):
|
def sync_blocks(rpc_connections, *, wait=1, timeout=60):
|
||||||
"""
|
"""
|
||||||
Wait until everybody has the same tip.
|
Wait until everybody has the same tip.
|
||||||
@ -406,9 +407,12 @@ def sync_blocks(rpc_connections, *, wait=1, timeout=60):
|
|||||||
best_hash = [x.getbestblockhash() for x in rpc_connections]
|
best_hash = [x.getbestblockhash() for x in rpc_connections]
|
||||||
if best_hash.count(best_hash[0]) == len(rpc_connections):
|
if best_hash.count(best_hash[0]) == len(rpc_connections):
|
||||||
return
|
return
|
||||||
|
# Check that each peer has at least one connection
|
||||||
|
assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
|
||||||
time.sleep(wait)
|
time.sleep(wait)
|
||||||
raise AssertionError("Block sync timed out:{}".format("".join("\n {!r}".format(b) for b in best_hash)))
|
raise AssertionError("Block sync timed out:{}".format("".join("\n {!r}".format(b) for b in best_hash)))
|
||||||
|
|
||||||
|
|
||||||
def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
|
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
|
||||||
@ -422,6 +426,8 @@ def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
|
|||||||
for r in rpc_connections:
|
for r in rpc_connections:
|
||||||
r.syncwithvalidationinterfacequeue()
|
r.syncwithvalidationinterfacequeue()
|
||||||
return
|
return
|
||||||
|
# Check that each peer has at least one connection
|
||||||
|
assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
|
||||||
time.sleep(wait)
|
time.sleep(wait)
|
||||||
raise AssertionError("Mempool sync timed out:{}".format("".join("\n {!r}".format(m) for m in pool)))
|
raise AssertionError("Mempool sync timed out:{}".format("".join("\n {!r}".format(m) for m in pool)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user