diff --git a/tests/integration_tests/test_types.py b/tests/integration_tests/test_types.py index a9f53b31..0ec8831e 100644 --- a/tests/integration_tests/test_types.py +++ b/tests/integration_tests/test_types.py @@ -12,6 +12,7 @@ from .utils import ( deploy_contract, send_transaction, w3_wait_for_new_blocks, + wait_for_block, ) @@ -177,6 +178,7 @@ def send_and_get_hash(w3, tx_value=10): def test_get_proof(ethermint, geth): + wait_for_block(ethermint.cosmos_cli(), 3) eth_rpc = ethermint.w3.provider geth_rpc = geth.w3.provider make_same_rpc_calls( diff --git a/tests/integration_tests/utils.py b/tests/integration_tests/utils.py index a2ea48a1..9f27f9fa 100644 --- a/tests/integration_tests/utils.py +++ b/tests/integration_tests/utils.py @@ -1,6 +1,7 @@ import json import os import socket +import sys import time from pathlib import Path @@ -75,6 +76,22 @@ def wait_for_new_blocks(cli, n): break +def wait_for_block(cli, height, timeout=240): + for i in range(timeout * 2): + try: + status = cli.status() + except AssertionError as e: + print(f"get sync status failed: {e}", file=sys.stderr) + else: + current_height = int(status["SyncInfo"]["latest_block_height"]) + if current_height >= height: + break + print("current block height", current_height) + time.sleep(0.5) + else: + raise TimeoutError(f"wait for block {height} timeout") + + def deploy_contract(w3, jsonfile, args=(), key=KEYS["validator"]): """ deploy contract and return the deployed contract instance