forked from opentensor/bittensor
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab54fdd
commit 467bcf9
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import pytest | ||
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_interval, | ||
register_subnet, | ||
register_neuron, | ||
) | ||
from tests.e2e_tests.utils.e2e_test_utils import ( | ||
setup_wallet, | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async 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 can be retrieved | ||
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") | ||
|
||
# Serve Alice's axon with a certificate | ||
axon = Axon(wallet=alice_wallet) | ||
encoded_certificate = "?FAKE_ALICE_CERT" | ||
axon.serve(netuid=netuid, subtensor=subtensor, certificate=encoded_certificate) | ||
|
||
await wait_interval(tempo=1, subtensor=subtensor, netuid=netuid) | ||
|
||
# Verify we are getting the correct certificate | ||
assert ( | ||
subtensor.get_neuron_certificate( | ||
netuid=netuid, hotkey=alice_keypair.ss58_address | ||
) | ||
== encoded_certificate | ||
) | ||
|
||
logging.info("✅ Passed test_neuron_certificate") |