Skip to content

Commit d2db252

Browse files
author
MarcoFalke
committed
Merge #18474: test: check that peer is connected when calling sync_*
fac3716 test: check that peer is connected when calling sync_* (MarcoFalke) Pull request description: Without a connection there is no way to sync, so we can fail early and don't have to wait for the timeout ACKs for top commit: jonatack: ACK fac3716 Tree-SHA512: 12f771473c23e152dae4bfb201fadb2c3530cf439de64fea07d048734614543080a5d05c9c36e6e398c6a69c8279f609d34706599571814172a11bcfbea4a3b9
2 parents 72ef366 + fac3716 commit d2db252

File tree

1 file changed

+6
-0
lines changed
  • test/functional/test_framework

1 file changed

+6
-0
lines changed

test/functional/test_framework/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ def connect_nodes(from_connection, node_num):
393393
# with transaction relaying
394394
wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
395395

396+
396397
def sync_blocks(rpc_connections, *, wait=1, timeout=60):
397398
"""
398399
Wait until everybody has the same tip.
@@ -406,9 +407,12 @@ def sync_blocks(rpc_connections, *, wait=1, timeout=60):
406407
best_hash = [x.getbestblockhash() for x in rpc_connections]
407408
if best_hash.count(best_hash[0]) == len(rpc_connections):
408409
return
410+
# Check that each peer has at least one connection
411+
assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
409412
time.sleep(wait)
410413
raise AssertionError("Block sync timed out:{}".format("".join("\n {!r}".format(b) for b in best_hash)))
411414

415+
412416
def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
413417
"""
414418
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):
422426
for r in rpc_connections:
423427
r.syncwithvalidationinterfacequeue()
424428
return
429+
# Check that each peer has at least one connection
430+
assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
425431
time.sleep(wait)
426432
raise AssertionError("Mempool sync timed out:{}".format("".join("\n {!r}".format(m) for m in pool)))
427433

0 commit comments

Comments
 (0)