1
1
#![ allow( clippy:: indexing_slicing) ]
2
- use crate :: mock:: * ;
2
+ use super :: mock:: * ;
3
3
use frame_support:: { assert_err, assert_noop, assert_ok} ;
4
- mod mock ;
5
- use pallet_subtensor :: { utils:: rate_limiting:: TransactionType , * } ;
4
+
5
+ use crate :: { utils:: rate_limiting:: TransactionType , * } ;
6
6
use sp_core:: U256 ;
7
7
8
8
// 1: Successful setting of a single child
@@ -3461,7 +3461,7 @@ fn test_childkey_take_drain() {
3461
3461
SubtensorModule :: set_weights_set_rate_limit ( netuid, 0 ) ;
3462
3462
SubtensorModule :: set_max_allowed_validators ( netuid, 2 ) ;
3463
3463
step_block ( subnet_tempo) ;
3464
- pallet_subtensor :: SubnetOwnerCut :: < Test > :: set ( 0 ) ;
3464
+ crate :: SubnetOwnerCut :: < Test > :: set ( 0 ) ;
3465
3465
3466
3466
// Set 20% childkey take
3467
3467
let max_take: u16 = 0xFFFF / 5 ;
@@ -3509,15 +3509,15 @@ fn test_childkey_take_drain() {
3509
3509
vec![ ( proportion, child) ]
3510
3510
) ) ;
3511
3511
// Make all stakes viable
3512
- pallet_subtensor :: StakeDeltaSinceLastEmissionDrain :: < Test > :: set ( parent, coldkey, -1 ) ;
3513
- pallet_subtensor :: StakeDeltaSinceLastEmissionDrain :: < Test > :: set ( child, nominator, -1 ) ;
3512
+ crate :: StakeDeltaSinceLastEmissionDrain :: < Test > :: set ( parent, coldkey, -1 ) ;
3513
+ crate :: StakeDeltaSinceLastEmissionDrain :: < Test > :: set ( child, nominator, -1 ) ;
3514
3514
3515
3515
// Setup YUMA so that it creates emissions:
3516
3516
// Parent and child both set weights
3517
3517
// Parent and child register on root and
3518
3518
// Set root weights
3519
- pallet_subtensor :: Weights :: < Test > :: insert ( netuid, 0 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3520
- pallet_subtensor :: Weights :: < Test > :: insert ( netuid, 1 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3519
+ crate :: Weights :: < Test > :: insert ( netuid, 0 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3520
+ crate :: Weights :: < Test > :: insert ( netuid, 1 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3521
3521
assert_ok ! ( SubtensorModule :: do_root_register(
3522
3522
RuntimeOrigin :: signed( coldkey) ,
3523
3523
parent,
@@ -3526,17 +3526,17 @@ fn test_childkey_take_drain() {
3526
3526
RuntimeOrigin :: signed( coldkey) ,
3527
3527
child,
3528
3528
) ) ;
3529
- pallet_subtensor :: Weights :: < Test > :: insert ( root_id, 0 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3530
- pallet_subtensor :: Weights :: < Test > :: insert ( root_id, 1 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3529
+ crate :: Weights :: < Test > :: insert ( root_id, 0 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3530
+ crate :: Weights :: < Test > :: insert ( root_id, 1 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3531
3531
3532
3532
// Run run_coinbase until PendingHotkeyEmission are populated
3533
- while pallet_subtensor :: PendingdHotkeyEmission :: < Test > :: get ( child) == 0 {
3533
+ while crate :: PendingdHotkeyEmission :: < Test > :: get ( child) == 0 {
3534
3534
step_block ( 1 ) ;
3535
3535
}
3536
3536
3537
3537
// Prevent further subnet epochs
3538
- pallet_subtensor :: Tempo :: < Test > :: set ( netuid, u16:: MAX ) ;
3539
- pallet_subtensor :: Tempo :: < Test > :: set ( root_id, u16:: MAX ) ;
3538
+ crate :: Tempo :: < Test > :: set ( netuid, u16:: MAX ) ;
3539
+ crate :: Tempo :: < Test > :: set ( root_id, u16:: MAX ) ;
3540
3540
3541
3541
// Run run_coinbase until PendingHotkeyEmission is drained for both child and parent
3542
3542
step_block ( ( hotkey_tempo * 2 ) as u16 ) ;
@@ -3545,9 +3545,9 @@ fn test_childkey_take_drain() {
3545
3545
// - Child stake increased by its child key take only (20% * 50% = 10% of total emission)
3546
3546
// - Parent stake increased by 40% of total emission
3547
3547
// - Nominator stake increased by 50% of total emission
3548
- let child_emission = pallet_subtensor :: Stake :: < Test > :: get ( child, coldkey) ;
3549
- let parent_emission = pallet_subtensor :: Stake :: < Test > :: get ( parent, coldkey) - stake;
3550
- let nominator_emission = pallet_subtensor :: Stake :: < Test > :: get ( child, nominator) - stake;
3548
+ let child_emission = crate :: Stake :: < Test > :: get ( child, coldkey) ;
3549
+ let parent_emission = crate :: Stake :: < Test > :: get ( parent, coldkey) - stake;
3550
+ let nominator_emission = crate :: Stake :: < Test > :: get ( child, nominator) - stake;
3551
3551
let total_emission = child_emission + parent_emission + nominator_emission;
3552
3552
3553
3553
assert ! ( is_within_tolerance(
@@ -3600,7 +3600,7 @@ fn test_childkey_take_drain_validator_take() {
3600
3600
SubtensorModule :: set_weights_set_rate_limit ( netuid, 0 ) ;
3601
3601
SubtensorModule :: set_max_allowed_validators ( netuid, 2 ) ;
3602
3602
step_block ( subnet_tempo) ;
3603
- pallet_subtensor :: SubnetOwnerCut :: < Test > :: set ( 0 ) ;
3603
+ crate :: SubnetOwnerCut :: < Test > :: set ( 0 ) ;
3604
3604
3605
3605
// Set 20% childkey take
3606
3606
let max_take: u16 = 0xFFFF / 5 ;
@@ -3648,15 +3648,15 @@ fn test_childkey_take_drain_validator_take() {
3648
3648
vec![ ( proportion, child) ]
3649
3649
) ) ;
3650
3650
// Make all stakes viable
3651
- pallet_subtensor :: StakeDeltaSinceLastEmissionDrain :: < Test > :: set ( parent, coldkey, -1 ) ;
3652
- pallet_subtensor :: StakeDeltaSinceLastEmissionDrain :: < Test > :: set ( child, nominator, -1 ) ;
3651
+ crate :: StakeDeltaSinceLastEmissionDrain :: < Test > :: set ( parent, coldkey, -1 ) ;
3652
+ crate :: StakeDeltaSinceLastEmissionDrain :: < Test > :: set ( child, nominator, -1 ) ;
3653
3653
3654
3654
// Setup YUMA so that it creates emissions:
3655
3655
// Parent and child both set weights
3656
3656
// Parent and child register on root and
3657
3657
// Set root weights
3658
- pallet_subtensor :: Weights :: < Test > :: insert ( netuid, 0 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3659
- pallet_subtensor :: Weights :: < Test > :: insert ( netuid, 1 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3658
+ crate :: Weights :: < Test > :: insert ( netuid, 0 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3659
+ crate :: Weights :: < Test > :: insert ( netuid, 1 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3660
3660
assert_ok ! ( SubtensorModule :: do_root_register(
3661
3661
RuntimeOrigin :: signed( coldkey) ,
3662
3662
parent,
@@ -3665,17 +3665,17 @@ fn test_childkey_take_drain_validator_take() {
3665
3665
RuntimeOrigin :: signed( coldkey) ,
3666
3666
child,
3667
3667
) ) ;
3668
- pallet_subtensor :: Weights :: < Test > :: insert ( root_id, 0 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3669
- pallet_subtensor :: Weights :: < Test > :: insert ( root_id, 1 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3668
+ crate :: Weights :: < Test > :: insert ( root_id, 0 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3669
+ crate :: Weights :: < Test > :: insert ( root_id, 1 , vec ! [ ( 0 , 0xFFFF ) , ( 1 , 0xFFFF ) ] ) ;
3670
3670
3671
3671
// Run run_coinbase until PendingHotkeyEmission are populated
3672
- while pallet_subtensor :: PendingdHotkeyEmission :: < Test > :: get ( child) == 0 {
3672
+ while crate :: PendingdHotkeyEmission :: < Test > :: get ( child) == 0 {
3673
3673
step_block ( 1 ) ;
3674
3674
}
3675
3675
3676
3676
// Prevent further subnet epochs
3677
- pallet_subtensor :: Tempo :: < Test > :: set ( netuid, u16:: MAX ) ;
3678
- pallet_subtensor :: Tempo :: < Test > :: set ( root_id, u16:: MAX ) ;
3677
+ crate :: Tempo :: < Test > :: set ( netuid, u16:: MAX ) ;
3678
+ crate :: Tempo :: < Test > :: set ( root_id, u16:: MAX ) ;
3679
3679
3680
3680
// Run run_coinbase until PendingHotkeyEmission is drained for both child and parent
3681
3681
step_block ( ( hotkey_tempo * 2 ) as u16 ) ;
@@ -3684,9 +3684,9 @@ fn test_childkey_take_drain_validator_take() {
3684
3684
// - Child stake increased by its child key take (20% * 50% = 10% of total emission) plus childkey's delegate take (10%)
3685
3685
// - Parent stake increased by 40% of total emission
3686
3686
// - Nominator stake increased by 40% of total emission
3687
- let child_emission = pallet_subtensor :: Stake :: < Test > :: get ( child, coldkey) ;
3688
- let parent_emission = pallet_subtensor :: Stake :: < Test > :: get ( parent, coldkey) - stake;
3689
- let nominator_emission = pallet_subtensor :: Stake :: < Test > :: get ( child, nominator) - stake;
3687
+ let child_emission = crate :: Stake :: < Test > :: get ( child, coldkey) ;
3688
+ let parent_emission = crate :: Stake :: < Test > :: get ( parent, coldkey) - stake;
3689
+ let nominator_emission = crate :: Stake :: < Test > :: get ( child, nominator) - stake;
3690
3690
let total_emission = child_emission + parent_emission + nominator_emission;
3691
3691
3692
3692
assert ! ( is_within_tolerance( child_emission, total_emission / 5 , 500 ) ) ;
0 commit comments