pallet-session: Migrate the historical part to the new pallet macro (#9878)

* Migrate session-historical to the new pallet macro

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* pallet-session: Migrate the historical part to the new pallet macro

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix staking test runtime

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Update frame/session/src/historical/mod.rs

* Update frame/session/src/historical/mod.rs

* update migration doc

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* use hardcoded prefix for migration v1

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* cargo +nightly-2021-11-08 fmt

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Qinxuan Chen
2021-11-17 15:16:28 +08:00
committed by GitHub
parent 256c35f473
commit 0b224d1b60
8 changed files with 325 additions and 66 deletions
+27
View File
@@ -453,3 +453,30 @@ fn upgrade_keys() {
}
})
}
#[cfg(feature = "historical")]
#[test]
fn test_migration_v1() {
use crate::{
historical::{HistoricalSessions, StoredRange},
mock::Historical,
};
use frame_support::traits::PalletInfoAccess;
new_test_ext().execute_with(|| {
assert!(<HistoricalSessions<Test>>::iter_values().count() > 0);
assert!(<StoredRange<Test>>::exists());
let old_pallet = "Session";
let new_pallet = <Historical as PalletInfoAccess>::name();
frame_support::storage::migration::move_pallet(
new_pallet.as_bytes(),
old_pallet.as_bytes(),
);
StorageVersion::new(0).put::<Historical>();
crate::migrations::v1::pre_migrate::<Test, Historical>();
crate::migrations::v1::migrate::<Test, Historical>();
crate::migrations::v1::post_migrate::<Test, Historical>();
});
}