From 540887247643fbafce7d1c7b3f5becc09e6f02d5 Mon Sep 17 00:00:00 2001 From: HaoranYi Date: Mon, 17 Jul 2023 15:37:10 -0500 Subject: [PATCH] test force reward interval end fn (#32513) Co-authored-by: HaoranYi --- runtime/src/bank/tests.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index da023e0ef1e01c..e2ab8aca19e834 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -12430,6 +12430,24 @@ fn test_rewards_point_calculation_empty() { assert!(point_value.is_none()); } +#[test] +fn test_force_reward_interval_end() { + 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::>(); + + bank.set_epoch_reward_status_active(vec![stake_rewards]); + assert!(bank.get_reward_interval() == RewardInterval::InsideInterval); + + bank.force_reward_interval_end_for_tests(); + assert!(bank.get_reward_interval() == RewardInterval::OutsideInterval); +} + #[test] fn test_is_partitioned_reward_feature_enable() { let (genesis_config, _mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL);