add an upgrade_keys method for pallet-session (#7688)

* add an upgrade_keys method for pallet-session

* test the upgrade_keys function
This commit is contained in:
Robert Habermeier
2020-12-08 12:13:21 -06:00
committed by GitHub
parent 29d7e0e6c1
commit 4689c21069
3 changed files with 169 additions and 0 deletions
+25
View File
@@ -40,6 +40,31 @@ impl From<UintAuthorityId> for MockSessionKeys {
}
}
pub const KEY_ID_A: KeyTypeId = KeyTypeId([4; 4]);
pub const KEY_ID_B: KeyTypeId = KeyTypeId([9; 4]);
#[derive(Debug, Clone, codec::Encode, codec::Decode, PartialEq, Eq)]
pub struct PreUpgradeMockSessionKeys {
pub a: [u8; 32],
pub b: [u8; 64],
}
impl OpaqueKeys for PreUpgradeMockSessionKeys {
type KeyTypeIdProviders = ();
fn key_ids() -> &'static [KeyTypeId] {
&[KEY_ID_A, KEY_ID_B]
}
fn get_raw(&self, i: KeyTypeId) -> &[u8] {
match i {
i if i == KEY_ID_A => &self.a[..],
i if i == KEY_ID_B => &self.b[..],
_ => &[],
}
}
}
impl_outer_origin! {
pub enum Origin for Test where system = frame_system {}
}