From aed5a9cd11c4006b014b872589d573c6f7e39f71 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Wed, 11 Jun 2025 23:09:25 +0200 Subject: [PATCH 1/2] Ensures network local is used if forgotten in e2e tests --- tests/e2e_tests/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/e2e_tests/utils.py b/tests/e2e_tests/utils.py index 07f2fbd93..2917ab59f 100644 --- a/tests/e2e_tests/utils.py +++ b/tests/e2e_tests/utils.py @@ -31,6 +31,19 @@ def exec_command( inputs: list[str] = None, ): extra_args = extra_args or [] + # Ensure if we forget to add `--network ws://127.0.0.1:9945` that it will run still using the local chain + if not any( + ( + x in extra_args + for x in ( + "--network", + "--chain", + "--subtensor.network", + "--subtensor.chain_endpoint", + ) + ) + ): + extra_args.extend(["--network", "ws://127.0.0.1:9945"]) cli_manager = CLIManager() # Capture stderr separately from stdout runner = CliRunner(mix_stderr=False) From df661ba6f6cc7cae69e0ef3cbb9d337836ba5855 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 12 Jun 2025 17:29:49 +0200 Subject: [PATCH 2/2] Ensures only adds network local to commands which utilise that arg. --- tests/e2e_tests/utils.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tests/e2e_tests/utils.py b/tests/e2e_tests/utils.py index 2917ab59f..7a3c0993f 100644 --- a/tests/e2e_tests/utils.py +++ b/tests/e2e_tests/utils.py @@ -1,3 +1,4 @@ +import inspect import os import re import shutil @@ -31,20 +32,28 @@ def exec_command( inputs: list[str] = None, ): extra_args = extra_args or [] - # Ensure if we forget to add `--network ws://127.0.0.1:9945` that it will run still using the local chain - if not any( - ( - x in extra_args - for x in ( - "--network", - "--chain", - "--subtensor.network", - "--subtensor.chain_endpoint", - ) - ) - ): - extra_args.extend(["--network", "ws://127.0.0.1:9945"]) cli_manager = CLIManager() + for group in cli_manager.app.registered_groups: + if group.name == command: + for command_ in group.typer_instance.registered_commands: + if command_.name == sub_command: + if "network" in inspect.getcallargs( + command_.callback + ).keys() and not any( + ( + x in extra_args + for x in ( + "--network", + "--chain", + "--subtensor.network", + "--subtensor.chain_endpoint", + ) + ) + ): + # Ensure if we forget to add `--network ws://127.0.0.1:9945` that it will run still + # using the local chain + extra_args.extend(["--network", "ws://127.0.0.1:9945"]) + # Capture stderr separately from stdout runner = CliRunner(mix_stderr=False) # Prepare the command arguments