1
1
from bittensor import logging
2
2
from bittensor .core .chain_data .stake_info import StakeInfo
3
3
from bittensor .utils .balance import Balance
4
- from tests .e2e_tests .utils .chain_interactions import ANY_BALANCE
4
+ from tests .e2e_tests .utils .chain_interactions import get_dynamic_balance
5
5
from tests .helpers .helpers import ApproxBalance
6
6
7
7
logging .enable_info ()
@@ -177,8 +177,10 @@ def test_batch_operations(subtensor, alice_wallet, bob_wallet):
177
177
)
178
178
179
179
assert balances == {
180
- alice_wallet .coldkey .ss58_address : ANY_BALANCE ,
181
- bob_wallet .coldkey .ss58_address : Balance .from_tao (999_998 ),
180
+ alice_wallet .coldkey .ss58_address : get_dynamic_balance (
181
+ balances [alice_wallet .coldkey .ss58_address ].rao , 2
182
+ ),
183
+ bob_wallet .coldkey .ss58_address : Balance .from_tao (999_998 ).set_unit (3 ),
182
184
}
183
185
184
186
alice_balance = balances [alice_wallet .coldkey .ss58_address ]
@@ -240,7 +242,9 @@ def test_batch_operations(subtensor, alice_wallet, bob_wallet):
240
242
)
241
243
242
244
assert balances == {
243
- alice_wallet .coldkey .ss58_address : ANY_BALANCE ,
245
+ alice_wallet .coldkey .ss58_address : get_dynamic_balance (
246
+ balances [alice_wallet .coldkey .ss58_address ].rao , 2
247
+ ),
244
248
bob_wallet .coldkey .ss58_address : Balance .from_tao (999_998 ),
245
249
}
246
250
assert balances [alice_wallet .coldkey .ss58_address ] > alice_balance
@@ -525,6 +529,7 @@ def test_move_stake(subtensor, alice_wallet, bob_wallet):
525
529
- Moving stake from one hotkey-subnet pair to another
526
530
"""
527
531
532
+ netuid = 1
528
533
subtensor .burned_register (
529
534
alice_wallet ,
530
535
netuid = 1 ,
@@ -535,7 +540,7 @@ def test_move_stake(subtensor, alice_wallet, bob_wallet):
535
540
assert subtensor .add_stake (
536
541
alice_wallet ,
537
542
alice_wallet .hotkey .ss58_address ,
538
- netuid = 1 ,
543
+ netuid = netuid ,
539
544
amount = Balance .from_tao (1_000 ),
540
545
wait_for_inclusion = True ,
541
546
wait_for_finalization = True ,
@@ -547,10 +552,10 @@ def test_move_stake(subtensor, alice_wallet, bob_wallet):
547
552
StakeInfo (
548
553
hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
549
554
coldkey_ss58 = alice_wallet .coldkey .ss58_address ,
550
- netuid = 1 ,
551
- stake = ANY_BALANCE ,
555
+ netuid = netuid ,
556
+ stake = get_dynamic_balance ( stakes [ 0 ]. stake . rao , netuid ) ,
552
557
locked = Balance (0 ),
553
- emission = ANY_BALANCE ,
558
+ emission = get_dynamic_balance ( stakes [ 0 ]. emission . rao , netuid ) ,
554
559
drain = 0 ,
555
560
is_registered = True ,
556
561
),
@@ -571,14 +576,15 @@ def test_move_stake(subtensor, alice_wallet, bob_wallet):
571
576
572
577
stakes = subtensor .get_stake_for_coldkey (alice_wallet .coldkey .ss58_address )
573
578
579
+ netuid = 2
574
580
assert stakes == [
575
581
StakeInfo (
576
582
hotkey_ss58 = bob_wallet .hotkey .ss58_address ,
577
583
coldkey_ss58 = alice_wallet .coldkey .ss58_address ,
578
- netuid = 2 ,
579
- stake = ANY_BALANCE ,
584
+ netuid = netuid ,
585
+ stake = get_dynamic_balance ( stakes [ 0 ]. stake . rao , netuid ) ,
580
586
locked = Balance (0 ),
581
- emission = ANY_BALANCE ,
587
+ emission = get_dynamic_balance ( stakes [ 0 ]. emission . rao , netuid ) ,
582
588
drain = 0 ,
583
589
is_registered = True ,
584
590
),
@@ -589,20 +595,21 @@ def test_transfer_stake(subtensor, alice_wallet, bob_wallet, dave_wallet):
589
595
"""
590
596
Tests:
591
597
- Adding stake
592
- - Transfering stake from one coldkey-subnet pair to another
598
+ - Transferring stake from one coldkey-subnet pair to another
593
599
"""
600
+ netuid = 1
594
601
595
602
subtensor .burned_register (
596
603
alice_wallet ,
597
- netuid = 1 ,
604
+ netuid = netuid ,
598
605
wait_for_inclusion = True ,
599
606
wait_for_finalization = True ,
600
607
)
601
608
602
609
assert subtensor .add_stake (
603
610
alice_wallet ,
604
611
alice_wallet .hotkey .ss58_address ,
605
- netuid = 1 ,
612
+ netuid = netuid ,
606
613
amount = Balance .from_tao (1_000 ),
607
614
wait_for_inclusion = True ,
608
615
wait_for_finalization = True ,
@@ -614,10 +621,10 @@ def test_transfer_stake(subtensor, alice_wallet, bob_wallet, dave_wallet):
614
621
StakeInfo (
615
622
hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
616
623
coldkey_ss58 = alice_wallet .coldkey .ss58_address ,
617
- netuid = 1 ,
618
- stake = ANY_BALANCE ,
624
+ netuid = netuid ,
625
+ stake = get_dynamic_balance ( alice_stakes [ 0 ]. stake . rao , netuid ) ,
619
626
locked = Balance (0 ),
620
- emission = ANY_BALANCE ,
627
+ emission = get_dynamic_balance ( alice_stakes [ 0 ]. emission . rao , netuid ) ,
621
628
drain = 0 ,
622
629
is_registered = True ,
623
630
),
@@ -652,14 +659,15 @@ def test_transfer_stake(subtensor, alice_wallet, bob_wallet, dave_wallet):
652
659
653
660
bob_stakes = subtensor .get_stake_for_coldkey (bob_wallet .coldkey .ss58_address )
654
661
662
+ netuid = 2
655
663
assert bob_stakes == [
656
664
StakeInfo (
657
665
hotkey_ss58 = alice_wallet .hotkey .ss58_address ,
658
666
coldkey_ss58 = bob_wallet .coldkey .ss58_address ,
659
667
netuid = 2 ,
660
- stake = ANY_BALANCE ,
668
+ stake = get_dynamic_balance ( bob_stakes [ 0 ]. stake . rao , netuid ) ,
661
669
locked = Balance (0 ),
662
- emission = ANY_BALANCE ,
670
+ emission = get_dynamic_balance ( bob_stakes [ 0 ]. emission . rao , netuid ) ,
663
671
drain = 0 ,
664
672
is_registered = False ,
665
673
),
0 commit comments