mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 01:45:41 +00:00
Move PalletVersion away from the crate version (#9165)
* Move `PalletVersion` away from the crate version Before this pr, `PalletVersion` was referring to the crate version that hosted the pallet. This pr introduces a custom `package.metadata.frame` section in the `Cargo.toml` that can contain a `pallet-version` key value pair. While the value is expected to be a valid u16. If this key/value pair isn't given, the version is set to 1. It also changes the `PalletVersion` declaration. We now only have one `u16` that represents the version. Not a major/minor/patch version. As the old `PalletVersion` was starting with the `u16` major, decoding the old values will work. * Overhaul the entire implementation - Drop PalletVersion - Introduce StorageVersion - StorageVersion needs to be set in the crate and set for the macros - Added migration * Fix migrations * Review feedback * Remove unneeded dep * remove pub consts * Brings back logging and implements `GetStorageVersion` * Return weight from migration * Fmt and remove unused import * Update frame/support/src/dispatch.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/support/src/traits/metadata.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -323,7 +323,6 @@ pub trait OnTimestampSet<Moment> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::traits::metadata::PalletVersion;
|
||||
|
||||
#[test]
|
||||
fn on_initialize_and_on_runtime_upgrade_weight_merge_works() {
|
||||
@@ -342,18 +341,4 @@ mod tests {
|
||||
assert_eq!(<(Test, Test)>::on_initialize(0), 20);
|
||||
assert_eq!(<(Test, Test)>::on_runtime_upgrade(), 40);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_pallet_version_ordering() {
|
||||
let version = PalletVersion::new(1, 0, 0);
|
||||
assert!(version > PalletVersion::new(0, 1, 2));
|
||||
assert!(version == PalletVersion::new(1, 0, 0));
|
||||
assert!(version < PalletVersion::new(1, 0, 1));
|
||||
assert!(version < PalletVersion::new(1, 1, 0));
|
||||
|
||||
let version = PalletVersion::new(2, 50, 50);
|
||||
assert!(version < PalletVersion::new(2, 50, 51));
|
||||
assert!(version > PalletVersion::new(2, 49, 51));
|
||||
assert!(version < PalletVersion::new(3, 49, 51));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user