@@ -711,144 +711,141 @@ fn get_account_id_from_ss58(ss58_str: &str) -> U256 {
711
711
#[ test]
712
712
fn test_migrate_rao ( ) {
713
713
new_test_ext ( 1 ) . execute_with ( || {
714
- assert ! ( false ) ;
715
-
716
- // // Setup initial state
717
- // let netuid_0: u16 = 0;
718
- // let netuid_1: u16 = 1;
719
- // let hotkey1 = U256::from(1);
720
- // let hotkey2 = U256::from(2);
721
- // let coldkey1 = U256::from(3);
722
- // let coldkey2 = U256::from(4);
723
- // let coldkey3 = U256::from(5);
724
- // let stake_amount: u64 = 1_000_000_000;
725
- // let lock_amount: u64 = 500;
726
-
727
- // // Add networks root and alpha
728
- // add_network(netuid_0, 1, 0);
729
- // add_network(netuid_1, 1, 0);
714
+ // Setup initial state
715
+ let netuid_0: u16 = 0 ;
716
+ let netuid_1: u16 = 1 ;
717
+ let hotkey1 = U256 :: from ( 1 ) ;
718
+ let hotkey2 = U256 :: from ( 2 ) ;
719
+ let coldkey1 = U256 :: from ( 3 ) ;
720
+ let coldkey2 = U256 :: from ( 4 ) ;
721
+ let coldkey3 = U256 :: from ( 5 ) ;
722
+ let stake_amount: u64 = 1_000_000_000 ;
723
+ let lock_amount: u64 = 500 ;
724
+
725
+ // Add networks root and alpha
726
+ add_network ( netuid_0, 1 , 0 ) ;
727
+ add_network ( netuid_1, 1 , 0 ) ;
730
728
731
- // // Set subnet lock
732
- // SubnetLocked::<Test>::insert(netuid_1, lock_amount);
729
+ // Set subnet lock
730
+ SubnetLocked :: < Test > :: insert ( netuid_1, lock_amount) ;
733
731
734
- // // Add some initial stake
735
- // Owner::<Test>::insert(hotkey1, coldkey1);
736
- // Owner::<Test>::insert(hotkey2, coldkey2);
737
- // Stake::<Test>::insert(hotkey1, coldkey1, stake_amount);
738
- // Stake::<Test>::insert(hotkey1, coldkey2, stake_amount);
739
- // Stake::<Test>::insert(hotkey2, coldkey2, stake_amount);
740
- // Stake::<Test>::insert(hotkey2, coldkey3, stake_amount);
741
-
742
- // // Verify initial conditions
743
- // assert_eq!(SubnetTAO::<Test>::get(netuid_0), 0);
744
- // assert_eq!(SubnetTAO::<Test>::get(netuid_1), 0);
745
- // assert_eq!(SubnetAlphaOut::<Test>::get(netuid_0), 0);
746
- // assert_eq!(SubnetAlphaOut::<Test>::get(netuid_1), 0);
747
- // assert_eq!(SubnetAlphaIn::<Test>::get(netuid_0), 0);
748
- // assert_eq!(SubnetAlphaIn::<Test>::get(netuid_1), 0);
749
- // assert_eq!(TotalHotkeyShares::<Test>::get(hotkey1, netuid_0), 0);
750
- // assert_eq!(TotalHotkeyShares::<Test>::get(hotkey1, netuid_1), 0);
751
- // assert_eq!(TotalHotkeyAlpha::<Test>::get(hotkey1, netuid_0), 0);
752
- // assert_eq!(TotalHotkeyAlpha::<Test>::get(hotkey2, netuid_1), 0);
732
+ // Add some initial stake
733
+ Owner :: < Test > :: insert ( hotkey1, coldkey1) ;
734
+ Owner :: < Test > :: insert ( hotkey2, coldkey2) ;
735
+ Stake :: < Test > :: insert ( hotkey1, coldkey1, stake_amount) ;
736
+ Stake :: < Test > :: insert ( hotkey1, coldkey2, stake_amount) ;
737
+ Stake :: < Test > :: insert ( hotkey2, coldkey2, stake_amount) ;
738
+ Stake :: < Test > :: insert ( hotkey2, coldkey3, stake_amount) ;
739
+
740
+ // Verify initial conditions
741
+ assert_eq ! ( SubnetTAO :: <Test >:: get( netuid_0) , 0 ) ;
742
+ assert_eq ! ( SubnetTAO :: <Test >:: get( netuid_1) , 0 ) ;
743
+ assert_eq ! ( SubnetAlphaOut :: <Test >:: get( netuid_0) , 0 ) ;
744
+ assert_eq ! ( SubnetAlphaOut :: <Test >:: get( netuid_1) , 0 ) ;
745
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid_0) , 0 ) ;
746
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid_1) , 0 ) ;
747
+ assert_eq ! ( TotalHotkeyShares :: <Test >:: get( hotkey1, netuid_0) , 0 ) ;
748
+ assert_eq ! ( TotalHotkeyShares :: <Test >:: get( hotkey1, netuid_1) , 0 ) ;
749
+ assert_eq ! ( TotalHotkeyAlpha :: <Test >:: get( hotkey1, netuid_0) , 0 ) ;
750
+ assert_eq ! ( TotalHotkeyAlpha :: <Test >:: get( hotkey2, netuid_1) , 0 ) ;
753
751
754
- // // Run migration
755
- // crate::migrations::migrate_rao::migrate_rao::<Test>();
756
-
757
- // // Verify root subnet (netuid 0) state after migration
758
- // assert_eq!(SubnetTAO::<Test>::get(netuid_0), 4 * stake_amount); // Root has everything
759
- // assert_eq!(SubnetTAO::<Test>::get(netuid_1), 1 ); // Initial Rao amount.
760
- // assert_eq!(SubnetAlphaIn::<Test>::get(netuid_0), 1); // No Alpha in pool on root.
761
- // assert_eq!(SubnetAlphaIn::<Test>::get(netuid_1), 1); // Initial Rao amount.
762
- // assert_eq!(SubnetAlphaOut::<Test>::get(netuid_0), 4 * stake_amount); // All stake is outstanding.
763
- // assert_eq!(SubnetAlphaOut::<Test>::get(netuid_1), 0); // No stake outstanding.
764
-
765
- // // Assert share information for hotkey1 on netuid_0
766
- // assert_eq!(TotalHotkeyShares::<Test>::get(hotkey1, netuid_0), 2 * stake_amount); // Shares
767
- // // Assert no shares for hotkey1 on netuid_1
768
- // assert_eq!(TotalHotkeyShares::<Test>::get(hotkey1, netuid_1), 0 ); // No shares
769
- // // Assert alpha for hotkey1 on netuid_0
770
- // assert_eq!(TotalHotkeyAlpha::<Test>::get(hotkey1, netuid_0), 2 * stake_amount); // Alpha
771
- // // Assert no alpha for hotkey1 on netuid_1
772
- // assert_eq!(TotalHotkeyAlpha::<Test>::get(hotkey1, netuid_1), 0 ); // No alpha.
773
- // // Assert share information for hotkey2 on netuid_0
774
- // assert_eq!(TotalHotkeyShares::<Test>::get(hotkey2, netuid_0), 2 * stake_amount); // Shares
775
- // // Assert no shares for hotkey2 on netuid_1
776
- // assert_eq!(TotalHotkeyShares::<Test>::get(hotkey2, netuid_1), 0 ); // No shares
777
- // // Assert alpha for hotkey2 on netuid_0
778
- // assert_eq!(TotalHotkeyAlpha::<Test>::get(hotkey2, netuid_0), 2 * stake_amount); // Alpha
779
- // // Assert no alpha for hotkey2 on netuid_1
780
- // assert_eq!(TotalHotkeyAlpha::<Test>::get(hotkey2, netuid_1), 0 ); // No alpha.
781
-
782
- // // Assert stake balances for hotkey1 and coldkey1 on netuid_0
783
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
784
- // &hotkey1,
785
- // &coldkey1,
786
- // netuid_0
787
- // ), stake_amount );
788
- // // Assert stake balances for hotkey1 and coldkey2 on netuid_0
789
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
790
- // &hotkey1,
791
- // &coldkey2,
792
- // netuid_0
793
- // ), stake_amount );
794
- // // Assert stake balances for hotkey2 and coldkey2 on netuid_0
795
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
796
- // &hotkey2,
797
- // &coldkey2,
798
- // netuid_0
799
- // ), stake_amount );
800
- // // Assert stake balances for hotkey2 and coldkey3 on netuid_0
801
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
802
- // &hotkey2,
803
- // &coldkey3,
804
- // netuid_0
805
- // ), stake_amount );
806
- // // Assert total stake for hotkey1 on netuid_0
807
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_on_subnet(
808
- // &hotkey1,
809
- // netuid_0
810
- // ), 2 * stake_amount );
811
- // // Assert total stake for hotkey2 on netuid_0
812
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_on_subnet(
813
- // &hotkey2,
814
- // netuid_0
815
- // ), 2 * stake_amount );
816
- // // Increase stake for hotkey1 and coldkey1 on netuid_0
817
- // SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet(
818
- // &hotkey1,
819
- // &coldkey1,
820
- // netuid_0,
821
- // stake_amount
822
- // );
823
- // // Assert updated stake for hotkey1 and coldkey1 on netuid_0
824
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
825
- // &hotkey1,
826
- // &coldkey1,
827
- // netuid_0
828
- // ), 2 * stake_amount );
829
- // // Assert updated total stake for hotkey1 on netuid_0
830
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_on_subnet(
831
- // &hotkey1,
832
- // netuid_0
833
- // ), 3 * stake_amount );
834
- // // Increase stake for hotkey1 and coldkey1 on netuid_1
835
- // SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet(
836
- // &hotkey1,
837
- // &coldkey1,
838
- // netuid_1,
839
- // stake_amount
840
- // );
841
- // // Assert updated stake for hotkey1 and coldkey1 on netuid_1
842
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
843
- // &hotkey1,
844
- // &coldkey1,
845
- // netuid_1
846
- // ), stake_amount );
847
- // // Assert updated total stake for hotkey1 on netuid_1
848
- // assert_eq!( SubtensorModule::get_stake_for_hotkey_on_subnet(
849
- // &hotkey1,
850
- // netuid_1
851
- // ), stake_amount );
852
-
752
+ // Run migration
753
+ crate :: migrations:: migrate_rao:: migrate_rao :: < Test > ( ) ;
754
+
755
+ // Verify root subnet (netuid 0) state after migration
756
+ assert_eq ! ( SubnetTAO :: <Test >:: get( netuid_0) , 4 * stake_amount) ; // Root has everything
757
+ assert_eq ! ( SubnetTAO :: <Test >:: get( netuid_1) , 100_000_000_000 ) ; // Initial Rao amount.
758
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid_0) , 1 ) ; // No Alpha in pool on root.
759
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid_1) , 100_000_000_000 ) ; // Initial Rao amount.
760
+ assert_eq ! ( SubnetAlphaOut :: <Test >:: get( netuid_0) , 4 * stake_amount) ; // All stake is outstanding.
761
+ assert_eq ! ( SubnetAlphaOut :: <Test >:: get( netuid_1) , 0 ) ; // No stake outstanding.
762
+
763
+ // Assert share information for hotkey1 on netuid_0
764
+ assert_eq ! ( TotalHotkeyShares :: <Test >:: get( hotkey1, netuid_0) , 2 * stake_amount) ; // Shares
765
+ // Assert no shares for hotkey1 on netuid_1
766
+ assert_eq ! ( TotalHotkeyShares :: <Test >:: get( hotkey1, netuid_1) , 0 ) ; // No shares
767
+ // Assert alpha for hotkey1 on netuid_0
768
+ assert_eq ! ( TotalHotkeyAlpha :: <Test >:: get( hotkey1, netuid_0) , 2 * stake_amount) ; // Alpha
769
+ // Assert no alpha for hotkey1 on netuid_1
770
+ assert_eq ! ( TotalHotkeyAlpha :: <Test >:: get( hotkey1, netuid_1) , 0 ) ; // No alpha.
771
+ // Assert share information for hotkey2 on netuid_0
772
+ assert_eq ! ( TotalHotkeyShares :: <Test >:: get( hotkey2, netuid_0) , 2 * stake_amount) ; // Shares
773
+ // Assert no shares for hotkey2 on netuid_1
774
+ assert_eq ! ( TotalHotkeyShares :: <Test >:: get( hotkey2, netuid_1) , 0 ) ; // No shares
775
+ // Assert alpha for hotkey2 on netuid_0
776
+ assert_eq ! ( TotalHotkeyAlpha :: <Test >:: get( hotkey2, netuid_0) , 2 * stake_amount) ; // Alpha
777
+ // Assert no alpha for hotkey2 on netuid_1
778
+ assert_eq ! ( TotalHotkeyAlpha :: <Test >:: get( hotkey2, netuid_1) , 0 ) ; // No alpha.
779
+
780
+ // Assert stake balances for hotkey1 and coldkey1 on netuid_0
781
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
782
+ & hotkey1,
783
+ & coldkey1,
784
+ netuid_0
785
+ ) , stake_amount ) ;
786
+ // Assert stake balances for hotkey1 and coldkey2 on netuid_0
787
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
788
+ & hotkey1,
789
+ & coldkey2,
790
+ netuid_0
791
+ ) , stake_amount ) ;
792
+ // Assert stake balances for hotkey2 and coldkey2 on netuid_0
793
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
794
+ & hotkey2,
795
+ & coldkey2,
796
+ netuid_0
797
+ ) , stake_amount ) ;
798
+ // Assert stake balances for hotkey2 and coldkey3 on netuid_0
799
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
800
+ & hotkey2,
801
+ & coldkey3,
802
+ netuid_0
803
+ ) , stake_amount ) ;
804
+ // Assert total stake for hotkey1 on netuid_0
805
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_on_subnet(
806
+ & hotkey1,
807
+ netuid_0
808
+ ) , 2 * stake_amount ) ;
809
+ // Assert total stake for hotkey2 on netuid_0
810
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_on_subnet(
811
+ & hotkey2,
812
+ netuid_0
813
+ ) , 2 * stake_amount ) ;
814
+ // Increase stake for hotkey1 and coldkey1 on netuid_0
815
+ SubtensorModule :: increase_stake_for_hotkey_and_coldkey_on_subnet (
816
+ & hotkey1,
817
+ & coldkey1,
818
+ netuid_0,
819
+ stake_amount
820
+ ) ;
821
+ // Assert updated stake for hotkey1 and coldkey1 on netuid_0
822
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
823
+ & hotkey1,
824
+ & coldkey1,
825
+ netuid_0
826
+ ) , 2 * stake_amount ) ;
827
+ // Assert updated total stake for hotkey1 on netuid_0
828
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_on_subnet(
829
+ & hotkey1,
830
+ netuid_0
831
+ ) , 3 * stake_amount ) ;
832
+ // Increase stake for hotkey1 and coldkey1 on netuid_1
833
+ SubtensorModule :: increase_stake_for_hotkey_and_coldkey_on_subnet (
834
+ & hotkey1,
835
+ & coldkey1,
836
+ netuid_1,
837
+ stake_amount
838
+ ) ;
839
+ // Assert updated stake for hotkey1 and coldkey1 on netuid_1
840
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
841
+ & hotkey1,
842
+ & coldkey1,
843
+ netuid_1
844
+ ) , stake_amount ) ;
845
+ // Assert updated total stake for hotkey1 on netuid_1
846
+ assert_eq ! ( SubtensorModule :: get_stake_for_hotkey_on_subnet(
847
+ & hotkey1,
848
+ netuid_1
849
+ ) , stake_amount ) ;
853
850
} ) ;
854
851
}
0 commit comments