Fix bags-list tests execution (#14047)

The `test` feature isn't propagated to dependencies in Rust, so we should just enable the method as
well for `std`.
This commit is contained in:
Bastian Köcher
2023-05-01 09:47:43 +02:00
committed by GitHub
parent 4df004d0d4
commit 9a3555d2e2
3 changed files with 17 additions and 7 deletions
+1 -1
View File
@@ -397,7 +397,7 @@ 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() Node::<T, I>::get(id).map(|node| node.score()).unwrap_or_default()
} }
frame_election_provider_support::runtime_benchmarks_or_fuzz_enabled! { frame_election_provider_support::runtime_benchmarks_fuzz_or_std_enabled! {
fn set_score_of(id: &T::AccountId, new_score: T::Score) { fn set_score_of(id: &T::AccountId, new_score: T::Score) {
ListNodes::<T, I>::mutate(id, |maybe_node| { ListNodes::<T, I>::mutate(id, |maybe_node| {
if let Some(node) = maybe_node.as_mut() { if let Some(node) = maybe_node.as_mut() {
+4 -3
View File
@@ -40,9 +40,10 @@ impl frame_election_provider_support::ScoreProvider<AccountId> for StakingMock {
*NextVoteWeightMap::get().get(id).unwrap_or(&NextVoteWeight::get()) *NextVoteWeightMap::get().get(id).unwrap_or(&NextVoteWeight::get())
} }
#[cfg(any(feature = "runtime-benchmarks", feature = "fuzz", test))] frame_election_provider_support::runtime_benchmarks_fuzz_or_std_enabled! {
fn set_score_of(id: &AccountId, weight: Self::Score) { fn set_score_of(id: &AccountId, weight: Self::Score) {
NEXT_VOTE_WEIGHT_MAP.with(|m| m.borrow_mut().insert(*id, weight)); NEXT_VOTE_WEIGHT_MAP.with(|m| m.borrow_mut().insert(*id, weight));
}
} }
} }
@@ -582,7 +582,7 @@ pub trait ScoreProvider<AccountId> {
fn score(who: &AccountId) -> Self::Score; fn score(who: &AccountId) -> Self::Score;
/// For tests, benchmarks and fuzzing, set the `score`. /// For tests, benchmarks and fuzzing, set the `score`.
#[cfg(any(feature = "runtime-benchmarks", feature = "fuzz", test))] #[cfg(any(feature = "runtime-benchmarks", feature = "fuzz", feature = "std"))]
fn set_score_of(_: &AccountId, _: Self::Score) {} fn set_score_of(_: &AccountId, _: Self::Score) {}
} }
@@ -673,5 +673,14 @@ pub type BoundedSupportsOf<E> = BoundedSupports<
<E as ElectionProviderBase>::MaxWinners, <E as ElectionProviderBase>::MaxWinners,
>; >;
sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(
sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); runtime_benchmarks_enabled,
feature = "runtime-benchmarks",
$
);
sp_core::generate_feature_enabled_macro!(
runtime_benchmarks_fuzz_or_std_enabled,
any(feature = "runtime-benchmarks", feature = "fuzzing", feature = "std"),
$
);