authorities stored based on the session hash map

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky
2025-06-11 22:56:48 +03:00
parent a00eec9bb9
commit e73f3855fd
6 changed files with 161 additions and 51 deletions

View File

@@ -16,7 +16,6 @@ use sp_staking::{
SessionIndex,
};
#[cfg(feature = "runtime-benchmarks")]
use sp_runtime::BuildStorage;
use crate as slow_clap;
@@ -231,12 +230,33 @@ pub fn advance_session() {
let now = System::block_number().max(1);
System::set_block_number(now + 1);
Session::rotate_session();
let session_index = Session::current_index();
let authorities = Session::validators()
.into_iter()
.map(UintAuthorityId)
.collect();
SlowClap::set_test_authorities(authorities);
assert_eq!(Session::current_index(), (now / Period::get()) as u32);
SlowClap::set_test_authorities(session_index, authorities);
assert_eq!(session_index, (now / Period::get()) as u32);
}
pub fn advance_session_with_authority(authority: u64) {
let now = System::block_number().max(1);
System::set_block_number(now + 1);
Session::rotate_session();
let session_index = Session::current_index();
SlowClap::set_test_authorities(
session_index,
vec![
UintAuthorityId::from(authority),
UintAuthorityId::from(69),
UintAuthorityId::from(420),
UintAuthorityId::from(1337),
]
);
assert_eq!(session_index, (now / Period::get()) as u32);
}