diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 7c9b96a10..d751e06ad 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -4597,7 +4597,9 @@ def sudo_set( "Param name not supplied with `--no-prompt` flag. Cannot continue" ) return False - hyperparam_list = [field.name for field in fields(SubnetHyperparameters)] + hyperparam_list = sorted( + [field.name for field in fields(SubnetHyperparameters)] + ) console.print("Available hyperparameters:\n") for idx, param in enumerate(hyperparam_list, start=1): console.print(f" {idx}. {param}") diff --git a/bittensor_cli/src/commands/sudo.py b/bittensor_cli/src/commands/sudo.py index 88032df89..8004dc90f 100644 --- a/bittensor_cli/src/commands/sudo.py +++ b/bittensor_cli/src/commands/sudo.py @@ -671,7 +671,8 @@ async def get_hyperparameters( dict_out = [] normalized_values = normalize_hyperparameters(subnet, json_output=json_output) - for param, value, norm_value in normalized_values: + sorted_values = sorted(normalized_values, key=lambda x: x[0]) + for param, value, norm_value in sorted_values: if not json_output: table.add_row(" " + param, value, norm_value) else: diff --git a/tests/e2e_tests/test_staking_sudo.py b/tests/e2e_tests/test_staking_sudo.py index 3225b9e6e..8cb5caca4 100644 --- a/tests/e2e_tests/test_staking_sudo.py +++ b/tests/e2e_tests/test_staking_sudo.py @@ -396,20 +396,17 @@ def test_staking(local_chain, wallet_setup): hyperparams = exec_command_alice( command="sudo", sub_command="get", - extra_args=[ - "--chain", - "ws://127.0.0.1:9945", - "--netuid", - netuid, - ], + extra_args=["--chain", "ws://127.0.0.1:9945", "--netuid", netuid, "--json-out"], ) # Parse all hyperparameters and single out max_burn in TAO - all_hyperparams = hyperparams.stdout.splitlines() - max_burn_tao = all_hyperparams[22].split()[2].strip("\u200e") + all_hyperparams = json.loads(hyperparams.stdout) + max_burn_tao = next( + filter(lambda x: x["hyperparameter"] == "max_burn", all_hyperparams) + )["value"] # Assert max_burn is 100 TAO from default - assert Balance.from_tao(float(max_burn_tao)) == Balance.from_tao(100.0) + assert Balance.from_rao(int(max_burn_tao)) == Balance.from_tao(100.0) hyperparams_json = exec_command_alice( command="sudo", @@ -468,7 +465,11 @@ def test_staking(local_chain, wallet_setup): # Parse updated hyperparameters all_updated_hyperparams = updated_hyperparams.stdout.splitlines() - updated_max_burn_tao = all_updated_hyperparams[22].split()[2].strip("\u200e") + updated_max_burn_tao = ( + next(filter(lambda x: x[3:11] == "max_burn", all_updated_hyperparams)) + .split()[2] + .strip("\u200e") + ) # Assert max_burn is now 10 TAO assert Balance.from_tao(float(updated_max_burn_tao)) == Balance.from_tao(10)