add deactivate_epoch_reward_status (#32114)
This commit is contained in:
parent
2968587d42
commit
1fa73e778f
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue