Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4149,6 +4149,7 @@ async def set_subnet_identity(
github_repo=subnet_identity.github_repo,
subnet_contact=subnet_identity.subnet_contact,
subnet_url=subnet_identity.subnet_url,
logo_url=subnet_identity.logo_url,
discord=subnet_identity.discord,
description=subnet_identity.description,
additional=subnet_identity.additional,
Expand Down
1 change: 1 addition & 0 deletions bittensor/core/chain_data/dynamic_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def _from_dict(cls, decoded: dict) -> "DynamicInfo":
decoded["subnet_identity"]["subnet_contact"]
).decode(),
subnet_url=bytes(decoded["subnet_identity"]["subnet_url"]).decode(),
logo_url=bytes(decoded["subnet_identity"]["logo_url"]).decode(),
discord=bytes(decoded["subnet_identity"]["discord"]).decode(),
description=bytes(decoded["subnet_identity"]["description"]).decode(),
additional=bytes(decoded["subnet_identity"]["additional"]).decode(),
Expand Down
2 changes: 2 additions & 0 deletions bittensor/core/chain_data/subnet_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class SubnetIdentity:
github_repo: str
subnet_contact: str
subnet_url: str
logo_url: str
discord: str
description: str
additional: str
Expand All @@ -21,6 +22,7 @@ def _from_dict(cls, decoded: dict) -> "SubnetIdentity":
github_repo=decoded["github_repo"],
subnet_contact=decoded["subnet_contact"],
subnet_url=decoded["subnet_url"],
logo_url=decoded["logo_url"],
discord=decoded["discord"],
description=decoded["description"],
additional=decoded["additional"],
Expand Down
3 changes: 3 additions & 0 deletions bittensor/core/extrinsics/asyncex/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ async def set_subnet_identity_extrinsic(
github_repo: str,
subnet_contact: str,
subnet_url: str,
logo_url: str,
discord: str,
description: str,
additional: str,
Expand All @@ -488,6 +489,7 @@ async def set_subnet_identity_extrinsic(
github_repo (str): URL of the GitHub repository related to the subnet.
subnet_contact (str): Subnet's contact information, e.g., email or contact link.
subnet_url (str): The URL of the subnet's primary web portal.
logo_url (str): The URL of the logo's primary web portal.
discord (str): Discord server or contact for the subnet.
description (str): A textual description of the subnet.
additional (str): Any additional metadata or information related to the subnet.
Expand Down Expand Up @@ -516,6 +518,7 @@ async def set_subnet_identity_extrinsic(
"github_repo": github_repo,
"subnet_contact": subnet_contact,
"subnet_url": subnet_url,
"logo_url": logo_url,
"discord": discord,
"description": description,
"additional": additional,
Expand Down
3 changes: 3 additions & 0 deletions bittensor/core/extrinsics/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ def set_subnet_identity_extrinsic(
github_repo: str,
subnet_contact: str,
subnet_url: str,
logo_url: str,
discord: str,
description: str,
additional: str,
Expand All @@ -480,6 +481,7 @@ def set_subnet_identity_extrinsic(
github_repo (str): URL of the GitHub repository related to the subnet.
subnet_contact (str): Subnet's contact information, e.g., email or contact link.
subnet_url (str): The URL of the subnet's primary web portal.
logo_url (str): The URL of the logo's primary web portal.
discord (str): Discord server or contact for the subnet.
description (str): A textual description of the subnet.
additional (str): Any additional metadata or information related to the subnet.
Expand Down Expand Up @@ -508,6 +510,7 @@ def set_subnet_identity_extrinsic(
"github_repo": github_repo,
"subnet_contact": subnet_contact,
"subnet_url": subnet_url,
"logo_url": logo_url,
"discord": discord,
"description": description,
"additional": additional,
Expand Down
1 change: 1 addition & 0 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3386,6 +3386,7 @@ def set_subnet_identity(
github_repo=subnet_identity.github_repo,
subnet_contact=subnet_identity.subnet_contact,
subnet_url=subnet_identity.subnet_url,
logo_url=subnet_identity.logo_url,
discord=subnet_identity.discord,
description=subnet_identity.description,
additional=subnet_identity.additional,
Expand Down
18 changes: 10 additions & 8 deletions tests/e2e_tests/test_set_subnet_identity_extrinsic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ async def test_set_subnet_identity_extrinsic_happy_pass(subtensor, alice_wallet)
# Verify subnet <netuid> created successfully
assert subtensor.subnet_exists(netuid), "Subnet wasn't created successfully"

# make sure subnet_identity is empty
# Make sure subnet_identity is empty
assert subtensor.subnet(netuid).subnet_identity is None, (
"Subnet identity should be None before set"
)

# prepare SubnetIdentity for subnet
# Prepare SubnetIdentity for subnet
subnet_identity = SubnetIdentity(
subnet_name="e2e test subnet",
github_repo="e2e test repo",
subnet_contact="e2e test contact",
subnet_url="e2e test url",
logo_url="e2e test logo url",
discord="e2e test discord",
description="e2e test description",
additional="e2e test additional",
)

# set SubnetIdentity to subnet
# Set SubnetIdentity to subnet
assert (
subtensor.set_subnet_identity(
wallet=alice_wallet,
Expand All @@ -44,7 +45,7 @@ async def test_set_subnet_identity_extrinsic_happy_pass(subtensor, alice_wallet)
is True
), "Set subnet identity failed"

# check SubnetIdentity of the subnet
# Check SubnetIdentity of the subnet
assert subtensor.subnet(netuid).subnet_identity == subnet_identity


Expand All @@ -69,31 +70,32 @@ async def test_set_subnet_identity_extrinsic_failed(
"[magenta]Testing `set_subnet_identity_extrinsic` with failed result.[/magenta]"
)

netuid = 2
netuid = subtensor.get_total_subnets() # 2

# Register a subnet, netuid 2
assert subtensor.register_subnet(alice_wallet), "Subnet wasn't created"

# Verify subnet <netuid> created successfully
assert subtensor.subnet_exists(netuid), "Subnet wasn't created successfully"

# make sure subnet_identity is empty
# Make sure subnet_identity is empty
assert subtensor.subnet(netuid).subnet_identity is None, (
"Subnet identity should be None before set"
)

# prepare SubnetIdentity for subnet
# Prepare SubnetIdentity for subnet
subnet_identity = SubnetIdentity(
subnet_name="e2e test subnet",
github_repo="e2e test repo",
subnet_contact="e2e test contact",
subnet_url="e2e test url",
logo_url="e2e test logo url",
discord="e2e test discord",
description="e2e test description",
additional="e2e test additional",
)

# set SubnetIdentity to subnet
# Set SubnetIdentity to subnet with wrong wallet
assert (
subtensor.set_subnet_identity(
wallet=bob_wallet,
Expand Down
6 changes: 6 additions & 0 deletions tests/unit_tests/extrinsics/asyncex/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ async def test_set_subnet_identity_extrinsic_is_success(subtensor, fake_wallet,
github_repo = "mock_github_repo"
subnet_contact = "mock_subnet_contact"
subnet_url = "mock_subnet_url"
logo_url = "mock_logo_url"
discord = "mock_discord"
description = "mock_description"
additional = "mock_additional"
Expand All @@ -452,6 +453,7 @@ async def test_set_subnet_identity_extrinsic_is_success(subtensor, fake_wallet,
github_repo=github_repo,
subnet_contact=subnet_contact,
subnet_url=subnet_url,
logo_url=logo_url,
discord=discord,
description=description,
additional=additional,
Expand All @@ -468,6 +470,7 @@ async def test_set_subnet_identity_extrinsic_is_success(subtensor, fake_wallet,
"github_repo": github_repo,
"subnet_contact": subnet_contact,
"subnet_url": subnet_url,
"logo_url": logo_url,
"discord": discord,
"description": description,
"additional": additional,
Expand All @@ -493,6 +496,7 @@ async def test_set_subnet_identity_extrinsic_is_failed(subtensor, fake_wallet, m
github_repo = "mock_github_repo"
subnet_contact = "mock_subnet_contact"
subnet_url = "mock_subnet_url"
logo_url = "mock_logo_url"
discord = "mock_discord"
description = "mock_description"
additional = "mock_additional"
Expand All @@ -515,6 +519,7 @@ async def test_set_subnet_identity_extrinsic_is_failed(subtensor, fake_wallet, m
github_repo=github_repo,
subnet_contact=subnet_contact,
subnet_url=subnet_url,
logo_url=logo_url,
discord=discord,
description=description,
additional=additional,
Expand All @@ -533,6 +538,7 @@ async def test_set_subnet_identity_extrinsic_is_failed(subtensor, fake_wallet, m
"github_repo": github_repo,
"subnet_contact": subnet_contact,
"subnet_url": subnet_url,
"logo_url": logo_url,
"discord": discord,
"description": description,
"additional": additional,
Expand Down
34 changes: 20 additions & 14 deletions tests/unit_tests/extrinsics/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def test_set_subnet_identity_extrinsic_is_success(mock_subtensor, mock_wallet, m
github_repo = "mock_github_repo"
subnet_contact = "mock_subnet_contact"
subnet_url = "mock_subnet_url"
logo_url = "mock_logo_url"
discord = "mock_discord"
description = "mock_description"
additional = "mock_additional"
Expand All @@ -253,6 +254,7 @@ def test_set_subnet_identity_extrinsic_is_success(mock_subtensor, mock_wallet, m
github_repo=github_repo,
subnet_contact=subnet_contact,
subnet_url=subnet_url,
logo_url=logo_url,
discord=discord,
description=description,
additional=additional,
Expand All @@ -265,13 +267,14 @@ def test_set_subnet_identity_extrinsic_is_success(mock_subtensor, mock_wallet, m
call_params={
"hotkey": mock_wallet.hotkey.ss58_address,
"netuid": netuid,
"subnet_name": "mock_subnet_name",
"github_repo": "mock_github_repo",
"subnet_contact": "mock_subnet_contact",
"subnet_url": "mock_subnet_url",
"discord": "mock_discord",
"description": "mock_description",
"additional": "mock_additional",
"subnet_name": subnet_name,
"github_repo": github_repo,
"subnet_contact": subnet_contact,
"subnet_url": subnet_url,
"logo_url": logo_url,
"discord": discord,
"description": description,
"additional": additional,
},
)
mocked_sign_and_send_extrinsic.assert_called_once_with(
Expand All @@ -293,6 +296,7 @@ def test_set_subnet_identity_extrinsic_is_failed(mock_subtensor, mock_wallet, mo
github_repo = "mock_github_repo"
subnet_contact = "mock_subnet_contact"
subnet_url = "mock_subnet_url"
logo_url = "mock_logo_url"
discord = "mock_discord"
description = "mock_description"
additional = "mock_additional"
Expand All @@ -315,6 +319,7 @@ def test_set_subnet_identity_extrinsic_is_failed(mock_subtensor, mock_wallet, mo
github_repo=github_repo,
subnet_contact=subnet_contact,
subnet_url=subnet_url,
logo_url=logo_url,
discord=discord,
description=description,
additional=additional,
Expand All @@ -327,13 +332,14 @@ def test_set_subnet_identity_extrinsic_is_failed(mock_subtensor, mock_wallet, mo
call_params={
"hotkey": mock_wallet.hotkey.ss58_address,
"netuid": netuid,
"subnet_name": "mock_subnet_name",
"github_repo": "mock_github_repo",
"subnet_contact": "mock_subnet_contact",
"subnet_url": "mock_subnet_url",
"discord": "mock_discord",
"description": "mock_description",
"additional": "mock_additional",
"subnet_name": subnet_name,
"github_repo": github_repo,
"subnet_contact": subnet_contact,
"subnet_url": subnet_url,
"logo_url": logo_url,
"discord": discord,
"description": description,
"additional": additional,
},
)
mocked_sign_and_send_extrinsic.assert_called_once_with(
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/test_async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,7 @@ async def test_set_subnet_identity(mocker, subtensor, fake_wallet):
github_repo=fake_subnet_identity.github_repo,
subnet_contact=fake_subnet_identity.subnet_contact,
subnet_url=fake_subnet_identity.subnet_url,
logo_url=fake_subnet_identity.logo_url,
discord=fake_subnet_identity.discord,
description=fake_subnet_identity.description,
additional=fake_subnet_identity.additional,
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/test_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3209,6 +3209,7 @@ def test_set_subnet_identity(mocker, subtensor, fake_wallet):
github_repo=fake_subnet_identity.github_repo,
subnet_contact=fake_subnet_identity.subnet_contact,
subnet_url=fake_subnet_identity.subnet_url,
logo_url=fake_subnet_identity.logo_url,
discord=fake_subnet_identity.discord,
description=fake_subnet_identity.description,
additional=fake_subnet_identity.additional,
Expand Down