Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreea-popescu-reef committed Nov 20, 2024
1 parent c84513e commit a40a279
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/e2e_tests/test_neuron_certificate.py
Original file line number Diff line number Diff line change
@@ -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 <netuid> 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")

0 comments on commit a40a279

Please sign in to comment.