Skip to content

Commit dd7855c

Browse files
committed
sync_blocks: check that peer is connected when calling sync_*.
Coming from btc@fac3716b09bb9ee121db629873d9694a95cae942
1 parent bc7d542 commit dd7855c

File tree

1 file changed

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

1 file changed

+4
-0
lines changed

test/functional/test_framework/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ def sync_blocks(rpc_connections, *, wait=1, timeout=60):
385385
best_hash = [x.getbestblockhash() for x in rpc_connections]
386386
if best_hash.count(best_hash[0]) == len(rpc_connections):
387387
return
388+
# Check that each peer has at least one connection
389+
assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
388390
time.sleep(wait)
389391
raise AssertionError("Block sync timed out:{}".format("".join("\n {!r}".format(b) for b in best_hash)))
390392

@@ -401,6 +403,8 @@ def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
401403
# for r in rpc_connections:
402404
# r.syncwithvalidationinterfacequeue()
403405
return
406+
# Check that each peer has at least one connection
407+
assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
404408
time.sleep(wait)
405409
raise AssertionError("Mempool sync timed out:{}".format("".join("\n {!r}".format(m) for m in pool)))
406410

0 commit comments

Comments
 (0)