Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Merge remote-tracking branch 'origin/master' into HEAD
  • Loading branch information
gui1117 committed Mar 27, 2020
commit e9578005bc65967dae486f11cc3ebdf0bbe9629c
5 changes: 3 additions & 2 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,9 @@ use sp_std::{
};
use codec::{HasCompact, Encode, Decode};
use frame_support::{
decl_module, decl_event, decl_storage, ensure, decl_error, weights::SimpleDispatchInfo,
dispatch::DispatchResult,
decl_module, decl_event, decl_storage, ensure, decl_error, debug,
weights::{SimpleDispatchInfo, Weight},
dispatch::{IsSubType, DispatchResult},
traits::{
Currency, LockIdentifier, LockableCurrency, WithdrawReasons, OnUnbalanced, Imbalance, Get,
UnixTime, EstimateNextNewSession,
Expand Down
21 changes: 13 additions & 8 deletions frame/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ use sp_runtime::testing::{Header, UintAuthorityId, TestXt};
use sp_staking::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}};
use sp_core::H256;
use frame_support::{
assert_ok, impl_outer_origin, parameter_types, StorageValue, StorageMap, StorageDoubleMap,
traits::{Currency, Get, FindAuthor, OnFinalize, OnInitialize}, weights::Weight,
assert_ok, impl_outer_origin, parameter_types, impl_outer_dispatch, impl_outer_event,
StorageValue, StorageMap, StorageDoubleMap,
traits::{Currency, Get, FindAuthor, OnFinalize, OnInitialize},
weights::Weight,
};
use frame_system::offchain::TransactionSubmitter;
use sp_io;
use sp_phragmen::{
build_support_map, evaluate_support, reduce, ExtendedBalance, StakedAssignment, PhragmenScore,
};
use crate::{
EraIndex, GenesisConfig, Module, Trait, StakerStatus, ValidatorPrefs, RewardDestination,
Expand Down Expand Up @@ -512,12 +519,10 @@ pub fn check_exposure(expo: Exposure<AccountId, Balance>) {
pub fn check_nominator_exposure(era: EraIndex, stash: AccountId) {
assert_is_stash(stash);
let mut sum = 0;
ErasStakers::<Test>::iter_prefix_values(era)
.for_each(|exposure| {
exposure.others.iter()
.filter(|i| i.who == stash)
.for_each(|i| sum += i.value)
});
Session::validators()
.iter()
.map(|v| Staking::eras_stakers(era, v))
.for_each(|e| e.others.iter().filter(|i| i.who == stash).for_each(|i| sum += i.value));
let nominator_stake = Staking::slashable_balance_of(&stash);
// a nominator cannot over-spend.
assert!(
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.