diff --git a/tests/e2e_tests/test_commit_reveal_v3.py b/tests/e2e_tests/test_commit_reveal_v3.py index a31063cd47..52d2324c62 100644 --- a/tests/e2e_tests/test_commit_reveal_v3.py +++ b/tests/e2e_tests/test_commit_reveal_v3.py @@ -1,15 +1,12 @@ import re -import time import numpy as np import pytest from bittensor.utils.btlogging import logging -from bittensor.utils.balance import Balance from bittensor.utils.weight_utils import convert_weights_and_uids_for_emit from tests.e2e_tests.utils.chain_interactions import ( sudo_set_admin_utils, sudo_set_hyperparameter_bool, - sudo_set_hyperparameter_values, wait_interval, next_tempo, ) @@ -57,14 +54,16 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle logging.console.info("Commit reveal enabled") # Change the weights rate limit on the subnet - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": "0"}, - return_error_message=True, ) + assert error is None + assert status is True + # Verify weights rate limit was changed assert ( subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0 @@ -81,7 +80,6 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle alice_wallet, call_function="sudo_set_tempo", call_params={"netuid": netuid, "tempo": tempo_set}, - return_error_message=True, )[0] is True ) diff --git a/tests/e2e_tests/test_commit_weights.py b/tests/e2e_tests/test_commit_weights.py index cb6b7fd885..4d966c8c37 100644 --- a/tests/e2e_tests/test_commit_weights.py +++ b/tests/e2e_tests/test_commit_weights.py @@ -7,7 +7,6 @@ from tests.e2e_tests.utils.chain_interactions import ( sudo_set_admin_utils, sudo_set_hyperparameter_bool, - sudo_set_hyperparameter_values, wait_epoch, ) @@ -54,15 +53,18 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa assert ( subtensor.weights_rate_limit(netuid=netuid) > 0 ), "Weights rate limit is below 0" + # Lower the rate limit - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": "0"}, - return_error_message=True, ) + assert error is None + assert status is True + assert ( subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0 ), "Failed to set weights_rate_limit" @@ -77,7 +79,6 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa "netuid": netuid, "tempo": 100, }, - return_error_message=True, ) # Commit-reveal values @@ -192,15 +193,18 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall assert ( subtensor.weights_rate_limit(netuid=netuid) > 0 ), "Weights rate limit is below 0" + # Lower the rate limit - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": "0"}, - return_error_message=True, ) + assert error is None + assert status is True + assert ( subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0 ), "Failed to set weights_rate_limit" diff --git a/tests/e2e_tests/test_delegate.py b/tests/e2e_tests/test_delegate.py index ae9c6b9cac..a5a835a98a 100644 --- a/tests/e2e_tests/test_delegate.py +++ b/tests/e2e_tests/test_delegate.py @@ -320,7 +320,6 @@ def test_nominator_min_required_stake(local_chain, subtensor, alice_wallet, bob_ call_params={ "min_stake": "100000000000000", }, - return_error_message=True, ) minimum_required_stake = subtensor.get_minimum_required_stake() diff --git a/tests/e2e_tests/test_dendrite.py b/tests/e2e_tests/test_dendrite.py index 36a6dfa786..b2e891ff73 100644 --- a/tests/e2e_tests/test_dendrite.py +++ b/tests/e2e_tests/test_dendrite.py @@ -6,7 +6,6 @@ from bittensor.utils.btlogging import logging from tests.e2e_tests.utils.chain_interactions import ( sudo_set_admin_utils, - sudo_set_hyperparameter_values, wait_epoch, ) @@ -44,11 +43,10 @@ async def test_dendrite(local_chain, subtensor, templates, alice_wallet, bob_wal "netuid": netuid, "max_allowed_validators": 1, }, - return_error_message=True, ) # update weights_set_rate_limit for fast-blocks - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", @@ -56,9 +54,11 @@ async def test_dendrite(local_chain, subtensor, templates, alice_wallet, bob_wal "netuid": netuid, "weights_set_rate_limit": 10, }, - return_error_message=True, ) + assert error is None + assert status is True + # Register Bob to the network assert subtensor.burned_register( bob_wallet, netuid diff --git a/tests/e2e_tests/test_hotkeys.py b/tests/e2e_tests/test_hotkeys.py index 19bc0dc718..126690d46c 100644 --- a/tests/e2e_tests/test_hotkeys.py +++ b/tests/e2e_tests/test_hotkeys.py @@ -151,6 +151,8 @@ async def test_children(subtensor, alice_wallet, bob_wallet): assert error == "" assert success is True + subtensor.wait_for_block(subtensor.block + SET_CHILDREN_COOLDOWN_PERIOD) + await wait_epoch(subtensor, netuid=1) success, children, error = subtensor.get_children( diff --git a/tests/e2e_tests/test_incentive.py b/tests/e2e_tests/test_incentive.py index 3511271b11..0467a0cd81 100644 --- a/tests/e2e_tests/test_incentive.py +++ b/tests/e2e_tests/test_incentive.py @@ -3,7 +3,7 @@ import pytest from tests.e2e_tests.utils.chain_interactions import ( - sudo_set_hyperparameter_values, + sudo_set_admin_utils, wait_epoch, ) @@ -66,18 +66,20 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa assert bob_neuron.trust == 0 # update weights_set_rate_limit for fast-blocks - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": 10}, - return_error_message=True, ) + assert error is None + assert status is True + async with templates.miner(bob_wallet, netuid): async with templates.validator(alice_wallet, netuid) as validator: # wait for the Validator to process and set_weights - async with asyncio.timeout(15): + async with asyncio.timeout(60): await validator.set_weights.wait() # Wait few epochs diff --git a/tests/e2e_tests/test_set_weights.py b/tests/e2e_tests/test_set_weights.py index d124238b5f..8a279e3ccf 100644 --- a/tests/e2e_tests/test_set_weights.py +++ b/tests/e2e_tests/test_set_weights.py @@ -5,7 +5,6 @@ from bittensor.utils.weight_utils import convert_weights_and_uids_for_emit from tests.e2e_tests.utils.chain_interactions import ( sudo_set_hyperparameter_bool, - sudo_set_hyperparameter_values, sudo_set_admin_utils, wait_epoch, ) @@ -35,7 +34,6 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet) alice_wallet, call_function="sudo_set_network_rate_limit", call_params={"rate_limit": "0"}, # No limit - return_error_message=True, ) # Set lock reduction interval sudo_set_admin_utils( @@ -43,7 +41,6 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet) alice_wallet, call_function="sudo_set_lock_reduction_interval", call_params={"interval": "1"}, # 1 block # reduce lock every block - return_error_message=True, ) # Try to register the subnets @@ -84,15 +81,18 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet) assert ( subtensor.weights_rate_limit(netuid=netuid) > 0 ), "Weights rate limit is below 0" + # Lower the rate limit - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": "0"}, - return_error_message=True, ) + assert error is None + assert status is True + assert ( subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0 ), "Failed to set weights_rate_limit" diff --git a/tests/e2e_tests/utils/chain_interactions.py b/tests/e2e_tests/utils/chain_interactions.py index b80548041b..3681bf2b46 100644 --- a/tests/e2e_tests/utils/chain_interactions.py +++ b/tests/e2e_tests/utils/chain_interactions.py @@ -150,8 +150,7 @@ def sudo_set_admin_utils( wallet: "Wallet", call_function: str, call_params: dict, - return_error_message: bool = False, -) -> tuple[bool, str]: +) -> tuple[bool, Optional[dict]]: """ Wraps the call in sudo to set hyperparameter values using AdminUtils. @@ -160,10 +159,9 @@ def sudo_set_admin_utils( wallet (Wallet): Wallet object with the keypair for signing. call_function (str): The AdminUtils function to call. call_params (dict): Parameters for the AdminUtils function. - return_error_message (bool): If True, returns the error message along with the success status. Returns: - Union[bool, tuple[bool, Optional[str]]]: Success status or (success status, error message). + tuple[bool, Optional[dict]]: (success status, error details). """ inner_call = substrate.compose_call( call_module="AdminUtils", @@ -185,10 +183,7 @@ def sudo_set_admin_utils( wait_for_finalization=True, ) - if return_error_message: - return response.is_success, response.error_message - - return response.is_success, "" + return response.is_success, response.error_message async def root_set_subtensor_hyperparameter_values(