@@ -1001,9 +1001,11 @@ async def test_root_claim_keep_subnets_basic_async(
10011001 await async_subtensor .wait_for_block (next_epoch_start_block )
10021002
10031003 # Check that root alpha dividends are accumulating for SN2
1004- root_alpha_dividends = await async_subtensor .staking .get_root_alpha_dividends_per_subnet (
1005- hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
1006- netuid = sn2 .netuid ,
1004+ root_alpha_dividends = (
1005+ await async_subtensor .staking .get_root_alpha_dividends_per_subnet (
1006+ hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
1007+ netuid = sn2 .netuid ,
1008+ )
10071009 )
10081010 assert root_alpha_dividends >= Balance .from_tao (0 ).set_unit (sn2 .netuid ), (
10091011 "Root alpha dividends should be non-negative"
@@ -1113,10 +1115,6 @@ def test_root_claim_keep_subnets_with_auto_claims(
11131115 )
11141116 prev_claimed_stake_charlie = claimed_stake_charlie
11151117
1116- # Note: root_alpha_dividends may decrease when auto claims occur,
1117- # as dividends are consumed during the claim process.
1118- # We only verify that stake increases, which confirms auto claims are working.
1119-
11201118 proof_counter -= 1
11211119
11221120
@@ -1212,8 +1210,8 @@ async def test_root_claim_keep_subnets_with_auto_claims_async(
12121210
12131211 # Wait for epochs and check that stake increases on SN2 due to auto claims
12141212 while proof_counter > 0 :
1215- next_epoch_start_block = await async_subtensor . subnets . get_next_epoch_start_block (
1216- root_sn .netuid
1213+ next_epoch_start_block = (
1214+ await async_subtensor . subnets . get_next_epoch_start_block ( root_sn .netuid )
12171215 )
12181216 await async_subtensor .wait_for_block (next_epoch_start_block )
12191217
@@ -1228,10 +1226,6 @@ async def test_root_claim_keep_subnets_with_auto_claims_async(
12281226 )
12291227 prev_claimed_stake_charlie = claimed_stake_charlie
12301228
1231- # Note: root_alpha_dividends may decrease when auto claims occur,
1232- # as dividends are consumed during the claim process.
1233- # We only verify that stake increases, which confirms auto claims are working.
1234-
12351229 proof_counter -= 1
12361230
12371231
@@ -1482,17 +1476,23 @@ async def test_root_claim_keep_subnets_multiple_subnets_async(
14821476 await async_subtensor .wait_for_block (next_epoch_start_block )
14831477
14841478 # Check that root alpha dividends are accumulating for SN2 and SN3 (kept subnets)
1485- root_alpha_dividends_sn2 = await async_subtensor .staking .get_root_alpha_dividends_per_subnet (
1486- hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
1487- netuid = sn2 .netuid ,
1479+ root_alpha_dividends_sn2 = (
1480+ await async_subtensor .staking .get_root_alpha_dividends_per_subnet (
1481+ hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
1482+ netuid = sn2 .netuid ,
1483+ )
14881484 )
1489- root_alpha_dividends_sn3 = await async_subtensor .staking .get_root_alpha_dividends_per_subnet (
1490- hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
1491- netuid = sn3 .netuid ,
1485+ root_alpha_dividends_sn3 = (
1486+ await async_subtensor .staking .get_root_alpha_dividends_per_subnet (
1487+ hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
1488+ netuid = sn3 .netuid ,
1489+ )
14921490 )
1493- root_alpha_dividends_sn4 = await async_subtensor .staking .get_root_alpha_dividends_per_subnet (
1494- hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
1495- netuid = sn4 .netuid ,
1491+ root_alpha_dividends_sn4 = (
1492+ await async_subtensor .staking .get_root_alpha_dividends_per_subnet (
1493+ hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
1494+ netuid = sn4 .netuid ,
1495+ )
14961496 )
14971497
14981498 # SN2 and SN3 should have dividends (kept), SN4 should have 0 (swapped)
@@ -1508,18 +1508,15 @@ async def test_root_claim_keep_subnets_multiple_subnets_async(
15081508 )
15091509
15101510
1511- def test_root_claim_keep_subnets_various_formats (
1511+ def test_root_claim_keep_subnets_validation_and_formats (
15121512 subtensor , alice_wallet , bob_wallet , charlie_wallet
15131513):
1514- """Tests root claim KeepSubnets with various input formats.
1514+ """Tests root claim KeepSubnets validation and various input formats.
15151515
15161516 Steps:
1517- - Activate ROOT net to stake on Alice
1518- - Register SN2 and the same validator (Alice) on that subnet
1519- - Test setting KeepSubnets using different formats:
1520- - Dict: {"KeepSubnets": {"subnets": [sn2.netuid]}}
1521- - Callable: RootClaimType.KeepSubnets([sn2.netuid])
1522- - Verify that all formats work correctly
1517+ - Test that setting KeepSubnets with empty list raises error
1518+ - Test that setting KeepSubnets with invalid format raises error
1519+ - Test that various input formats work correctly and produce expected behavior
15231520 """
15241521 TEMPO_TO_SET = 20 if subtensor .chain .is_fast_blocks () else 10
15251522
@@ -1546,7 +1543,31 @@ def test_root_claim_keep_subnets_various_formats(
15461543 ]
15471544 )
15481545
1549- # Test format 1: Dict format
1546+ # Test 1: Empty subnets list should raise error
1547+ with pytest .raises ((ValueError , Exception )):
1548+ subtensor .staking .set_root_claim_type (
1549+ wallet = charlie_wallet ,
1550+ new_root_claim_type = {"KeepSubnets" : {"subnets" : []}},
1551+ raise_error = True ,
1552+ )
1553+
1554+ # Test 2: Invalid dict format should raise error
1555+ with pytest .raises ((ValueError , Exception )):
1556+ subtensor .staking .set_root_claim_type (
1557+ wallet = charlie_wallet ,
1558+ new_root_claim_type = {"KeepSubnets" : {}},
1559+ raise_error = True ,
1560+ )
1561+
1562+ # Test 3: Invalid key should raise error
1563+ with pytest .raises ((ValueError , Exception )):
1564+ subtensor .staking .set_root_claim_type (
1565+ wallet = charlie_wallet ,
1566+ new_root_claim_type = {"InvalidKey" : {"subnets" : [1 ]}},
1567+ raise_error = True ,
1568+ )
1569+
1570+ # Test 4: Dict format should work correctly
15501571 assert subtensor .staking .set_root_claim_type (
15511572 wallet = charlie_wallet ,
15521573 new_root_claim_type = {"KeepSubnets" : {"subnets" : [sn2 .netuid ]}},
@@ -1559,7 +1580,7 @@ def test_root_claim_keep_subnets_various_formats(
15591580 assert "KeepSubnets" in root_claim_type
15601581 assert sn2 .netuid in root_claim_type ["KeepSubnets" ]["subnets" ]
15611582
1562- # Test format 2 : Callable format
1583+ # Test 5 : Callable format should work correctly
15631584 assert subtensor .staking .set_root_claim_type (
15641585 wallet = charlie_wallet ,
15651586 new_root_claim_type = RootClaimType .KeepSubnets ([sn2 .netuid ]),
@@ -1574,18 +1595,15 @@ def test_root_claim_keep_subnets_various_formats(
15741595
15751596
15761597@pytest .mark .asyncio
1577- async def test_root_claim_keep_subnets_various_formats_async (
1598+ async def test_root_claim_keep_subnets_validation_and_formats_async (
15781599 async_subtensor , alice_wallet , bob_wallet , charlie_wallet
15791600):
1580- """Tests root claim KeepSubnets with various input formats.
1601+ """Tests root claim KeepSubnets validation and various input formats.
15811602
15821603 Steps:
1583- - Activate ROOT net to stake on Alice
1584- - Register SN2 and the same validator (Alice) on that subnet
1585- - Test setting KeepSubnets using different formats:
1586- - Dict: {"KeepSubnets": {"subnets": [sn2.netuid]}}
1587- - Callable: RootClaimType.KeepSubnets([sn2.netuid])
1588- - Verify that all formats work correctly
1604+ - Test that setting KeepSubnets with empty list raises error
1605+ - Test that setting KeepSubnets with invalid format raises error
1606+ - Test that various input formats work correctly and produce expected behavior
15891607 """
15901608 TEMPO_TO_SET = 20 if await async_subtensor .chain .is_fast_blocks () else 10
15911609
@@ -1612,101 +1630,56 @@ async def test_root_claim_keep_subnets_various_formats_async(
16121630 ]
16131631 )
16141632
1615- # Test format 1: Dict format
1616- assert (
1617- await async_subtensor .staking .set_root_claim_type (
1618- wallet = charlie_wallet ,
1619- new_root_claim_type = {"KeepSubnets" : {"subnets" : [sn2 .netuid ]}},
1620- )
1621- ).success
1622-
1623- root_claim_type = await async_subtensor .staking .get_root_claim_type (
1624- coldkey_ss58 = charlie_wallet .coldkey .ss58_address
1625- )
1626- assert isinstance (root_claim_type , dict )
1627- assert "KeepSubnets" in root_claim_type
1628- assert sn2 .netuid in root_claim_type ["KeepSubnets" ]["subnets" ]
1629-
1630- # Test format 2: Callable format
1631- assert (
1632- await async_subtensor .staking .set_root_claim_type (
1633- wallet = charlie_wallet ,
1634- new_root_claim_type = RootClaimType .KeepSubnets ([sn2 .netuid ]),
1635- )
1636- ).success
1637-
1638- root_claim_type = await async_subtensor .staking .get_root_claim_type (
1639- coldkey_ss58 = charlie_wallet .coldkey .ss58_address
1640- )
1641- assert isinstance (root_claim_type , dict )
1642- assert "KeepSubnets" in root_claim_type
1643- assert sn2 .netuid in root_claim_type ["KeepSubnets" ]["subnets" ]
1644-
1645-
1646- def test_root_claim_keep_subnets_validation (
1647- subtensor , alice_wallet , bob_wallet , charlie_wallet
1648- ):
1649- """Tests root claim KeepSubnets validation.
1650-
1651- Steps:
1652- - Test that setting KeepSubnets with empty list raises error
1653- - Test that setting KeepSubnets with invalid format raises error
1654- """
16551633 # Test 1: Empty subnets list should raise error
16561634 with pytest .raises ((ValueError , Exception )):
1657- subtensor .staking .set_root_claim_type (
1635+ await async_subtensor .staking .set_root_claim_type (
16581636 wallet = charlie_wallet ,
16591637 new_root_claim_type = {"KeepSubnets" : {"subnets" : []}},
16601638 raise_error = True ,
16611639 )
16621640
16631641 # Test 2: Invalid dict format should raise error
16641642 with pytest .raises ((ValueError , Exception )):
1665- subtensor .staking .set_root_claim_type (
1643+ await async_subtensor .staking .set_root_claim_type (
16661644 wallet = charlie_wallet ,
16671645 new_root_claim_type = {"KeepSubnets" : {}},
16681646 raise_error = True ,
16691647 )
16701648
16711649 # Test 3: Invalid key should raise error
16721650 with pytest .raises ((ValueError , Exception )):
1673- subtensor .staking .set_root_claim_type (
1651+ await async_subtensor .staking .set_root_claim_type (
16741652 wallet = charlie_wallet ,
16751653 new_root_claim_type = {"InvalidKey" : {"subnets" : [1 ]}},
16761654 raise_error = True ,
16771655 )
16781656
1679-
1680- @pytest .mark .asyncio
1681- async def test_root_claim_keep_subnets_validation_async (
1682- async_subtensor , alice_wallet , bob_wallet , charlie_wallet
1683- ):
1684- """Tests root claim KeepSubnets validation.
1685-
1686- Steps:
1687- - Test that setting KeepSubnets with empty list raises error
1688- - Test that setting KeepSubnets with invalid format raises error
1689- """
1690- # Test 1: Empty subnets list should raise error
1691- with pytest .raises ((ValueError , Exception )):
1657+ # Test 4: Dict format should work correctly
1658+ assert (
16921659 await async_subtensor .staking .set_root_claim_type (
16931660 wallet = charlie_wallet ,
1694- new_root_claim_type = {"KeepSubnets" : {"subnets" : []}},
1695- raise_error = True ,
1661+ new_root_claim_type = {"KeepSubnets" : {"subnets" : [sn2 .netuid ]}},
16961662 )
1663+ ).success
16971664
1698- # Test 2: Invalid dict format should raise error
1699- with pytest .raises ((ValueError , Exception )):
1700- await async_subtensor .staking .set_root_claim_type (
1701- wallet = charlie_wallet ,
1702- new_root_claim_type = {"KeepSubnets" : {}},
1703- raise_error = True ,
1704- )
1665+ root_claim_type = await async_subtensor .staking .get_root_claim_type (
1666+ coldkey_ss58 = charlie_wallet .coldkey .ss58_address
1667+ )
1668+ assert isinstance (root_claim_type , dict )
1669+ assert "KeepSubnets" in root_claim_type
1670+ assert sn2 .netuid in root_claim_type ["KeepSubnets" ]["subnets" ]
17051671
1706- # Test 3: Invalid key should raise error
1707- with pytest . raises (( ValueError , Exception )):
1672+ # Test 5: Callable format should work correctly
1673+ assert (
17081674 await async_subtensor .staking .set_root_claim_type (
17091675 wallet = charlie_wallet ,
1710- new_root_claim_type = {"InvalidKey" : {"subnets" : [1 ]}},
1711- raise_error = True ,
1676+ new_root_claim_type = RootClaimType .KeepSubnets ([sn2 .netuid ]),
17121677 )
1678+ ).success
1679+
1680+ root_claim_type = await async_subtensor .staking .get_root_claim_type (
1681+ coldkey_ss58 = charlie_wallet .coldkey .ss58_address
1682+ )
1683+ assert isinstance (root_claim_type , dict )
1684+ assert "KeepSubnets" in root_claim_type
1685+ assert sn2 .netuid in root_claim_type ["KeepSubnets" ]["subnets" ]
0 commit comments