Fixup some wrong dependencies (#12899)

* Fixup some wrong dependencies

Dev dependencies should not appear in the feature list. If features are required, they should be
directly enabled for the `dev-dependency`.

* More fixups

* Fix fix

* Remove deprecated feature

* Make all work properly and nice!!

* FMT

* Fix formatting
This commit is contained in:
Bastian Köcher
2022-12-13 22:47:51 +01:00
committed by GitHub
parent 962580c82e
commit c0c8d6305f
17 changed files with 119 additions and 77 deletions
+29 -27
View File
@@ -359,25 +359,26 @@ impl<T: Config<I>, I: 'static> SortedListProvider<T::AccountId> for Pallet<T, I>
List::<T, I>::unsafe_clear()
}
#[cfg(feature = "runtime-benchmarks")]
fn score_update_worst_case(who: &T::AccountId, is_increase: bool) -> Self::Score {
use frame_support::traits::Get as _;
let thresholds = T::BagThresholds::get();
let node = list::Node::<T, I>::get(who).unwrap();
let current_bag_idx = thresholds
.iter()
.chain(sp_std::iter::once(&T::Score::max_value()))
.position(|w| w == &node.bag_upper())
.unwrap();
frame_election_provider_support::runtime_benchmarks_enabled! {
fn score_update_worst_case(who: &T::AccountId, is_increase: bool) -> Self::Score {
use frame_support::traits::Get as _;
let thresholds = T::BagThresholds::get();
let node = list::Node::<T, I>::get(who).unwrap();
let current_bag_idx = thresholds
.iter()
.chain(sp_std::iter::once(&T::Score::max_value()))
.position(|w| w == &node.bag_upper)
.unwrap();
if is_increase {
let next_threshold_idx = current_bag_idx + 1;
assert!(thresholds.len() > next_threshold_idx);
thresholds[next_threshold_idx]
} else {
assert!(current_bag_idx != 0);
let prev_threshold_idx = current_bag_idx - 1;
thresholds[prev_threshold_idx]
if is_increase {
let next_threshold_idx = current_bag_idx + 1;
assert!(thresholds.len() > next_threshold_idx);
thresholds[next_threshold_idx]
} else {
assert!(current_bag_idx != 0);
let prev_threshold_idx = current_bag_idx - 1;
thresholds[prev_threshold_idx]
}
}
}
}
@@ -389,14 +390,15 @@ impl<T: Config<I>, I: 'static> ScoreProvider<T::AccountId> for Pallet<T, I> {
Node::<T, I>::get(id).map(|node| node.score()).unwrap_or_default()
}
#[cfg(any(feature = "runtime-benchmarks", feature = "fuzz", test))]
fn set_score_of(id: &T::AccountId, new_score: T::Score) {
ListNodes::<T, I>::mutate(id, |maybe_node| {
if let Some(node) = maybe_node.as_mut() {
node.set_score(new_score)
} else {
panic!("trying to mutate {:?} which does not exists", id);
}
})
frame_election_provider_support::runtime_benchmarks_or_fuzz_enabled! {
fn set_score_of(id: &T::AccountId, new_score: T::Score) {
ListNodes::<T, I>::mutate(id, |maybe_node| {
if let Some(node) = maybe_node.as_mut() {
node.score = new_score;
} else {
panic!("trying to mutate {:?} which does not exists", id);
}
})
}
}
}