Skip to content

Commit 31091c0

Browse files
committed
Implement Staking Reward Eras basics (#1589)
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
1 parent dbbebd8 commit 31091c0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use super::mock::*;
2+
use crate::{
3+
tests::testing_utils::{run_to_block, system_run_to_block},
4+
Config, CurrentEraInfo, Error, Event, RewardEraInfo,
5+
};
6+
7+
use frame_support::traits::Get;
8+
9+
#[test]
10+
fn start_new_era_if_needed() {
11+
new_test_ext().execute_with(|| {
12+
CurrentEraInfo::<Test>::set(RewardEraInfo { current_era: 1, era_start: 0 });
13+
system_run_to_block(9);
14+
run_to_block(10);
15+
let mut current_era_info = CurrentEraInfo::<Test>::get();
16+
assert_eq!(current_era_info.current_era, 2u32);
17+
assert_eq!(current_era_info.era_start, 10u32);
18+
19+
system_run_to_block(19);
20+
run_to_block(20);
21+
current_era_info = CurrentEraInfo::<Test>::get();
22+
assert_eq!(current_era_info.current_era, 3u32);
23+
assert_eq!(current_era_info.era_start, 20u32);
24+
})
25+
}

0 commit comments

Comments
 (0)