From 572aae7f022d5f581e4cbbce7cf5dd611f888eaf Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 23 Oct 2024 10:25:30 +0800 Subject: [PATCH] Problem: test_tx_inclusion is flaky when nodes halt due to different gas_wanted (#1657) * Problem: test_tx_inclusion is flaky when nodes halt due to different gas_wanted wait longer to avoid nodes start with different max_gas_wanted * add max timeout * cleanup --- integration_tests/test_basic.py | 6 +++++- integration_tests/utils.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index 7089b6c9d1..b267746806 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -866,7 +866,12 @@ def fn(cmd): cronos.base_dir / "tasks.ini", lambda cmd: fn(cmd), ) + cli = cronos.cosmos_cli() + # update right after a new block start + wait_for_new_blocks(cli, 1, sleep=0.1) cronos.supervisorctl("update") + # ensure nodes stop and start at the same time + time.sleep(2) wait_for_port(ports.evmrpc_port(cronos.base_port(0))) # reset to origin_cmd only @@ -874,7 +879,6 @@ def fn(cmd): return w3 = cronos.w3 - cli = cronos.cosmos_cli() block_gas_limit = 81500000 tx_gas_limit = 80000000 max_tx_in_block = block_gas_limit // min(max_gas_wanted, tx_gas_limit) diff --git a/integration_tests/utils.py b/integration_tests/utils.py index adbdaa2bf9..c4474d8ce6 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -122,11 +122,14 @@ def wait_for_block(cli, height, timeout=240): raise TimeoutError(f"wait for block {height} timeout") -def wait_for_new_blocks(cli, n, sleep=0.5): +def wait_for_new_blocks(cli, n, sleep=0.5, timeout=240): cur_height = begin_height = int(get_sync_info(cli.status())["latest_block_height"]) + start_time = time.time() while cur_height - begin_height < n: time.sleep(sleep) cur_height = int(get_sync_info(cli.status())["latest_block_height"]) + if time.time() - start_time > timeout: + raise TimeoutError(f"wait for block {begin_height + n} timeout") return cur_height