Fixing by cu computation adding more tests to check by CU (#311)

* Fixing by cu computation adding more tests to check by CU

* Adding more tests
This commit is contained in:
galactus 2024-02-01 14:56:37 +01:00 committed by GitHub
parent 118f5435e3
commit 36458aefe7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -45,7 +45,7 @@ pub fn calculate_supp_percentiles(
let dist_fee_by_cu = (0..=100)
.step_by(p_step)
.map(|p| {
if agg < (cu_sum * p) / 100 {
while agg < (cu_sum * p) / 100 {
index += 1;
agg += prio_fees_in_block[index].1;
}
@ -157,6 +157,8 @@ mod tests {
let supp_info = calculate_supp_percentiles(&prio_fees_in_block);
assert_eq!(supp_info.by_tx[5], 43);
assert_eq!(supp_info.by_tx_percentiles[5], 0.25);
assert_eq!(supp_info.by_cu_percentiles[20], 1.0);
assert_eq!(supp_info.by_cu[20], 72);
}
#[test]
@ -179,6 +181,10 @@ mod tests {
assert_eq!(supp_info.by_tx_percentiles[4], 0.20);
assert_eq!(supp_info.by_tx[5], 5);
assert_eq!(supp_info.by_cu_percentiles[19], 0.95);
assert_eq!(supp_info.by_cu_percentiles[20], 1.0);
assert_eq!(supp_info.by_cu[19], 10);
assert_eq!(supp_info.by_cu[20], 10);
}
#[test]