Skip to content

Commit

Permalink
add test for is_partitioned_rewards_feature_enabled (#32158)
Browse files Browse the repository at this point in the history
* add set_partitioned_rewards_enabled_for_test fn

* reveiws

---------

Co-authored-by: HaoranYi <[email protected]>
  • Loading branch information
HaoranYi and HaoranYi authored Jun 16, 2023
1 parent ec9fdbf commit d06b099
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,8 @@ impl Bank {

#[allow(dead_code)]
fn is_partitioned_rewards_feature_enabled(&self) -> bool {
false // Will be feature later. It is convenient to have a constant fn at the moment.
self.feature_set
.is_active(&feature_set::enable_partitioned_epoch_reward::id())
}

#[allow(dead_code)]
Expand Down
11 changes: 11 additions & 0 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12604,6 +12604,17 @@ fn test_rewards_point_calculation_empty() {
assert!(point_value.is_none());
}

/// Test partitioned_reward feature enable/disable
#[test]
fn test_is_partitioned_reward_enable() {
let (genesis_config, _mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL);

let mut bank = Bank::new_for_tests(&genesis_config);
assert!(!bank.is_partitioned_rewards_feature_enabled());
bank.activate_feature(&feature_set::enable_partitioned_epoch_reward::id());
assert!(bank.is_partitioned_rewards_feature_enabled());
}

#[test]
fn test_deactivate_epoch_reward_status() {
let (genesis_config, _mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL);
Expand Down

0 comments on commit d06b099

Please sign in to comment.