From 919c98dddddfe62ee7a3a281d91d9016df88d023 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Wed, 14 Apr 2021 10:13:15 +0200 Subject: [PATCH] simplify --- frame/election-provider-multi-phase/src/unsigned.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 81d7dd2e0e968..e4c64a2dcb74c 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -1035,27 +1035,24 @@ mod tests { let (mut voters, mut assignments) = voters_and_assignments(); let compact = make_compact_from(voters.clone(), assignments.clone()); let encoded_len = compact.encode().len() as u32; - let voter_count = voters.len(); + let count = assignments.len(); let min_stake_voter = voters.iter() .map(|(id, weight, _)| (weight, id)) .min() .map(|(_, id)| *id) .unwrap(); - // test precondition - assert_eq!(voter_count, compact.voter_count()); // when MultiPhase::sort_by_decreasing_stake(&mut voters, &mut assignments); MultiPhase::trim_assignments_length(encoded_len - 1, &mut assignments); // then + assert_eq!(assignments.len(), count - 1, "we must have removed exactly one assignment"); assert!( assignments.iter() .all(|Assignment{ who, ..}| *who != min_stake_voter), "min_stake_voter must no longer be in the set of voters", ); - let compact = make_compact_from(voters, assignments); - assert_eq!(compact.voter_count(), voter_count - 1, "we must have removed exactly 1 voter"); }); }