Wait until everybody has the same tip. sync_blocks needs to be called with an rpc_connections set that has least one node already synced to the latest, stable tip, otherwise there's a chance it might return before all nodes are stably synced.
(rpc_connections, *, wait=1, timeout=60)
| 376 | connect_nodes(nodes[b], a) |
| 377 | |
| 378 | def sync_blocks(rpc_connections, *, wait=1, timeout=60): |
| 379 | """ |
| 380 | Wait until everybody has the same tip. |
| 381 | |
| 382 | sync_blocks needs to be called with an rpc_connections set that has least |
| 383 | one node already synced to the latest, stable tip, otherwise there's a |
| 384 | chance it might return before all nodes are stably synced. |
| 385 | """ |
| 386 | stop_time = time.time() + timeout |
| 387 | while time.time() <= stop_time: |
| 388 | best_hash = [x.getbestblockhash() for x in rpc_connections] |
| 389 | if best_hash.count(best_hash[0]) == len(rpc_connections): |
| 390 | return |
| 391 | time.sleep(wait) |
| 392 | raise AssertionError("Block sync timed out:{}".format("".join("\n {!r}".format(b) for b in best_hash))) |
| 393 | |
| 394 | def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True): |
| 395 | """ |