Skip to content

Commit

Permalink
build: add script that waits for local-setup to be ready
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelTxFusion committed Jan 10, 2024
1 parent fda3670 commit 8ce986c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions scripts/wait.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import time

import os
import sys


def is_node_ready(w3):
try:
w3.zksync.get_block_number()
return True
except Exception as _:
return False


def wait_for_node():
print("Waiting for node to be ready")
from zksync2.module.module_builder import ZkSyncBuilder

max_attempts = 30
w3 = ZkSyncBuilder.build("http://localhost:3050")

for i in range(max_attempts):
if is_node_ready(w3):
print("Node is ready")
return
time.sleep(20)
raise Exception("Maximum retries exceeded.")


if __name__ == '__main__':
current_directory = os.path.dirname(os.path.abspath(__file__))
parent_directory = os.path.join(current_directory, '..')
sys.path.append(parent_directory)
try:
wait_for_node()
except Exception as e:
print(f"Error: {e}")
sys.path.remove(parent_directory)

0 comments on commit 8ce986c

Please sign in to comment.