From c6d653ffc86cff3d2fd55245219e21044f08a418 Mon Sep 17 00:00:00 2001 From: Zeke Mostov Date: Tue, 8 Mar 2022 12:31:20 +0000 Subject: [PATCH] election provider support: Update some test only types (#10983) --- .../election-provider-support/src/lib.rs | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/substrate/frame/election-provider-support/src/lib.rs b/substrate/frame/election-provider-support/src/lib.rs index 26efe5107b..ca22e30938 100644 --- a/substrate/frame/election-provider-support/src/lib.rs +++ b/substrate/frame/election-provider-support/src/lib.rs @@ -262,33 +262,6 @@ pub trait ElectionDataProvider { fn clear() {} } -/// An election data provider that should only be used for testing. -#[cfg(feature = "std")] -pub struct TestDataProvider(sp_std::marker::PhantomData); - -#[cfg(feature = "std")] -impl ElectionDataProvider for TestDataProvider<(AccountId, BlockNumber)> { - type AccountId = AccountId; - type BlockNumber = BlockNumber; - type MaxVotesPerVoter = (); - - fn targets(_maybe_max_len: Option) -> data_provider::Result> { - Ok(Default::default()) - } - - fn voters(_maybe_max_len: Option) -> data_provider::Result>> { - Ok(Default::default()) - } - - fn desired_targets() -> data_provider::Result { - Ok(Default::default()) - } - - fn next_election_prediction(now: BlockNumber) -> BlockNumber { - now - } -} - /// Something that can compute the result of an election and pass it back to the caller. /// /// This trait only provides an interface to _request_ an election, i.e. @@ -340,11 +313,15 @@ pub trait InstantElectionProvider: ElectionProvider { pub struct NoElection(sp_std::marker::PhantomData); #[cfg(feature = "std")] -impl ElectionProvider for NoElection<(AccountId, BlockNumber)> { +impl ElectionProvider + for NoElection<(AccountId, BlockNumber, DataProvider)> +where + DataProvider: ElectionDataProvider, +{ type AccountId = AccountId; type BlockNumber = BlockNumber; type Error = &'static str; - type DataProvider = TestDataProvider<(AccountId, BlockNumber)>; + type DataProvider = DataProvider; fn elect() -> Result, Self::Error> { Err(" cannot do anything.")