Skip to content

Commit

Permalink
Uses stable u64::next_multiple_of() (solana-labs#33549)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo committed Oct 6, 2023
1 parent 973df82 commit c8d545c
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions core/tests/epoch_accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ fn test_background_services_request_handling_for_epoch_accounts_hash() {
// Based on the EAH start and snapshot interval, pick a slot to mass-root all the banks in
// this range such that an EAH request will be sent and also a snapshot request.
let eah_start_slot = epoch_accounts_hash_utils::calculation_start(&bank);
let set_root_slot = next_multiple_of(eah_start_slot, FULL_SNAPSHOT_INTERVAL);
let set_root_slot = eah_start_slot.next_multiple_of(FULL_SNAPSHOT_INTERVAL);

if bank.block_height() == set_root_slot {
info!("Calling set_root() on bank {}...", bank.slot());
Expand Down Expand Up @@ -661,16 +661,3 @@ fn test_epoch_accounts_hash_and_warping() {
.wait_get_epoch_accounts_hash();
info!("Waiting for epoch accounts hash... DONE");
}

// Copy the impl of `next_multiple_of` since it is nightly-only experimental.
// https://doc.rust-lang.org/std/primitive.u64.html#method.next_multiple_of
// https://github.com/rust-lang/rust/issues/88581
// https://github.com/rust-lang/rust/pull/88582
// https://github.com/jhpratt/rust/blob/727a4fc7e3f836938dfeb4a2ab237cfca612222d/library/core/src/num/uint_macros.rs#L1811-L1837
const fn next_multiple_of(lhs: u64, rhs: u64) -> u64 {
#![allow(clippy::arithmetic_side_effects)]
match lhs % rhs {
0 => lhs,
r => lhs + (rhs - r),
}
}

0 comments on commit c8d545c

Please sign in to comment.