diff --git a/tests/e2e_tests/test_commitment.py b/tests/e2e_tests/test_commitment.py index 66319c01d0..0df20688ea 100644 --- a/tests/e2e_tests/test_commitment.py +++ b/tests/e2e_tests/test_commitment.py @@ -1,12 +1,13 @@ import pytest +from async_substrate_interface.errors import SubstrateRequestException from bittensor import logging -from async_substrate_interface.errors import SubstrateRequestException +from tests.e2e_tests.utils.chain_interactions import sudo_set_admin_utils logging.set_trace() -def test_commitment(subtensor, alice_wallet): +def test_commitment(local_chain, subtensor, alice_wallet): with pytest.raises(SubstrateRequestException, match="AccountNotAllowedCommit"): subtensor.set_commitment( alice_wallet, @@ -37,14 +38,27 @@ def test_commitment(subtensor, alice_wallet): data="Hello World!", ) + status, error = sudo_set_admin_utils( + local_chain, + alice_wallet, + call_module="Commitments", + call_function="set_max_space", + call_params={ + "netuid": 1, + "new_limit": len("Hello World!"), + }, + ) + + assert status is True, error + with pytest.raises( SubstrateRequestException, - match="CommitmentSetRateLimitExceeded", + match="SpaceLimitExceeded", ): subtensor.set_commitment( alice_wallet, netuid=1, - data="Hello World!", + data="Hello World!1", ) assert "Hello World!" == subtensor.get_commitment( @@ -59,7 +73,7 @@ def test_commitment(subtensor, alice_wallet): @pytest.mark.asyncio -async def test_commitment_async(async_subtensor, alice_wallet): +async def test_commitment_async(local_chain, async_subtensor, alice_wallet): async with async_subtensor as sub: with pytest.raises(SubstrateRequestException, match="AccountNotAllowedCommit"): await sub.set_commitment( @@ -91,14 +105,27 @@ async def test_commitment_async(async_subtensor, alice_wallet): data="Hello World!", ) + status, error = sudo_set_admin_utils( + local_chain, + alice_wallet, + call_module="Commitments", + call_function="set_max_space", + call_params={ + "netuid": 1, + "new_limit": len("Hello World!"), + }, + ) + + assert status is True, error + with pytest.raises( SubstrateRequestException, - match="CommitmentSetRateLimitExceeded", + match="SpaceLimitExceeded", ): await sub.set_commitment( alice_wallet, netuid=1, - data="Hello World!", + data="Hello World!1", ) assert "Hello World!" == await sub.get_commitment( diff --git a/tests/e2e_tests/test_incentive.py b/tests/e2e_tests/test_incentive.py index bb5e3749ec..56f23ddd52 100644 --- a/tests/e2e_tests/test_incentive.py +++ b/tests/e2e_tests/test_incentive.py @@ -3,11 +3,14 @@ import pytest from tests.e2e_tests.utils.chain_interactions import ( + root_set_subtensor_hyperparameter_values, sudo_set_admin_utils, wait_epoch, wait_interval, ) +DURATION_OF_START_CALL = 10 + @pytest.mark.asyncio async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wallet): @@ -53,7 +56,7 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa assert alice_neuron.validator_permit is True assert alice_neuron.dividends == 0 - assert alice_neuron.stake.tao > 0 + assert alice_neuron.stake.tao == 0 assert alice_neuron.validator_trust == 0 assert alice_neuron.incentive == 0 assert alice_neuron.consensus == 0 @@ -66,6 +69,20 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa assert bob_neuron.rank == 0 assert bob_neuron.trust == 0 + subtensor.wait_for_block(DURATION_OF_START_CALL) + + # Subnet "Start Call" https://github.com/opentensor/bits/pull/13 + status, error = await root_set_subtensor_hyperparameter_values( + local_chain, + alice_wallet, + call_function="start_call", + call_params={ + "netuid": netuid, + }, + ) + + assert status is True, error + # update weights_set_rate_limit for fast-blocks tempo = subtensor.tempo(netuid) status, error = sudo_set_admin_utils( diff --git a/tests/e2e_tests/test_metagraph.py b/tests/e2e_tests/test_metagraph.py index f199cf44e3..29bb9ceaa9 100644 --- a/tests/e2e_tests/test_metagraph.py +++ b/tests/e2e_tests/test_metagraph.py @@ -202,12 +202,12 @@ def test_metagraph_info(subtensor, alice_wallet): blocks_since_last_step=1, subnet_emission=Balance(0), alpha_in=Balance.from_tao(10), - alpha_out=Balance.from_tao(2), + alpha_out=Balance.from_tao(1), tao_in=Balance.from_tao(10), - alpha_out_emission=Balance.from_tao(1), + alpha_out_emission=Balance(0), alpha_in_emission=Balance(0), tao_in_emission=Balance(0), - pending_alpha_emission=Balance.from_tao(0.820004577), + pending_alpha_emission=Balance(0), pending_root_emission=Balance(0), subnet_volume=Balance(0), moving_price=Balance(0), diff --git a/tests/e2e_tests/test_staking.py b/tests/e2e_tests/test_staking.py index 60177eb7b1..e72936d821 100644 --- a/tests/e2e_tests/test_staking.py +++ b/tests/e2e_tests/test_staking.py @@ -40,7 +40,7 @@ def test_single_operation(subtensor, alice_wallet, bob_wallet): alice_wallet, bob_wallet.hotkey.ss58_address, netuid=1, - amount=Balance.from_tao(10_000), + amount=Balance.from_tao(1), wait_for_inclusion=True, wait_for_finalization=True, ) diff --git a/tests/e2e_tests/utils/chain_interactions.py b/tests/e2e_tests/utils/chain_interactions.py index 15998f93e0..93fabb29ff 100644 --- a/tests/e2e_tests/utils/chain_interactions.py +++ b/tests/e2e_tests/utils/chain_interactions.py @@ -181,6 +181,7 @@ def sudo_set_admin_utils( wallet: "Wallet", call_function: str, call_params: dict, + call_module: str = "AdminUtils", ) -> tuple[bool, Optional[dict]]: """ Wraps the call in sudo to set hyperparameter values using AdminUtils. @@ -195,7 +196,7 @@ def sudo_set_admin_utils( tuple[bool, Optional[dict]]: (success status, error details). """ inner_call = substrate.compose_call( - call_module="AdminUtils", + call_module=call_module, call_function=call_function, call_params=call_params, ) @@ -222,7 +223,6 @@ async def root_set_subtensor_hyperparameter_values( wallet: "Wallet", call_function: str, call_params: dict, - return_error_message: bool = False, ) -> tuple[bool, str]: """ Sets liquid alpha values using AdminUtils. Mimics setting hyperparams @@ -240,10 +240,7 @@ async def root_set_subtensor_hyperparameter_values( 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 def set_identity(