Skip to content

Commit

Permalink
Update sorted_members test
Browse files Browse the repository at this point in the history
  • Loading branch information
raychu86 committed Mar 3, 2024
1 parent 911c3c3 commit 2fdb843
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions ledger/committee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,34 +429,9 @@ mod tests {
println!("sorted_members: {}ms", timer.elapsed().as_millis());
// Check that the members are sorted based on our sorting criteria.
for i in 0..sorted_members.len() - 1 {
let (address1, (stake1, _)) = sorted_members[i];
let (address2, (stake2, _)) = sorted_members[i + 1];
assert!(stake1 >= stake2);
if stake1 == stake2 {
assert!(address1.to_x_coordinate() > address2.to_x_coordinate());
}
}
}

#[test]
fn test_sorted_members_with_equal_stake() {
// Initialize the RNG.
let rng = &mut TestRng::default();
// Sample a committee.
let committee = crate::test_helpers::sample_committee_equal_stake_committee(200, rng);
// Start a timer.
let timer = std::time::Instant::now();
// Sort the members.
let sorted_members = committee.sorted_members().collect::<Vec<_>>();
println!("sorted_members: {}ms", timer.elapsed().as_millis());
// Check that the members are sorted based on our sorting criteria.
for i in 0..sorted_members.len() - 1 {
let (address1, (stake1, _)) = sorted_members[i];
let (address2, (stake2, _)) = sorted_members[i + 1];
assert!(stake1 >= stake2);
if stake1 == stake2 {
assert!(address1.to_x_coordinate() > address2.to_x_coordinate());
}
let (address1, (_, _)) = sorted_members[i];
let (address2, (_, _)) = sorted_members[i + 1];
assert!(address1.to_x_coordinate() > address2.to_x_coordinate());
}
}

Expand Down

0 comments on commit 2fdb843

Please sign in to comment.