Skip to content

Commit 7e4849a

Browse files
basfromanibraheem-abe
authored andcommitted
Add subvortex subnet and tests (#2395)
* add `subvortex` subnet and tests * ruff
1 parent 1a5a243 commit 7e4849a

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

bittensor/core/settings.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,26 @@
4040
WALLETS_DIR.mkdir(parents=True, exist_ok=True)
4141
MINERS_DIR.mkdir(parents=True, exist_ok=True)
4242

43+
# Bittensor networks name
44+
NETWORKS = ["finney", "test", "archive", "local", "subvortex"]
45+
46+
DEFAULT_ENDPOINT = "wss://entrypoint-finney.opentensor.ai:443"
47+
DEFAULT_NETWORK = NETWORKS[0]
4348

4449
# Bittensor endpoints (Needs to use wss://)
4550
FINNEY_ENTRYPOINT = "wss://entrypoint-finney.opentensor.ai:443"
4651
FINNEY_TEST_ENTRYPOINT = "wss://test.finney.opentensor.ai:443/"
4752
ARCHIVE_ENTRYPOINT = "wss://archive.chain.opentensor.ai:443/"
4853
LOCAL_ENTRYPOINT = os.getenv("BT_SUBTENSOR_CHAIN_ENDPOINT") or "ws://127.0.0.1:9944"
54+
SUBVORTEX_ENTRYPOINT = "ws://subvortex.info:9944"
55+
56+
NETWORK_MAP = {
57+
NETWORKS[0]: FINNEY_ENTRYPOINT,
58+
NETWORKS[1]: FINNEY_TEST_ENTRYPOINT,
59+
NETWORKS[2]: ARCHIVE_ENTRYPOINT,
60+
NETWORKS[3]: LOCAL_ENTRYPOINT,
61+
NETWORKS[4]: SUBVORTEX_ENTRYPOINT,
62+
}
4963

5064
# Currency Symbols Bittensor
5165
TAO_SYMBOL: str = chr(0x03C4)

bittensor/core/subtensor.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -715,16 +715,8 @@ def determine_chain_endpoint_and_network(
715715

716716
if network is None:
717717
return None, None
718-
if network in ["finney", "local", "test", "archive"]:
719-
if network == "finney":
720-
# Kiru Finney staging network.
721-
return network, settings.FINNEY_ENTRYPOINT
722-
elif network == "local":
723-
return network, settings.LOCAL_ENTRYPOINT
724-
elif network == "test":
725-
return network, settings.FINNEY_TEST_ENTRYPOINT
726-
elif network == "archive":
727-
return network, settings.ARCHIVE_ENTRYPOINT
718+
if network in settings.NETWORKS:
719+
return network, settings.NETWORK_MAP[network]
728720
else:
729721
if (
730722
network == settings.FINNEY_ENTRYPOINT
@@ -745,7 +737,6 @@ def determine_chain_endpoint_and_network(
745737
return "local", network
746738
else:
747739
return "unknown", network
748-
return None, None
749740

750741
def get_netuids_for_hotkey(
751742
self, hotkey_ss58: str, block: Optional[int] = None

tests/unit_tests/test_subtensor.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,3 +2138,16 @@ def test_get_delegate_take_none(subtensor, mocker):
21382138

21392139
subtensor_module.u16_normalized_float.assert_not_called()
21402140
assert result is None
2141+
2142+
2143+
def test_networks_during_connection(mocker):
2144+
"""Test networks during_connection."""
2145+
# Preps
2146+
subtensor_module.SubstrateInterface = mocker.Mock()
2147+
# Call
2148+
for network in list(settings.NETWORK_MAP.keys()) + ["undefined"]:
2149+
sub = Subtensor(network)
2150+
2151+
# Assertions
2152+
sub.network = network
2153+
sub.chain_endpoint = settings.NETWORK_MAP.get(network)

0 commit comments

Comments
 (0)