Implement iter for doublemap (#5504)

* implement iter for doublemap

* fmt

* fix tests

* fix staking mock

* address comment

* update doc and constraint for reversible hasher

Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
thiolliere
2020-04-15 16:49:08 +02:00
committed by GitHub
parent 24fc051c86
commit 28edcbfe8d
7 changed files with 187 additions and 67 deletions
+1 -1
View File
@@ -528,7 +528,7 @@ fn check_ledgers() {
fn check_exposures() {
// a check per validator to ensure the exposure struct is always sane.
let era = active_era();
ErasStakers::<Test>::iter_prefix(era).for_each(|expo| {
ErasStakers::<Test>::iter_prefix_values(era).for_each(|expo| {
assert_eq!(
expo.total as u128,
expo.own as u128 + expo.others.iter().map(|e| e.value as u128).sum::<u128>(),
+2 -2
View File
@@ -340,7 +340,7 @@ fn less_than_needed_candidates_works() {
// But the exposure is updated in a simple way. No external votes exists.
// This is purely self-vote.
assert!(
ErasStakers::<Test>::iter_prefix(Staking::active_era().unwrap().index)
ErasStakers::<Test>::iter_prefix_values(Staking::active_era().unwrap().index)
.all(|exposure| exposure.others.is_empty())
);
});
@@ -461,7 +461,7 @@ fn nominating_and_rewards_should_work() {
// ------ check the staked value of all parties.
// 30 and 40 are not chosen anymore
assert_eq!(ErasStakers::<Test>::iter_prefix(Staking::active_era().unwrap().index).count(), 2);
assert_eq!(ErasStakers::<Test>::iter_prefix_values(Staking::active_era().unwrap().index).count(), 2);
assert_eq!(
Staking::eras_stakers(Staking::active_era().unwrap().index, 11),
Exposure {