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

Commit 06982f6

Browse files
committed
Fix tests
1 parent 4e9061b commit 06982f6

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

frame/election-provider-multi-phase/src/benchmarking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,6 @@ frame_benchmarking::benchmarks! {
494494

495495
impl_benchmark_test_suite!(
496496
MultiPhase,
497-
crate::mock::ExtBuilder::default().build(),
497+
crate::mock::ExtBuilder::default().build_offchainify(10).0,
498498
crate::mock::Runtime,
499499
);

frame/election-provider-multi-phase/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ pub mod pallet {
913913

914914
// Note: we don't `rotate_round` at this point; the next call to
915915
// `ElectionProvider::elect` will succeed and take care of that.
916-
916+
917917
let solution = ReadySolution {
918918
supports,
919919
score: [0, 0, 0],

frame/election-provider-multi-phase/src/mock.rs

+26
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,32 @@ impl ElectionDataProvider<AccountId, u64> for StakingMock {
438438
Targets::set(targets);
439439
Voters::set(voters);
440440
}
441+
442+
#[cfg(any(feature = "runtime-benchmarks", test))]
443+
fn clear() {
444+
Targets::set(vec![]);
445+
Voters::set(vec![]);
446+
}
447+
448+
#[cfg(any(feature = "runtime-benchmarks", test))]
449+
fn add_voter(voter: AccountId, weight: VoteWeight, targets: Vec<AccountId>) {
450+
let mut current = Voters::get();
451+
current.push((voter, weight, targets));
452+
Voters::set(current);
453+
}
454+
455+
#[cfg(any(feature = "runtime-benchmarks", test))]
456+
fn add_target(target: AccountId) {
457+
let mut current = Targets::get();
458+
current.push(target);
459+
Targets::set(current);
460+
461+
// to be on-par with staking, we add a self vote as well. the stake is really not that
462+
// important.
463+
let mut current = Voters::get();
464+
current.push((target, ExistentialDeposit::get() as u64, vec![target]));
465+
Voters::set(current);
466+
}
441467
}
442468

443469
impl ExtBuilder {

0 commit comments

Comments
 (0)