Skip to content

Commit 19d9078

Browse files
committed
Change max take to 18% in tests
1 parent 3db6b62 commit 19d9078

File tree

2 files changed

+30
-39
lines changed

2 files changed

+30
-39
lines changed

pallets/subtensor/tests/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ parameter_types! {
123123
pub const InitialBondsMovingAverage: u64 = 900_000;
124124
pub const InitialStakePruningMin: u16 = 0;
125125
pub const InitialFoundationDistribution: u64 = 0;
126-
pub const InitialDefaultTake: u16 = 32_767; // 50% for tests (18% honest number is used in production (see runtime))
126+
pub const InitialDefaultTake: u16 = 11_796; // 18%, same as in production
127127
pub const InitialWeightsVersionKey: u16 = 0;
128128
pub const InitialServingRateLimit: u64 = 0; // No limit.
129129
pub const InitialTxRateLimit: u64 = 0; // Disable rate limit for testing

pallets/subtensor/tests/staking.rs

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,11 +1638,11 @@ fn test_full_with_delegating() {
16381638
Err(Error::<Test>::NonAssociatedColdKey.into())
16391639
);
16401640

1641-
// Lets make this new key a delegate with a 50% take.
1641+
// Lets make this new key a delegate with a 10% take.
16421642
assert_ok!(SubtensorModule::do_become_delegate(
16431643
<<Test as Config>::RuntimeOrigin>::signed(coldkey2),
16441644
hotkey2,
1645-
u16::MAX / 2
1645+
u16::MAX / 10
16461646
));
16471647

16481648
// Add nominate some stake.
@@ -1680,16 +1680,16 @@ fn test_full_with_delegating() {
16801680
SubtensorModule::emit_inflation_through_hotkey_account(&hotkey2, 0, 1000);
16811681
assert_eq!(
16821682
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey2, &hotkey2),
1683-
1_668
1684-
); // 1000 + 500 + 500 * (1000/3000) = 1500 + 166.6666666667 = 1,668
1683+
1_400
1684+
); // 1000 + 100 + 900 * (1000/3000) = 1400
16851685
assert_eq!(
16861686
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey1, &hotkey2),
1687-
1_166
1688-
); // 1000 + 500 * (1000/3000) = 1000 + 166.6666666667 = 1166.6
1687+
1_300
1688+
); // 1000 + 900 * (1000/3000) = 1300
16891689
assert_eq!(
16901690
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey0, &hotkey2),
1691-
1_166
1692-
); // 1000 + 500 * (1000/3000) = 1000 + 166.6666666667 = 1166.6
1691+
1_300
1692+
); // 1000 + 900 * (1000/3000) = 1300
16931693
assert_eq!(SubtensorModule::get_total_stake(), 6_500); // before + 1_000 = 5_500 + 1_000 = 6_500
16941694

