Skip to content

Commit 0adc55e

Browse files
committed
add max timeout
1 parent c279cec commit 0adc55e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

integration_tests/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,14 @@ def wait_for_block(cli, height, timeout=240):
122122
raise TimeoutError(f"wait for block {height} timeout")
123123

124124

125-
def wait_for_new_blocks(cli, n, sleep=0.5):
125+
def wait_for_new_blocks(cli, n, sleep=0.5, timeout=240):
126126
cur_height = begin_height = int(get_sync_info(cli.status())["latest_block_height"])
127+
start_time = time.time()
127128
while cur_height - begin_height < n:
128129
time.sleep(sleep)
129130
cur_height = int(get_sync_info(cli.status())["latest_block_height"])
131+
if time.time() - start_time > timeout:
132+
raise TimeoutError(f"wait for block {begin_height + n} timeout")
130133
return cur_height
131134

132135

0 commit comments

Comments
 (0)