Skip to content

Commit

Permalink
Implement Staking Reward Eras basics (#1589)
Browse files Browse the repository at this point in the history
Implement the basic functionality of tracking and rotating Reward Era. Closes #1567
Does not include anything to do with the Reward Pool.

- [x] Chain spec updated
- [x] Design doc(s) updated
- [x] Tests added
  • Loading branch information
shannonwells committed Dec 11, 2023
1 parent 0e6afd1 commit 756ffe0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pallets/capacity/src/tests/eras_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use super::mock::*;
use crate::{
tests::testing_utils::{run_to_block, system_run_to_block},
Config, CurrentEraInfo, Error, Event, RewardEraInfo,
};

use frame_support::traits::Get;

#[test]
fn start_new_era_if_needed() {
new_test_ext().execute_with(|| {
CurrentEraInfo::<Test>::set(RewardEraInfo { current_era: 1, era_start: 0 });
system_run_to_block(9);
run_to_block(10);
let mut current_era_info = CurrentEraInfo::<Test>::get();
assert_eq!(current_era_info.current_era, 2u32);
assert_eq!(current_era_info.era_start, 10u32);

system_run_to_block(19);
run_to_block(20);
current_era_info = CurrentEraInfo::<Test>::get();
assert_eq!(current_era_info.current_era, 3u32);
assert_eq!(current_era_info.era_start, 20u32);
})
}

0 comments on commit 756ffe0

Please sign in to comment.