fix: make get_proof integration tests more stable (#1236)
* test: make get_proof integration tests more stable it could fail for error "proof queries at height <= 2 are not supported" if the latest block number <= 2 * Apply suggestions from code review
This commit is contained in:
parent
77ed4aa754
commit
66e8cdbe02
@ -12,6 +12,7 @@ from .utils import (
|
|||||||
deploy_contract,
|
deploy_contract,
|
||||||
send_transaction,
|
send_transaction,
|
||||||
w3_wait_for_new_blocks,
|
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):
|
def test_get_proof(ethermint, geth):
|
||||||
|
wait_for_block(ethermint.cosmos_cli(), 3)
|
||||||
eth_rpc = ethermint.w3.provider
|
eth_rpc = ethermint.w3.provider
|
||||||
geth_rpc = geth.w3.provider
|
geth_rpc = geth.w3.provider
|
||||||
make_same_rpc_calls(
|
make_same_rpc_calls(
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@ -75,6 +76,22 @@ def wait_for_new_blocks(cli, n):
|
|||||||
break
|
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"]):
|
def deploy_contract(w3, jsonfile, args=(), key=KEYS["validator"]):
|
||||||
"""
|
"""
|
||||||
deploy contract and return the deployed contract instance
|
deploy contract and return the deployed contract instance
|
||||||
|
Loading…
Reference in New Issue
Block a user