16951695
step_block(1);
@@ -1710,7 +1710,7 @@ fn test_full_with_delegating() {
17101710
assert_ok!(SubtensorModule::do_become_delegate(
17111711
<<Test as Config>::RuntimeOrigin>::signed(coldkey3),
17121712
hotkey3,
1713-
u16::MAX / 2
1713+
u16::MAX / 10
17141714
)); // Full take.
17151715
assert_ok!(SubtensorModule::add_stake(
17161716
<<Test as Config>::RuntimeOrigin>::signed(coldkey0),
@@ -1748,20 +1748,20 @@ fn test_full_with_delegating() {
17481748
SubtensorModule::emit_inflation_through_hotkey_account(&hotkey3, 0, 1000);
17491749
assert_eq!(
17501750
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey0, &hotkey3),
1751-
1125
1752-
); // 1000 + 50% * 1000 * 1000/4000 = 1125
1751+
1225
1752+
); // 1000 + 90% * 1000 * 1000/4000 = 1225
17531753
assert_eq!(
17541754
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey1, &hotkey3),
1755-
1125
1756-
); // 1000 + 50% * 1000 * 1000/4000 = 1125
1755+
1225
1756+
); // 1000 + 90% * 1000 * 1000/4000 = 1225
17571757
assert_eq!(
17581758
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey2, &hotkey3),
1759-
1125
1760-
); // 1000 + 50% * 1000 * 1000/4000 = 1125
1759+
1225
1760+
); // 1000 + 90% * 1000 * 1000/4000 = 1225
17611761
assert_eq!(
17621762
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey3, &hotkey3),
1763-
1625
1764-
); // 1000 + 125 * 3 + 1000 * 1000/4000 = 1625
1763+
1325
1764+
); // 1000 + 25 * 3 + 1000 * 1000/4000 = 1325
17651765
assert_eq!(SubtensorModule::get_total_stake(), 11_500); // before + 1_000 = 10_500 + 1_000 = 11_500
17661766
});
17671767
}
@@ -2018,11 +2018,11 @@ fn test_full_with_delegating_some_servers() {
20182018

20192019
assert_eq!(SubtensorModule::get_total_stake(), 5_623); // 4_723 + 900 = 5_623
20202020

2021-
// Lets make this new key a delegate with a 50% take.
2021+
// Lets make this new key a delegate with a 10% take.
20222022
assert_ok!(SubtensorModule::do_become_delegate(
20232023
<<Test as Config>::RuntimeOrigin>::signed(coldkey2),
20242024
hotkey2,
2025-
u16::MAX / 2
2025+
u16::MAX / 10
20262026
));
20272027

20282028
// Add nominate some stake.
@@ -2062,16 +2062,16 @@ fn test_full_with_delegating_some_servers() {
20622062
SubtensorModule::emit_inflation_through_hotkey_account(&hotkey2, 100, 1000);
20632063
assert_eq!(
20642064
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey2, &hotkey2),
2065-
1_768
2066-
); // 1000 + 100 + 500 + 500 * (1000/3000) = 100 + 1500 + 166.6666666667 ~= 1,768.6666666667
2065+
1_500
2066+
); // 1000 + 100 + 100 + 900 * (1000/3000) = 1000 + 200 + 300 = 1500
20672067
assert_eq!(
20682068
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey1, &hotkey2),
2069-
1_166
2070-
); // 1000 + 500 * (1000/3000) = 1000 + 166.6666666667 = 1166.6
2069+
1_300
2070+
); // 1000 + 900 * (1000/3000) = 1000 + 300 = 1300
20712071
assert_eq!(
20722072
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey0, &hotkey2),
2073-
1_166
2074-
); // 1000 + 500 * (1000/3000) = 1000 + 166.6666666667 = 1166.6
2073+
1_300
2074+
); // 1000 + 900 * (1000/3000) = 1000 + 300 = 1300
20752075
assert_eq!(SubtensorModule::get_total_stake(), 8_823); // 7_723 + 1_100 = 8_823
20762076

20772077
// Lets emit MORE inflation through this new key with distributed ownership.
@@ -2081,15 +2081,15 @@ fn test_full_with_delegating_some_servers() {
20812081
SubtensorModule::emit_inflation_through_hotkey_account(&hotkey2, 123, 0);
20822082
assert_eq!(
20832083
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey2, &hotkey2),
2084-
1_891
2085-
); // 1_768 + 123 = 1_891
2084+
1_623
2085+
); // 1_500 + 123 = 1_623
20862086
assert_eq!(
20872087
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey1, &hotkey2),
2088-
1_166
2088+
1_300
20892089
); // No change.
20902090
assert_eq!(
20912091
SubtensorModule::get_stake_for_coldkey_and_hotkey(&coldkey0, &hotkey2),
2092-
1_166
2092+
1_300
20932093
); // No change.
20942094
assert_eq!(SubtensorModule::get_total_stake(), 8_946); // 8_823 + 123 = 8_946
20952095
});
@@ -2701,15 +2701,6 @@ fn test_remove_stake_below_minimum_threshold() {
27012701
})
27022702
}
27032703

2704-
// Verify that InitialDefaultTake is between 50% and u16::MAX-1, this is important for other tests
2705-
#[test]
2706-
fn test_delegate_take_limit() {
2707-
new_test_ext(1).execute_with(|| {
2708-
assert_eq!(InitialDefaultTake::get() >= u16::MAX / 2, true);
2709-
assert_eq!(InitialDefaultTake::get() <= u16::MAX - 1, true);
2710-
});
2711-
}
2712-
27132704
// Verify delegate take can be decreased
27142705
#[test]
27152706
fn test_delegate_take_can_be_decreased() {

0 commit comments

Comments
 (0)