Skip to content

Commit

Permalink
Remove get_hotkey_take from pallet-subtensor::Pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-otf committed Dec 11, 2024
1 parent 8ebb7b7 commit 63cebf1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
11 changes: 0 additions & 11 deletions pallets/subtensor/src/staking/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,6 @@ impl<T: Config> Pallet<T> {
Owner::<T>::get(hotkey)
}

/// Returns the hotkey take.
///
/// # Arguments
/// * `hotkey` - The hotkey account ID.
///
/// # Returns
/// The take value of the hotkey.
pub fn get_hotkey_take(hotkey: &T::AccountId) -> u16 {
Delegates::<T>::get(hotkey)
}

/// Returns true if the hotkey account has been created.
///
/// # Arguments
Expand Down
34 changes: 17 additions & 17 deletions pallets/subtensor/src/tests/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,7 @@ fn test_delegate_take_can_be_decreased() {
SubtensorModule::get_min_delegate_take()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);

Expand Down Expand Up @@ -1744,7 +1744,7 @@ fn test_can_set_min_take_ok() {
SubtensorModule::get_min_delegate_take()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);
});
Expand Down Expand Up @@ -1773,7 +1773,7 @@ fn test_delegate_take_can_not_be_increased_with_decrease_take() {
SubtensorModule::get_min_delegate_take()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);

Expand All @@ -1787,7 +1787,7 @@ fn test_delegate_take_can_not_be_increased_with_decrease_take() {
Err(Error::<Test>::DelegateTakeTooLow.into())
);
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);
});
Expand Down Expand Up @@ -1816,7 +1816,7 @@ fn test_delegate_take_can_be_increased() {
SubtensorModule::get_min_delegate_take()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);

Expand All @@ -1828,7 +1828,7 @@ fn test_delegate_take_can_be_increased() {
hotkey0,
u16::MAX / 8
));
assert_eq!(SubtensorModule::get_hotkey_take(&hotkey0), u16::MAX / 8);
assert_eq!(Delegates::<Test>::get(&hotkey0), u16::MAX / 8);
});
}

Expand All @@ -1855,7 +1855,7 @@ fn test_delegate_take_can_not_be_decreased_with_increase_take() {
SubtensorModule::get_min_delegate_take()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);

Expand All @@ -1869,7 +1869,7 @@ fn test_delegate_take_can_not_be_decreased_with_increase_take() {
Err(Error::<Test>::DelegateTakeTooLow.into())
);
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);
});
Expand Down Expand Up @@ -1898,7 +1898,7 @@ fn test_delegate_take_can_be_increased_to_limit() {
SubtensorModule::get_min_delegate_take()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);

Expand All @@ -1911,7 +1911,7 @@ fn test_delegate_take_can_be_increased_to_limit() {
InitialDefaultDelegateTake::get()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
InitialDefaultDelegateTake::get()
);
});
Expand All @@ -1932,7 +1932,7 @@ fn test_delegate_take_can_not_be_set_beyond_limit() {
let netuid = 1;
add_network(netuid, 0, 0);
register_ok_neuron(netuid, hotkey0, coldkey0, 124124);
let before = SubtensorModule::get_hotkey_take(&hotkey0);
let before = Delegates::<Test>::get(&hotkey0);

// Coldkey / hotkey 0 attempt to become delegates with take above maximum
// (Disable this check if InitialDefaultDelegateTake is u16::MAX)
Expand All @@ -1946,7 +1946,7 @@ fn test_delegate_take_can_not_be_set_beyond_limit() {
Err(Error::<Test>::DelegateTakeTooHigh.into())
);
}
assert_eq!(SubtensorModule::get_hotkey_take(&hotkey0), before);
assert_eq!(Delegates::<Test>::get(&hotkey0), before);
});
}

Expand All @@ -1973,7 +1973,7 @@ fn test_delegate_take_can_not_be_increased_beyond_limit() {
SubtensorModule::get_min_delegate_take()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);

Expand All @@ -1990,7 +1990,7 @@ fn test_delegate_take_can_not_be_increased_beyond_limit() {
);
}
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);
});
Expand Down Expand Up @@ -2019,7 +2019,7 @@ fn test_rate_limits_enforced_on_increase_take() {
SubtensorModule::get_min_delegate_take()
));
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);

Expand All @@ -2033,7 +2033,7 @@ fn test_rate_limits_enforced_on_increase_take() {
Err(Error::<Test>::DelegateTxRateLimitExceeded.into())
);
assert_eq!(
SubtensorModule::get_hotkey_take(&hotkey0),
Delegates::<Test>::get(&hotkey0),
SubtensorModule::get_min_delegate_take()
);

Expand All @@ -2045,7 +2045,7 @@ fn test_rate_limits_enforced_on_increase_take() {
hotkey0,
u16::MAX / 8
));
assert_eq!(SubtensorModule::get_hotkey_take(&hotkey0), u16::MAX / 8);
assert_eq!(Delegates::<Test>::get(&hotkey0), u16::MAX / 8);
});
}

Expand Down

0 comments on commit 63cebf1

Please sign in to comment.