mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
Try-runtime proper return types (#7146)
* Try-runtime proper return types
* update
* oops
* use ensure
* update lockfile for {"substrate"}
---------
Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -46,7 +46,7 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactiveV2<T> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
||||
let total = Funds::<T>::iter_values()
|
||||
.map(|item| {
|
||||
CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(item.fund_index))
|
||||
@@ -56,11 +56,13 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactiveV2<T> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(total: Vec<u8>) -> Result<(), &'static str> {
|
||||
let (total, active) = <(BalanceOf<T>, BalanceOf<T>)>::decode(&mut total.as_slice())
|
||||
.expect("the state parameter should be something that was generated by pre_upgrade");
|
||||
assert_eq!(active - total, CurrencyOf::<T>::active_issuance(), "the total be correct");
|
||||
Ok(())
|
||||
fn post_upgrade(total: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
||||
if let Ok((total, active)) = <(BalanceOf<T>, BalanceOf<T>)>::decode(&mut total.as_slice()) {
|
||||
ensure!(active - total == CurrencyOf::<T>::active_issuance(), "the total be correct");
|
||||
Ok(())
|
||||
} else {
|
||||
Err("the state parameter should be something that was generated by pre_upgrade".into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ use sp_std::vec::Vec;
|
||||
pub struct ClearOldSessionStorage<T>(sp_std::marker::PhantomData<T>);
|
||||
impl<T: Config> OnRuntimeUpgrade for ClearOldSessionStorage<T> {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
|
||||
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ impl<T: Config> OnRuntimeUpgrade for ClearOldSessionStorage<T> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user