Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Remove implementation of Randomness for () (#6959)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr authored Aug 26, 2020
1 parent 0a391e4 commit 8e2319f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions frame/society/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -99,7 +100,7 @@ impl pallet_balances::Trait for Test {
impl Trait for Test {
type Event = ();
type Currency = pallet_balances::Module<Self>;
type Randomness = ();
type Randomness = TestRandomness;
type CandidateDeposit = CandidateDeposit;
type WrongSideDeduction = WrongSideDeduction;
type MaxStrikes = MaxStrikes;
Expand Down
5 changes: 4 additions & 1 deletion frame/support/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,10 @@ pub trait Randomness<Output> {
}
}

impl<Output: Decode + Default> Randomness<Output> for () {
/// Provides an implementation of [`Randomness`] that should only be used in tests!
pub struct TestRandomness;

impl<Output: Decode + Default> Randomness<Output> for TestRandomness {
fn random(subject: &[u8]) -> Output {
Output::decode(&mut TrailingZeroInput::new(subject)).unwrap_or_default()
}
Expand Down

0 comments on commit 8e2319f

Please sign in to comment.