Make sure that on_before_session_ending is called (#3487)

* Make sure that `on_before_session_ending` is called

* Move the call above the validtor set being set

* Bump spec_version
This commit is contained in:
Bastian Köcher
2019-08-27 11:57:35 +02:00
committed by GitHub
parent 5b8ebf7baf
commit 10b032bb0d
3 changed files with 45 additions and 2 deletions
+14
View File
@@ -53,6 +53,8 @@ thread_local! {
pub static SESSION_CHANGED: RefCell<bool> = RefCell::new(false);
pub static TEST_SESSION_CHANGED: RefCell<bool> = RefCell::new(false);
pub static DISABLED: RefCell<bool> = RefCell::new(false);
// Stores if `on_before_session_end` was called
pub static BEFORE_SESSION_END_CALLED: RefCell<bool> = RefCell::new(false);
}
pub struct TestShouldEndSession;
@@ -81,6 +83,9 @@ impl SessionHandler<u64> for TestSessionHandler {
fn on_disabled(_validator_index: usize) {
DISABLED.with(|l| *l.borrow_mut() = true)
}
fn on_before_session_ending() {
BEFORE_SESSION_END_CALLED.with(|b| *b.borrow_mut() = true);
}
}
pub struct TestOnSessionEnding;
@@ -134,8 +139,17 @@ pub fn set_next_validators(next: Vec<u64>) {
NEXT_VALIDATORS.with(|v| *v.borrow_mut() = next);
}
pub fn before_session_end_called() -> bool {
BEFORE_SESSION_END_CALLED.with(|b| *b.borrow())
}
pub fn reset_before_session_end_called() {
BEFORE_SESSION_END_CALLED.with(|b| *b.borrow_mut() = false);
}
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: u32 = 1024;