22from bittensor .core .chain_data .stake_info import StakeInfo
33from bittensor .utils .balance import Balance
44from tests .e2e_tests .utils .chain_interactions import get_dynamic_balance
5- from tests .helpers .helpers import ApproxBalance
65from tests .e2e_tests .utils .e2e_test_utils import wait_to_start_call
76
87
@@ -173,7 +172,7 @@ def test_single_operation(subtensor, alice_wallet, bob_wallet):
173172
174173 # all balances have been unstaked
175174 assert stake == Balance (0 ).set_unit (alice_subnet_netuid )
176- logging .console .success (f "✅ Test [green]test_single_operation[/green] passed" )
175+ logging .console .success ("✅ Test [green]test_single_operation[/green] passed" )
177176
178177
179178def test_batch_operations (subtensor , alice_wallet , bob_wallet ):
@@ -216,7 +215,7 @@ def test_batch_operations(subtensor, alice_wallet, bob_wallet):
216215 netuid = netuid ,
217216 )
218217
219- assert stake == Balance (0 ), f"netuid={ netuid } stake={ stake } "
218+ assert stake == Balance (0 ). set_unit ( netuid ) , f"netuid={ netuid } stake={ stake } "
220219
221220 balances = subtensor .get_balances (
222221 alice_wallet .coldkey .ss58_address ,
@@ -255,7 +254,7 @@ def test_batch_operations(subtensor, alice_wallet, bob_wallet):
255254 ]
256255
257256 for netuid , stake in zip (netuids , stakes ):
258- assert stake > Balance (0 ), f"netuid={ netuid } stake={ stake } "
257+ assert stake > Balance (0 ). set_unit ( netuid ) , f"netuid={ netuid } stake={ stake } "
259258
260259 alice_balance -= len (netuids ) * Balance .from_tao (10_000 )
261260
@@ -308,7 +307,7 @@ def test_batch_operations(subtensor, alice_wallet, bob_wallet):
308307 assert balances == expected_balances
309308
310309 assert balances [alice_wallet .coldkey .ss58_address ] > alice_balance
311- logging .console .success (f "✅ Test [green]test_batch_operations[/green] passed" )
310+ logging .console .success ("✅ Test [green]test_batch_operations[/green] passed" )
312311
313312
314313def test_safe_staking_scenarios (subtensor , alice_wallet , bob_wallet ):
@@ -349,7 +348,7 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet):
349348 bob_wallet .hotkey .ss58_address ,
350349 netuid = alice_subnet_netuid ,
351350 )
352- assert initial_stake == Balance (0 )
351+ assert initial_stake == Balance (0 ). set_unit ( alice_subnet_netuid )
353352
354353 # Test Staking Scenarios
355354 stake_amount = Balance .from_tao (100 )
@@ -373,7 +372,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet):
373372 bob_wallet .hotkey .ss58_address ,
374373 netuid = alice_subnet_netuid ,
375374 )
376- assert current_stake == Balance (0 ), "Stake should not change after failed attempt"
375+ assert current_stake == Balance (0 ).set_unit (alice_subnet_netuid ), (
376+ "Stake should not change after failed attempt"
377+ )
377378
378379 # 2. Partial allowed - should succeed partially
379380 success = subtensor .add_stake (
@@ -394,7 +395,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet):
394395 bob_wallet .hotkey .ss58_address ,
395396 netuid = alice_subnet_netuid ,
396397 )
397- assert partial_stake > Balance (0 ), "Partial stake should be added"
398+ assert partial_stake > Balance (0 ).set_unit (alice_subnet_netuid ), (
399+ "Partial stake should be added"
400+ )
398401 assert partial_stake < stake_amount , (
399402 "Partial stake should be less than requested amount"
400403 )
@@ -468,7 +471,9 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet):
468471 netuid = alice_subnet_netuid ,
469472 )
470473 logging .console .info (f"[orange]Partial unstake: { partial_unstake } [orange]" )
471- assert partial_unstake > Balance (0 ), "Some stake should remain"
474+ assert partial_unstake > Balance (0 ).set_unit (alice_subnet_netuid ), (
475+ "Some stake should remain"
476+ )
472477
473478 # 3. Higher threshold - should succeed fully
474479 success = subtensor .unstake (
@@ -483,9 +488,7 @@ def test_safe_staking_scenarios(subtensor, alice_wallet, bob_wallet):
483488 allow_partial_stake = False ,
484489 )
485490 assert success is True , "Unstake should succeed"
486- logging .console .success (
487- f"✅ Test [green]test_safe_staking_scenarios[/green] passed"
488- )
491+ logging .console .success ("✅ Test [green]test_safe_staking_scenarios[/green] passed" )
489492
490493
491494def test_safe_swap_stake_scenarios (subtensor , alice_wallet , bob_wallet ):
@@ -539,7 +542,9 @@ def test_safe_swap_stake_scenarios(subtensor, alice_wallet, bob_wallet):
539542 alice_wallet .hotkey .ss58_address ,
540543 netuid = origin_netuid ,
541544 )
542- assert origin_stake > Balance (0 ), "Origin stake should be non-zero"
545+ assert origin_stake > Balance (0 ).set_unit (origin_netuid ), (
546+ "Origin stake should be non-zero"
547+ )
543548
544549 stake_swap_amount = Balance .from_tao (10_000 )
545550 # 1. Try swap with strict threshold and big amount- should fail
@@ -563,7 +568,7 @@ def test_safe_swap_stake_scenarios(subtensor, alice_wallet, bob_wallet):
563568 alice_wallet .hotkey .ss58_address ,
564569 netuid = dest_netuid ,
565570 )
566- assert dest_stake == Balance (0 ), (
571+ assert dest_stake == Balance (0 ). set_unit ( dest_netuid ) , (
567572 "Destination stake should remain 0 after failed swap"
568573 )
569574
@@ -584,7 +589,7 @@ def test_safe_swap_stake_scenarios(subtensor, alice_wallet, bob_wallet):
584589 assert success is True
585590
586591 # Verify stake was moved
587- origin_stake = subtensor .get_stake (
592+ origin_stake = subtensor .get_stake ( # TODO this seems unused
588593 alice_wallet .coldkey .ss58_address ,
589594 alice_wallet .hotkey .ss58_address ,
590595 netuid = origin_netuid ,
@@ -594,11 +599,11 @@ def test_safe_swap_stake_scenarios(subtensor, alice_wallet, bob_wallet):
594599 alice_wallet .hotkey .ss58_address ,
595600 netuid = dest_netuid ,
596601 )
597- assert dest_stake > Balance (0 ), (
602+ assert dest_stake > Balance (0 ). set_unit ( dest_netuid ) , (
598603 "Destination stake should be non-zero after successful swap"
599604 )
600605 logging .console .success (
601- f "✅ Test [green]test_safe_swap_stake_scenarios[/green] passed"
606+ "✅ Test [green]test_safe_swap_stake_scenarios[/green] passed"
602607 )
603608
604609
@@ -641,7 +646,7 @@ def test_move_stake(subtensor, alice_wallet, bob_wallet):
641646 coldkey_ss58 = alice_wallet .coldkey .ss58_address ,
642647 netuid = alice_subnet_netuid ,
643648 stake = get_dynamic_balance (stakes [0 ].stake .rao , alice_subnet_netuid ),
644- locked = Balance (0 ),
649+ locked = Balance (0 ). set_unit ( alice_subnet_netuid ) ,
645650 emission = get_dynamic_balance (stakes [0 ].emission .rao , alice_subnet_netuid ),
646651 drain = 0 ,
647652 is_registered = True ,
@@ -704,7 +709,7 @@ def test_move_stake(subtensor, alice_wallet, bob_wallet):
704709 expected_stakes += fast_block_stake
705710
706711 assert stakes == expected_stakes
707- logging .console .success (f "✅ Test [green]test_move_stake[/green] passed" )
712+ logging .console .success ("✅ Test [green]test_move_stake[/green] passed" )
708713
709714
710715def test_transfer_stake (subtensor , alice_wallet , bob_wallet , dave_wallet ):
@@ -746,7 +751,7 @@ def test_transfer_stake(subtensor, alice_wallet, bob_wallet, dave_wallet):
746751 coldkey_ss58 = alice_wallet .coldkey .ss58_address ,
747752 netuid = alice_subnet_netuid ,
748753 stake = get_dynamic_balance (alice_stakes [0 ].stake .rao , alice_subnet_netuid ),
749- locked = Balance (0 ),
754+ locked = Balance (0 ). set_unit ( alice_subnet_netuid ) ,
750755 emission = get_dynamic_balance (
751756 alice_stakes [0 ].emission .rao , alice_subnet_netuid
752757 ),
@@ -815,7 +820,7 @@ def test_transfer_stake(subtensor, alice_wallet, bob_wallet, dave_wallet):
815820 coldkey_ss58 = bob_wallet .coldkey .ss58_address ,
816821 netuid = dave_subnet_netuid ,
817822 stake = get_dynamic_balance (bob_stakes [0 ].stake .rao , dave_subnet_netuid ),
818- locked = Balance (0 ),
823+ locked = Balance (0 ). set_unit ( dave_subnet_netuid ) ,
819824 emission = get_dynamic_balance (
820825 bob_stakes [0 ].emission .rao , dave_subnet_netuid
821826 ),
@@ -824,4 +829,4 @@ def test_transfer_stake(subtensor, alice_wallet, bob_wallet, dave_wallet):
824829 ),
825830 ]
826831 assert bob_stakes == expected_bob_stake
827- logging .console .success (f "✅ Test [green]test_transfer_stake[/green] passed" )
832+ logging .console .success ("✅ Test [green]test_transfer_stake[/green] passed" )
0 commit comments