add deactivate_epoch_reward_status (#32114)

This commit is contained in:
Jeff Washington (jwash) 2023-06-14 09:46:34 -05:00 committed by GitHub
parent 2968587d42
commit 1fa73e778f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -1824,6 +1824,16 @@ impl Bank {
);
}
#[allow(dead_code)]
/// partitioned reward distribution is complete.
fn deactivate_epoch_reward_status(&mut self) {
assert!(matches!(
self.epoch_reward_status,
EpochRewardStatus::Active(_)
));
self.epoch_reward_status = EpochRewardStatus::Inactive;
}
pub fn byte_limit_for_scans(&self) -> Option<usize> {
self.rc
.accounts

View File

@ -12604,7 +12604,25 @@ fn test_rewards_point_calculation_empty() {
assert!(point_value.is_none());
}
/// Test reward computation at epoch boundary
#[test]
fn test_deactivate_epoch_reward_status() {
let (genesis_config, _mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL);
let mut bank = Bank::new_for_tests(&genesis_config);
let expected_num = 100;
let stake_rewards = (0..expected_num)
.map(|_| StakeReward::new_random())
.collect::<Vec<_>>();
bank.set_epoch_reward_status_active(vec![stake_rewards]);
assert!(bank.get_reward_interval() == RewardInterval::InsideInterval);
bank.deactivate_epoch_reward_status();
assert!(bank.get_reward_interval() == RewardInterval::OutsideInterval);
}
/// Test rewards compuation and partitioned rewards distribution at the epoch boundary
#[test]
fn test_rewards_computation() {
solana_logger::setup();