From fcaf83060b5842cb426c1f42f730a676615ad8b3 Mon Sep 17 00:00:00 2001 From: dudong2 Date: Wed, 7 Feb 2024 14:07:47 +0900 Subject: [PATCH] test: debug trace --- tests/integration_tests/test_debug_trace.py | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/integration_tests/test_debug_trace.py b/tests/integration_tests/test_debug_trace.py index d96b055510..19abf66494 100644 --- a/tests/integration_tests/test_debug_trace.py +++ b/tests/integration_tests/test_debug_trace.py @@ -16,6 +16,7 @@ def test_trace_blk(ethermint): sender = acc.address # fund new sender fund = 3000000000000000000 + blk = wait_for_new_blocks(cli, 1, sleep=0.1) tx = {"to": sender, "value": fund, "gasPrice": w3.eth.gas_price} send_transaction(w3, tx) assert w3.eth.get_balance(sender, "latest") == fund @@ -39,13 +40,20 @@ def test_trace_blk(ethermint): res = w3.eth.wait_for_transaction_receipt(txhash) assert res.status == 1 - url = f"http://127.0.0.1:{ports.evmrpc_port(ethermint.base_port(0))}" - params = { - "method": "debug_traceBlockByNumber", - "params": [hex(blk + 1)], - "id": 1, - "jsonrpc": "2.0", - } - rsp = requests.post(url, json=params) - assert rsp.status_code == 200 - assert len(rsp.json()["result"]) == 2 + def trace_blk(blk): + url = f"http://127.0.0.1:{ports.evmrpc_port(ethermint.base_port(0))}" + params = { + "method": "debug_traceBlockByNumber", + "params": [hex(blk + 1)], + "id": 1, + "jsonrpc": "2.0", + } + rsp = requests.post(url, json=params) + assert rsp.status_code == 200 + return rsp.json()["result"] + + total = len(trace_blk(blk)) + expected = 2 + if total < expected: + total += len(trace_blk(blk + 1)) + assert total == expected