1
- mod mock;
1
+ use super :: mock:: * ;
2
+ use crate :: * ;
2
3
use std:: collections:: BTreeMap ;
3
-
4
- use crate :: mock:: * ;
5
- use pallet_subtensor:: * ;
6
4
use sp_core:: U256 ;
7
5
use substrate_fixed:: types:: I96F32 ;
8
6
@@ -1051,7 +1049,7 @@ fn test_basic_emission_distribution_scenario() {
1051
1049
1052
1050
// Set up stakes and delegations
1053
1051
add_network ( netuid, tempo, 0 ) ;
1054
- pallet_subtensor :: ChildkeyTake :: < Test > :: insert ( hotkey, netuid, 16384 ) ; // 25% childkey take
1052
+ ChildkeyTake :: < Test > :: insert ( hotkey, netuid, 16384 ) ; // 25% childkey take
1055
1053
SubtensorModule :: stake_into_subnet ( & parent1, & coldkey, netuid, 500 ) ;
1056
1054
SubtensorModule :: stake_into_subnet ( & parent2, & coldkey, netuid, 500 ) ;
1057
1055
ParentKeys :: < Test > :: insert (
@@ -1122,12 +1120,12 @@ fn test_hotkey_take_calculation_scenario() {
1122
1120
let mining_emission = 0 ;
1123
1121
1124
1122
step_block ( 1000 ) ; // should be past stake adding block by 2 tempos
1125
- LastAddStakeIncrease :: < Test > :: insert ( hotkey, coldkey, 1 ) ;
1123
+ // LastAddStakeIncrease::<Test>::insert(hotkey, coldkey, 1);
1126
1124
ParentKeys :: < Test > :: insert ( hotkey, netuid, vec ! [ ( 1000 , parent) ] ) ;
1127
1125
1128
1126
// Test with different childkey take values
1129
1127
for & take in & [ 0 , 16384 , 32768 , 49152 , 65535 ] {
1130
- pallet_subtensor :: ChildkeyTake :: < Test > :: insert ( hotkey, netuid, take) ;
1128
+ crate :: ChildkeyTake :: < Test > :: insert ( hotkey, netuid, take) ;
1131
1129
SubtensorModule :: stake_into_subnet ( & parent, & coldkey, netuid, u64:: MAX ) ;
1132
1130
ParentKeys :: < Test > :: insert ( hotkey, netuid, vec ! [ ( u64 :: MAX , parent) ] ) ;
1133
1131
@@ -1896,43 +1894,43 @@ fn test_basic_emission() {
1896
1894
1897
1895
// Starting point
1898
1896
let validator_alpha_before: u64 =
1899
- pallet_subtensor :: Alpha :: < Test > :: get ( ( validator, netuid, coldkey_validator) ) ;
1897
+ crate :: Alpha :: < Test > :: get ( ( validator, netuid, coldkey_validator) ) ;
1900
1898
let miner_alpha_before: u64 =
1901
- pallet_subtensor :: Alpha :: < Test > :: get ( ( miner, netuid, coldkey_miner) ) ;
1899
+ crate :: Alpha :: < Test > :: get ( ( miner, netuid, coldkey_miner) ) ;
1902
1900
1903
1901
// Run run_coinbase until PendingHotkeyEmission are populated
1904
- while pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: < Test > :: get ( validator, netuid) == 0 {
1902
+ while crate :: PendingHotkeyEmissionOnNetuid :: < Test > :: get ( validator, netuid) == 0 {
1905
1903
step_block ( 1 ) ;
1906
1904
}
1907
1905
1908
1906
assert ! (
1909
- pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( validator, netuid)
1907
+ crate :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( validator, netuid)
1910
1908
> 1_000_000_000 ,
1911
1909
"Validator should have received pending emission"
1912
1910
) ;
1913
1911
assert_eq ! (
1914
- pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( miner, netuid) ,
1912
+ crate :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( miner, netuid) ,
1915
1913
0 ,
1916
1914
"Miner should not have received pending emission"
1917
1915
) ;
1918
1916
1919
1917
// Prevent further subnet epochs
1920
- pallet_subtensor :: Tempo :: < Test > :: set ( netuid, u16:: MAX ) ;
1918
+ crate :: Tempo :: < Test > :: set ( netuid, u16:: MAX ) ;
1921
1919
1922
1920
// Run run_coinbase until PendingHotkeyEmission is drained
1923
1921
step_block ( ( hotkey_tempo * 10 ) as u16 ) ;
1924
1922
1925
1923
// Check emission distribution
1926
- let owner_emission = pallet_subtensor :: Alpha :: < Test > :: get ( (
1924
+ let owner_emission = crate :: Alpha :: < Test > :: get ( (
1927
1925
subnet_owner_hotkey,
1928
1926
netuid,
1929
1927
subnet_owner_coldkey,
1930
1928
) ) ;
1931
1929
let validator_emission: u64 =
1932
- pallet_subtensor :: Alpha :: < Test > :: get ( ( validator, netuid, coldkey_validator) )
1930
+ crate :: Alpha :: < Test > :: get ( ( validator, netuid, coldkey_validator) )
1933
1931
- validator_alpha_before;
1934
1932
let miner_emission: u64 =
1935
- pallet_subtensor :: Alpha :: < Test > :: get ( ( miner, netuid, coldkey_miner) )
1933
+ crate :: Alpha :: < Test > :: get ( ( miner, netuid, coldkey_miner) )
1936
1934
- miner_alpha_before;
1937
1935
1938
1936
assert ! (
@@ -1981,43 +1979,43 @@ fn test_basic_emission_reverse_order() {
1981
1979
1982
1980
// Starting point
1983
1981
let validator_alpha_before: u64 =
1984
- pallet_subtensor :: Alpha :: < Test > :: get ( ( validator, netuid, coldkey_validator) ) ;
1982
+ crate :: Alpha :: < Test > :: get ( ( validator, netuid, coldkey_validator) ) ;
1985
1983
let miner_alpha_before: u64 =
1986
- pallet_subtensor :: Alpha :: < Test > :: get ( ( miner, netuid, coldkey_miner) ) ;
1984
+ crate :: Alpha :: < Test > :: get ( ( miner, netuid, coldkey_miner) ) ;
1987
1985
1988
1986
// Run run_coinbase until PendingHotkeyEmission are populated
1989
- while pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: < Test > :: get ( validator, netuid) == 0 {
1987
+ while crate :: PendingHotkeyEmissionOnNetuid :: < Test > :: get ( validator, netuid) == 0 {
1990
1988
step_block ( 1 ) ;
1991
1989
}
1992
1990
1993
1991
assert ! (
1994
- pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( validator, netuid)
1992
+ crate :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( validator, netuid)
1995
1993
> 1_000_000_000 ,
1996
1994
"Validator should have received pending emission"
1997
1995
) ;
1998
1996
assert_eq ! (
1999
- pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( miner, netuid) ,
1997
+ crate :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( miner, netuid) ,
2000
1998
0 ,
2001
1999
"Miner should not have received pending emission"
2002
2000
) ;
2003
2001
2004
2002
// Prevent further subnet epochs
2005
- pallet_subtensor :: Tempo :: < Test > :: set ( netuid, u16:: MAX ) ;
2003
+ crate :: Tempo :: < Test > :: set ( netuid, u16:: MAX ) ;
2006
2004
2007
2005
// Run run_coinbase until PendingHotkeyEmission is drained
2008
2006
step_block ( ( hotkey_tempo * 10 ) as u16 ) ;
2009
2007
2010
2008
// Check emission distribution
2011
- let owner_emission = pallet_subtensor :: Alpha :: < Test > :: get ( (
2009
+ let owner_emission = crate :: Alpha :: < Test > :: get ( (
2012
2010
subnet_owner_hotkey,
2013
2011
netuid,
2014
2012
subnet_owner_coldkey,
2015
2013
) ) ;
2016
2014
let validator_emission: u64 =
2017
- pallet_subtensor :: Alpha :: < Test > :: get ( ( validator, netuid, coldkey_validator) )
2015
+ crate :: Alpha :: < Test > :: get ( ( validator, netuid, coldkey_validator) )
2018
2016
- validator_alpha_before;
2019
2017
let miner_emission: u64 =
2020
- pallet_subtensor :: Alpha :: < Test > :: get ( ( miner, netuid, coldkey_miner) )
2018
+ crate :: Alpha :: < Test > :: get ( ( miner, netuid, coldkey_miner) )
2021
2019
- miner_alpha_before;
2022
2020
2023
2021
assert ! (
@@ -2068,14 +2066,14 @@ fn test_basic_emission_two_validators() {
2068
2066
2069
2067
// Starting point
2070
2068
let validator1_alpha_before: u64 =
2071
- pallet_subtensor :: Alpha :: < Test > :: get ( ( validator1_hotkey, netuid, validator1_coldkey) ) ;
2069
+ crate :: Alpha :: < Test > :: get ( ( validator1_hotkey, netuid, validator1_coldkey) ) ;
2072
2070
let validator2_alpha_before: u64 =
2073
- pallet_subtensor :: Alpha :: < Test > :: get ( ( validator2_hotkey, netuid, validator2_coldkey) ) ;
2071
+ crate :: Alpha :: < Test > :: get ( ( validator2_hotkey, netuid, validator2_coldkey) ) ;
2074
2072
let miner_alpha_before: u64 =
2075
- pallet_subtensor :: Alpha :: < Test > :: get ( ( miner_hotkey, netuid, miner_coldkey) ) ;
2073
+ crate :: Alpha :: < Test > :: get ( ( miner_hotkey, netuid, miner_coldkey) ) ;
2076
2074
2077
2075
// Run run_coinbase until PendingHotkeyEmission are populated
2078
- while pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: < Test > :: get (
2076
+ while crate :: PendingHotkeyEmissionOnNetuid :: < Test > :: get (
2079
2077
validator1_hotkey,
2080
2078
netuid,
2081
2079
) == 0
@@ -2084,17 +2082,17 @@ fn test_basic_emission_two_validators() {
2084
2082
}
2085
2083
2086
2084
assert ! (
2087
- pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( validator1_hotkey, netuid)
2085
+ crate :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( validator1_hotkey, netuid)
2088
2086
> 1_000_000_000 ,
2089
2087
"Validator 1 should have received pending emission"
2090
2088
) ;
2091
2089
assert ! (
2092
- pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( validator2_hotkey, netuid)
2090
+ crate :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( validator2_hotkey, netuid)
2093
2091
> 1_000_000_000 ,
2094
2092
"validator 2 should have received pending emission"
2095
2093
) ;
2096
2094
assert ! (
2097
- pallet_subtensor :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( miner_hotkey, netuid) == 0 ,
2095
+ crate :: PendingHotkeyEmissionOnNetuid :: <Test >:: get( miner_hotkey, netuid) == 0 ,
2098
2096
"Miner should NOT have received pending emission"
2099
2097
) ;
2100
2098
@@ -2103,13 +2101,13 @@ fn test_basic_emission_two_validators() {
2103
2101
2104
2102
// Check emission distribution
2105
2103
let validator1_emission: u64 =
2106
- pallet_subtensor :: Alpha :: < Test > :: get ( ( validator1_hotkey, validator1_coldkey , netuid ) )
2104
+ crate :: Alpha :: < Test > :: get ( ( validator1_hotkey, netuid , validator1_coldkey ) )
2107
2105
- validator1_alpha_before;
2108
2106
let validator2_emission: u64 =
2109
- pallet_subtensor :: Alpha :: < Test > :: get ( ( validator2_hotkey, validator2_coldkey , netuid ) )
2107
+ crate :: Alpha :: < Test > :: get ( ( validator2_hotkey, netuid , validator2_coldkey ) )
2110
2108
- validator2_alpha_before;
2111
2109
let miner_emission: u64 =
2112
- pallet_subtensor :: Alpha :: < Test > :: get ( ( miner_hotkey, netuid, miner_coldkey) )
2110
+ crate :: Alpha :: < Test > :: get ( ( miner_hotkey, netuid, miner_coldkey) )
2113
2111
- miner_alpha_before;
2114
2112
2115
2113
assert ! (
0 commit comments