Skip to content

Commit 1e75a05

Browse files
committed
fix(execute): got broken earlier
1 parent a26f1a4 commit 1e75a05

File tree

9 files changed

+75
-67
lines changed

9 files changed

+75
-67
lines changed

packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/execute.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from execution_testing.rpc import EngineRPC, EthRPC
1616
from execution_testing.specs import BaseTest
1717
from execution_testing.test_types import (
18-
ChainConfigDefaults,
1918
EnvironmentDefaults,
2019
TransactionDefaults,
2120
)
@@ -106,15 +105,6 @@ def pytest_addoption(parser: pytest.Parser) -> None:
106105
"Time to wait after sending a forkchoice_updated before getting the payload."
107106
),
108107
)
109-
execute_group.addoption(
110-
"--chain-id",
111-
action="store",
112-
dest="chain_id",
113-
required=False,
114-
type=int,
115-
default=None,
116-
help="ID of the chain where the tests will be executed.",
117-
)
118108

119109
report_group = parser.getgroup(
120110
"tests", "Arguments defining html report behavior"
@@ -172,22 +162,6 @@ def pytest_configure(config: pytest.Config) -> None:
172162
config.skip_transition_forks = True # type: ignore[attr-defined]
173163
config.single_fork_mode = True # type: ignore[attr-defined]
174164

175-
# Configure the chain ID for the tests.
176-
rpc_chain_id = config.getoption("rpc_chain_id", None)
177-
chain_id = config.getoption("chain_id", None)
178-
if rpc_chain_id is not None or chain_id is not None:
179-
if rpc_chain_id is not None and chain_id is not None:
180-
if chain_id != rpc_chain_id:
181-
pytest.exit(
182-
"Conflicting chain ID configuration. "
183-
"The --rpc-chain-id flag is deprecated and will be removed in a future "
184-
"release. Use --chain-id instead."
185-
)
186-
if rpc_chain_id is not None:
187-
ChainConfigDefaults.chain_id = rpc_chain_id
188-
if chain_id is not None:
189-
ChainConfigDefaults.chain_id = chain_id
190-
191165

192166
def pytest_metadata(metadata: dict[str, Any]) -> None:
193167
"""Add or remove metadata to/from the pytest report."""

packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/rpc/remote.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,6 @@ def pytest_addoption(parser: pytest.Parser) -> None:
2626
dest="rpc_endpoint",
2727
help="RPC endpoint to an execution client",
2828
)
29-
remote_rpc_group.addoption(
30-
"--chain-id",
31-
action="store",
32-
dest="chain_id",
33-
required=False,
34-
type=int,
35-
default=None,
36-
help="ID of the chain where the tests will be executed.",
37-
)
38-
remote_rpc_group.addoption(
39-
"--rpc-chain-id",
40-
action="store",
41-
dest="rpc_chain_id",
42-
required=False,
43-
type=int,
44-
default=None,
45-
help="DEPRECATED: ID of the chain where the tests will be executed. "
46-
"This flag is deprecated and will be removed in a future release."
47-
"Use --chain-id instead.",
48-
)
4929
remote_rpc_group.addoption(
5030
"--tx-wait-timeout",
5131
action="store",
@@ -100,27 +80,6 @@ def pytest_addoption(parser: pytest.Parser) -> None:
10080

10181
def pytest_configure(config: pytest.Config) -> None:
10282
"""Check if a chain ID configuration is provided."""
103-
rpc_chain_id = config.getoption("rpc_chain_id", None)
104-
chain_id = config.getoption("chain_id", None)
105-
106-
if rpc_chain_id is None and chain_id is None:
107-
pytest.exit("No chain ID configuration found. Please use --chain-id.")
108-
109-
# Handle both --chain-id and deprecated --rpc-chain-id
110-
if rpc_chain_id is not None and chain_id is not None:
111-
if chain_id != rpc_chain_id:
112-
pytest.exit(
113-
"Conflicting chain ID configuration. "
114-
"The --rpc-chain-id flag is deprecated and will be removed in a future "
115-
"release. Use --chain-id instead."
116-
)
117-
118-
# Set the chain ID
119-
if chain_id is not None:
120-
ChainConfigDefaults.chain_id = chain_id
121-
elif rpc_chain_id is not None:
122-
ChainConfigDefaults.chain_id = rpc_chain_id
123-
12483
# Verify the chain ID configuration is consistent with the remote RPC endpoint
12584
rpc_endpoint = config.getoption("rpc_endpoint")
12685
eth_rpc = EthRPC(rpc_endpoint)

packages/testing/src/execution_testing/cli/pytest_commands/plugins/help/help.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def pytest_configure(config: pytest.Config) -> None:
112112
"pre-allocation behavior during test execution",
113113
"sender key fixtures",
114114
"remote seed sender",
115+
"chain configuration",
115116
],
116117
)
117118
elif config.getoption("show_execute_hive_help"):
@@ -124,6 +125,7 @@ def pytest_configure(config: pytest.Config) -> None:
124125
"pre-allocation behavior during test execution",
125126
"sender key fixtures",
126127
"remote seed sender",
128+
"chain configuration",
127129
],
128130
)
129131
elif config.getoption("show_execute_recover_help"):
@@ -134,6 +136,7 @@ def pytest_configure(config: pytest.Config) -> None:
134136
"fund recovery",
135137
"remote RPC configuration",
136138
"remote seed sender",
139+
"chain configuration",
137140
],
138141
)
139142
elif config.getoption("show_execute_eth_config_help"):
@@ -142,6 +145,7 @@ def pytest_configure(config: pytest.Config) -> None:
142145
"pytest-execute-eth-config.ini",
143146
[
144147
"eth_config",
148+
"chain configuration",
145149
],
146150
)
147151

