Skip to content

Commit

Permalink
Comment on not getting the exact target number of mandates in test_ra…
Browse files Browse the repository at this point in the history
…nd_dist
  • Loading branch information
birchmd committed Apr 18, 2024
1 parent d68f018 commit 5326630
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/primitives/src/validator_mandates/compute_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ mod tests {
let target_mandates_per_shard = stakes.len();
let config = ValidatorMandatesConfig::new(target_mandates_per_shard, num_shards);
let price = compute_mandate_price(config, &stakes);
// In this case it was not possible to find a seat price that exactly results
// in the target number of mandates. This is simply due to the discrete nature
// of the problem. But the algorithm still gets very close (3 out of 1000 is
// 0.3% off the target).
assert_eq!(count_whole_mandates(&stakes, price), target_mandates_per_shard + 3);

let target_mandates_per_shard = 2 * stakes.len();
Expand Down

0 comments on commit 5326630

Please sign in to comment.