-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. # Checklist - [x] Chain spec updated - [x] Design doc(s) updated - [x] Tests added
- Loading branch information
1 parent
f25b57b
commit ae88a01
Showing
5 changed files
with
86 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters