diff --git a/tests/e2e_tests/conftest.py b/tests/e2e_tests/conftest.py index 1590e5d6e5..7d72315b90 100644 --- a/tests/e2e_tests/conftest.py +++ b/tests/e2e_tests/conftest.py @@ -49,13 +49,6 @@ def local_chain(request): # Pattern match indicates node is compiled and ready pattern = re.compile(r"Imported #1") - - # install neuron templates - logging.info("downloading and installing neuron templates from github") - # commit with subnet-template-repo changes for rust wallet - templates_dir = clone_or_update_templates() - install_templates(templates_dir) - timestamp = int(time.time()) def wait_for_node_start(process, pattern): @@ -87,7 +80,7 @@ def read_output(): wait_for_node_start(process, pattern) # Run the test, passing in substrate interface - yield SubstrateInterface(url="ws://127.0.0.1:9945") + yield SubstrateInterface(url="ws://127.0.0.1:9944") # Terminate the process group (includes all child processes) os.killpg(os.getpgid(process.pid), signal.SIGTERM) @@ -102,14 +95,25 @@ def read_output(): # Ensure the process has terminated process.wait() - # uninstall templates + +@pytest.fixture +def templates(): + logging.info("downloading and installing neuron templates from github") + + templates_dir = clone_or_update_templates() + + install_templates(templates_dir) + + yield templates_dir + logging.info("uninstalling neuron templates") + uninstall_templates(template_path) @pytest.fixture def subtensor(local_chain): - return Subtensor(network="ws://localhost:9945") + return Subtensor(network="ws://localhost:9944") @pytest.fixture diff --git a/tests/e2e_tests/test_axon.py b/tests/e2e_tests/test_axon.py index f89d29ff0d..0d3825b465 100644 --- a/tests/e2e_tests/test_axon.py +++ b/tests/e2e_tests/test_axon.py @@ -4,14 +4,10 @@ import pytest from bittensor.utils import networking -from tests.e2e_tests.utils.e2e_test_utils import ( - template_path, - templates_repo, -) @pytest.mark.asyncio -async def test_axon(subtensor, alice_wallet): +async def test_axon(subtensor, templates, alice_wallet): """ Test the Axon mechanism and successful registration on the network. @@ -53,13 +49,13 @@ async def test_axon(subtensor, alice_wallet): cmd = " ".join( [ f"{sys.executable}", - f'"{template_path}{templates_repo}/miner.py"', + f'"{templates}/miner.py"', "--netuid", str(netuid), "--subtensor.network", "local", "--subtensor.chain_endpoint", - "ws://localhost:9945", + "ws://localhost:9944", "--wallet.path", alice_wallet.path, "--wallet.name", diff --git a/tests/e2e_tests/test_dendrite.py b/tests/e2e_tests/test_dendrite.py index 070ffdf3ee..c4ebcef35b 100644 --- a/tests/e2e_tests/test_dendrite.py +++ b/tests/e2e_tests/test_dendrite.py @@ -10,14 +10,10 @@ sudo_set_hyperparameter_values, wait_epoch, ) -from tests.e2e_tests.utils.e2e_test_utils import ( - template_path, - templates_repo, -) @pytest.mark.asyncio -async def test_dendrite(local_chain, subtensor, alice_wallet, bob_wallet): +async def test_dendrite(local_chain, subtensor, templates, alice_wallet, bob_wallet): """ Test the Dendrite mechanism @@ -112,13 +108,13 @@ async def test_dendrite(local_chain, subtensor, alice_wallet, bob_wallet): cmd = " ".join( [ f"{sys.executable}", - f'"{template_path}{templates_repo}/validator.py"', + f'"{templates}/validator.py"', "--netuid", str(netuid), "--subtensor.network", "local", "--subtensor.chain_endpoint", - "ws://localhost:9945", + "ws://localhost:9944", "--wallet.path", bob_wallet.path, "--wallet.name", diff --git a/tests/e2e_tests/test_incentive.py b/tests/e2e_tests/test_incentive.py index 6f73799c31..ae445914d7 100644 --- a/tests/e2e_tests/test_incentive.py +++ b/tests/e2e_tests/test_incentive.py @@ -7,14 +7,10 @@ sudo_set_hyperparameter_values, wait_epoch, ) -from tests.e2e_tests.utils.e2e_test_utils import ( - template_path, - templates_repo, -) @pytest.mark.asyncio -async def test_incentive(local_chain, subtensor, alice_wallet, bob_wallet): +async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wallet): """ Test the incentive mechanism and interaction of miners/validators @@ -75,13 +71,13 @@ async def test_incentive(local_chain, subtensor, alice_wallet, bob_wallet): cmd = " ".join( [ f"{sys.executable}", - f'"{template_path}{templates_repo}/miner.py"', + f'"{templates}/miner.py"', "--netuid", str(netuid), "--subtensor.network", "local", "--subtensor.chain_endpoint", - "ws://localhost:9945", + "ws://localhost:9944", "--wallet.path", bob_wallet.path, "--wallet.name", @@ -104,13 +100,13 @@ async def test_incentive(local_chain, subtensor, alice_wallet, bob_wallet): cmd = " ".join( [ f"{sys.executable}", - f'"{template_path}{templates_repo}/validator.py"', + f'"{templates}/validator.py"', "--netuid", str(netuid), "--subtensor.network", "local", "--subtensor.chain_endpoint", - "ws://localhost:9945", + "ws://localhost:9944", "--wallet.path", alice_wallet.path, "--wallet.name", diff --git a/tests/e2e_tests/test_root_set_weights.py b/tests/e2e_tests/test_root_set_weights.py index a6fd9a160b..83b3284e37 100644 --- a/tests/e2e_tests/test_root_set_weights.py +++ b/tests/e2e_tests/test_root_set_weights.py @@ -6,10 +6,6 @@ wait_epoch, sudo_set_hyperparameter_values, ) -from tests.e2e_tests.utils.e2e_test_utils import ( - template_path, - templates_repo, -) FAST_BLOCKS_SPEEDUP_FACTOR = 5 @@ -34,7 +30,13 @@ @pytest.mark.asyncio -async def test_root_reg_hyperparams(local_chain, subtensor, alice_wallet, bob_wallet): +async def test_root_reg_hyperparams( + local_chain, + subtensor, + templates, + alice_wallet, + bob_wallet, +): """ Test root weights and hyperparameters in the Subtensor network. @@ -86,13 +88,13 @@ async def test_root_reg_hyperparams(local_chain, subtensor, alice_wallet, bob_wa cmd = " ".join( [ f"{sys.executable}", - f'"{template_path}{templates_repo}/validator.py"', + f'"{templates}/validator.py"', "--netuid", str(netuid), "--subtensor.network", "local", "--subtensor.chain_endpoint", - "ws://localhost:9945", + "ws://localhost:9944", "--wallet.path", alice_wallet.path, "--wallet.name", diff --git a/tests/e2e_tests/test_subtensor_functions.py b/tests/e2e_tests/test_subtensor_functions.py index 831df35dcc..590842c900 100644 --- a/tests/e2e_tests/test_subtensor_functions.py +++ b/tests/e2e_tests/test_subtensor_functions.py @@ -8,10 +8,6 @@ sudo_set_admin_utils, wait_epoch, ) -from tests.e2e_tests.utils.e2e_test_utils import ( - template_path, - templates_repo, -) """ Verifies: @@ -35,7 +31,7 @@ @pytest.mark.asyncio -async def test_subtensor_extrinsics(subtensor, alice_wallet, bob_wallet): +async def test_subtensor_extrinsics(subtensor, templates, alice_wallet, bob_wallet): """ Tests subtensor extrinsics @@ -163,13 +159,13 @@ async def test_subtensor_extrinsics(subtensor, alice_wallet, bob_wallet): cmd = " ".join( [ f"{sys.executable}", - f'"{template_path}{templates_repo}/validator.py"', + f'"{templates}/validator.py"', "--netuid", str(netuid), "--subtensor.network", "local", "--subtensor.chain_endpoint", - "ws://localhost:9945", + "ws://localhost:9944", "--wallet.path", alice_wallet.path, "--wallet.name", diff --git a/tests/e2e_tests/utils/e2e_test_utils.py b/tests/e2e_tests/utils/e2e_test_utils.py index ebf6a6a1e2..8d187d967f 100644 --- a/tests/e2e_tests/utils/e2e_test_utils.py +++ b/tests/e2e_tests/utils/e2e_test_utils.py @@ -73,11 +73,11 @@ def clone_or_update_templates(specific_commit=None): os.chdir(cwd) - return install_dir + templates_repo + "/" + return install_dir + templates_repo def install_templates(install_dir): - subprocess.check_call([sys.executable, "-m", "pip", "install", "."]) + subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", "."]) def uninstall_templates(install_dir):