packages/testing/src/execution_testing/cli/pytest_commands/pytest_ini_files/pytest-execute-eth-config.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ minversion = 7.0
44
python_files = *.py
55
# Note: register new markers via src/execution_testing/cli/pytest_commands/plugins/shared/execute_fill.py
66
addopts =
7+
-p execution_testing.cli.pytest_commands.plugins.execute.execute_flags.execute_flags
78
-p execution_testing.cli.pytest_commands.plugins.execute.eth_config.eth_config
89
-p execution_testing.cli.pytest_commands.plugins.help.help
910
-p execution_testing.cli.pytest_commands.plugins.custom_logging.plugin_logging

packages/testing/src/execution_testing/cli/pytest_commands/pytest_ini_files/pytest-execute-hive.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ python_files = test_*.py
55
testpaths = tests/
66
# Note: register new markers via src/execution_testing/cli/pytest_commands/plugins/shared/execute_fill.py
77
addopts =
8+
-p execution_testing.cli.pytest_commands.plugins.execute.execute_flags.execute_flags
89
-p execution_testing.cli.pytest_commands.plugins.concurrency
910
-p execution_testing.cli.pytest_commands.plugins.execute.sender
1011
-p execution_testing.cli.pytest_commands.plugins.execute.pre_alloc

packages/testing/src/execution_testing/cli/pytest_commands/pytest_ini_files/pytest-execute-recover.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ console_output_style = count
33
minversion = 7.0
44
python_files = *.py
55
addopts =
6+
-p execution_testing.cli.pytest_commands.plugins.execute.execute_flags.execute_flags
67
-p execution_testing.cli.pytest_commands.plugins.execute.rpc.remote
78
-p execution_testing.cli.pytest_commands.plugins.execute.recover
89
-p execution_testing.cli.pytest_commands.plugins.help.help

packages/testing/src/execution_testing/cli/pytest_commands/pytest_ini_files/pytest-execute.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ python_files = test_*.py
55
testpaths = tests/
66
# Note: register new markers via src/execution_testing/cli/pytest_commands/plugins/shared/execute_fill.py
77
addopts =
8+
-p execution_testing.cli.pytest_commands.plugins.execute.execute_flags.execute_flags
89
-p execution_testing.cli.pytest_commands.plugins.concurrency
910
-p execution_testing.cli.pytest_commands.plugins.execute.sender
1011
-p execution_testing.cli.pytest_commands.plugins.execute.pre_alloc

packages/testing/src/execution_testing/cli/tests/test_pytest_execute_command.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,69 @@ def test_execute_subcommands_have_help_text() -> None:
4141

4242
assert recover.__doc__ is not None
4343
assert "recover" in recover.__doc__.lower()
44+
45+
46+
def test_execute_main_help(runner: CliRunner) -> None:
47+
"""Test that execute --help works without errors."""
48+
result = runner.invoke(execute, ["--help"])
49+
assert result.exit_code == 0
50+
assert "Execute command to run tests" in result.output
51+
52+
53+
def test_execute_remote_help(runner: CliRunner) -> None:
54+
"""Test that execute remote --help works without argument conflicts."""
55+
result = runner.invoke(execute, ["remote", "--help"])
56+
assert result.exit_code == 0
57+
assert "After displaying help" in result.output
58+
# Verify no argparse conflicts with --chain-id
59+
assert "conflicting option string" not in result.output
60+
61+
62+
def test_execute_recover_help(runner: CliRunner) -> None:
63+
"""Test that execute recover --help works without argument conflicts."""
64+
result = runner.invoke(execute, ["recover", "--help"])
65+
assert result.exit_code == 0
66+
assert "After displaying help" in result.output
67+
# Verify --chain-id is available
68+
assert "--chain-id" in result.output
69+
# Verify no argparse conflicts
70+
assert "conflicting option string" not in result.output
71+
72+
73+
def test_execute_hive_help(runner: CliRunner) -> None:
74+
"""Test that execute hive --help works without errors."""
75+
result = runner.invoke(execute, ["hive", "--help"])
76+
assert result.exit_code == 0
77+
assert "After displaying help" in result.output
78+
79+
80+
def test_execute_eth_config_help(runner: CliRunner) -> None:
81+
"""Test that execute eth-config --help works without errors."""
82+
result = runner.invoke(execute, ["eth-config", "--help"])
83+
assert result.exit_code == 0
84+
assert "After displaying help" in result.output
85+
86+
87+
def test_all_execute_subcommands_help_no_conflicts(runner: CliRunner) -> None:
88+
"""Test that all execute subcommands --help work without argument conflicts.
89+
90+
This is a regression test for issue where --chain-id was defined in multiple
91+
plugins, causing argparse.ArgumentError conflicts.
92+
"""
93+
subcommands = ["remote", "recover", "hive", "eth-config"]
94+
95+
for subcommand in subcommands:
96+
result = runner.invoke(execute, [subcommand, "--help"])
97+
assert result.exit_code == 0, (
98+
f"execute {subcommand} --help failed with exit code {result.exit_code}\n"
99+
f"Output: {result.output}"
100+
)
101+
# Ensure no argparse conflicts
102+
assert "ArgumentError" not in result.output, (
103+
f"execute {subcommand} --help has ArgumentError\n"
104+
f"Output: {result.output}"
105+
)
106+
assert "conflicting option string" not in result.output, (
107+
f"execute {subcommand} --help has conflicting option string\n"
108+
f"Output: {result.output}"
109+
)

packages/testing/src/execution_testing/test_types/chain_config_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ChainConfigDefaults:
1414
"""
1515

1616
chain_id: int = 1
17+
rpc_chain_id: int = 1
1718

1819

1920
class ChainConfig(CamelModel):

0 commit comments

Comments
 (0)