From 8e2319f4ff88614ffdf38a86de7c846cc7b03ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 26 Aug 2020 09:05:49 +0200 Subject: [PATCH] Remove implementation of `Randomness for ()` (#6959) --- frame/society/src/mock.rs | 5 +++-- frame/support/src/traits.rs | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index f29dbc8cb17ad..1ca828bf37196 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -20,7 +20,8 @@ use super::*; use frame_support::{ - impl_outer_origin, parameter_types, ord_parameter_types, traits::{OnInitialize, OnFinalize} + impl_outer_origin, parameter_types, ord_parameter_types, + traits::{OnInitialize, OnFinalize, TestRandomness}, }; use sp_core::H256; use sp_runtime::{ @@ -99,7 +100,7 @@ impl pallet_balances::Trait for Test { impl Trait for Test { type Event = (); type Currency = pallet_balances::Module; - type Randomness = (); + type Randomness = TestRandomness; type CandidateDeposit = CandidateDeposit; type WrongSideDeduction = WrongSideDeduction; type MaxStrikes = MaxStrikes; diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 72a3850d2d37e..6f50f38a23369 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -1345,7 +1345,10 @@ pub trait Randomness { } } -impl Randomness for () { +/// Provides an implementation of [`Randomness`] that should only be used in tests! +pub struct TestRandomness; + +impl Randomness for TestRandomness { fn random(subject: &[u8]) -> Output { Output::decode(&mut TrailingZeroInput::new(subject)).unwrap_or_default() }