diff --git a/tests/e2e_tests/test_neuron_certificate.py b/tests/e2e_tests/test_neuron_certificate.py new file mode 100644 index 0000000000..923b798059 --- /dev/null +++ b/tests/e2e_tests/test_neuron_certificate.py @@ -0,0 +1,54 @@ +from bittensor.core.subtensor import Subtensor +from bittensor.core.axon import Axon +from bittensor.utils.btlogging import logging +from tests.e2e_tests.utils.chain_interactions import ( + wait_epoch, + register_subnet, + register_neuron, +) +from tests.e2e_tests.utils.e2e_test_utils import ( + setup_wallet, +) + + +def test_neuron_certificate(local_chain): + """ + Tests the metagraph + + Steps: + 1. Register a subnet through Alice + 2. Serve alice axon with neuron certificate + 3. Verify neuron certificate + Raises: + AssertionError: If any of the checks or verifications fail + """ + logging.info("Testing neuron_certificate") + netuid = 1 + + # Register root as Alice - the subnet owner and validator + alice_keypair, alice_wallet = setup_wallet("//Alice") + register_subnet(local_chain, alice_wallet) + + # Verify subnet created successfully + assert local_chain.query( + "SubtensorModule", "NetworksAdded", [netuid] + ).serialize(), "Subnet wasn't created successfully" + + # Register Alice as a neuron on the subnet + register_neuron(local_chain, alice_wallet, netuid) + + subtensor = Subtensor(network="ws://localhost:9945") + + axon = Axon(wallet=alice_wallet) + logging.info(f"axon : {axon}") + + certificate = "FAKE_ALICE_CERT" + r = axon.serve(netuid=netuid, subtensor=subtensor, certificate=certificate) + logging.info(f"Serve response: {r}") + # await wait_epoch(subtensor) + # logging.info("Epoch started") + + assert subtensor.get_neuron_certificate(netuid=netuid, hotkey=alice_keypair.ss58_address) == certificate + + logging.info("✅ Passed test_neuron_certificate") +