fix(rpc): get_proof test fail because block numbers are not high enough (#1239)

* Problem: get_proof test fail because block numbers are not high enough

Solution:
- wait for app block height rather than tendermint block height

* Update tests/integration_tests/test_types.py

* keep get_proof response the same as geth

Co-authored-by: Daniel Burckhardt <daniel.m.burckhardt@gmail.com>
This commit is contained in:
yihuang
2022-08-12 13:20:17 +02:00
committed by GitHub
co-authored by Daniel Burckhardt
parent 989192028f
commit 94cab52ca1
3 changed files with 22 additions and 6 deletions
+5 -3
View File
@@ -11,8 +11,8 @@ from .utils import (
KEYS,
deploy_contract,
send_transaction,
w3_wait_for_block,
w3_wait_for_new_blocks,
wait_for_block,
)
@@ -178,7 +178,9 @@ def send_and_get_hash(w3, tx_value=10):
def test_get_proof(ethermint, geth):
wait_for_block(ethermint.cosmos_cli(), 3)
# on ethermint the proof query will fail for block numbers <= 2
# so we must wait for several blocks
w3_wait_for_block(ethermint.w3, 3)
eth_rpc = ethermint.w3.provider
geth_rpc = geth.w3.provider
make_same_rpc_calls(
@@ -192,7 +194,7 @@ def test_get_proof(ethermint, geth):
eth_rpc,
geth_rpc,
"eth_getProof",
["0x57f96e6b86cdefdb3d412547816a82e3e0ebf9d2", ["0x0"], "0x32"],
["0x57f96e6b86cdefdb3d412547816a82e3e0ebf9d2", ["0x0"], "0x1024"],
)
_ = send_and_get_hash(ethermint.w3)
+15
View File
@@ -92,6 +92,21 @@ def wait_for_block(cli, height, timeout=240):
raise TimeoutError(f"wait for block {height} timeout")
def w3_wait_for_block(w3, height, timeout=240):
for i in range(timeout * 2):
try:
current_height = w3.eth.block_number
except Exception as e:
print(f"get json-rpc block number failed: {e}", file=sys.stderr)
else:
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