Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

fix: make get_proof integration tests more stable #1236

Merged
merged 2 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/integration_tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
deploy_contract,
send_transaction,
w3_wait_for_new_blocks,
wait_for_block,
)


Expand Down Expand Up @@ -177,8 +178,10 @@ 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
print(ethermint.w3.eth.block_number, geth.w3.eth.block_number)
yihuang marked this conversation as resolved.
Show resolved Hide resolved
make_same_rpc_calls(
eth_rpc,
geth_rpc,
Expand Down Expand Up @@ -315,6 +318,8 @@ def test_estimate_gas(ethermint, geth):
def make_same_rpc_calls(rpc1, rpc2, method, params):
res1 = rpc1.make_request(method, params)
res2 = rpc2.make_request(method, params)
print("res1", res1)
print("res2", res2)
yihuang marked this conversation as resolved.
Show resolved Hide resolved
res, err = same_types(res1, res2)
assert res, err

Expand Down
17 changes: 17 additions & 0 deletions tests/integration_tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import socket
import sys
import time
from pathlib import Path

Expand Down Expand Up @@ -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
Expand Down