diff --git a/runtime/common/src/crowdloan/migration.rs b/runtime/common/src/crowdloan/migration.rs index 22851de9c3d2..4a47f3283de3 100644 --- a/runtime/common/src/crowdloan/migration.rs +++ b/runtime/common/src/crowdloan/migration.rs @@ -57,10 +57,12 @@ impl OnRuntimeUpgrade for MigrateToTrackInactiveV2 { #[cfg(feature = "try-runtime")] fn post_upgrade(total: Vec) -> Result<(), sp_runtime::TryRuntimeError> { - let (total, active) = <(BalanceOf, BalanceOf)>::decode(&mut total.as_slice()) - .expect("the state parameter should be something that was generated by pre_upgrade"); - assert_eq!(active - total, CurrencyOf::::active_issuance(), "the total be correct"); - Ok(()) + if let Ok((total, active)) = <(BalanceOf, BalanceOf)>::decode(&mut total.as_slice()) { + ensure!(active - total == CurrencyOf::::active_issuance(), "the total be correct"); + Ok(()) + } else { + Err("the state parameter should be something that was generated by pre_upgrade".into()) + } } } diff --git a/runtime/parachains/src/configuration/migration_ump.rs b/runtime/parachains/src/configuration/migration_ump.rs index 2ffe1391d2e8..bde44841953c 100644 --- a/runtime/parachains/src/configuration/migration_ump.rs +++ b/runtime/parachains/src/configuration/migration_ump.rs @@ -23,7 +23,7 @@ use parity_scale_codec::{Decode, Encode}; pub mod latest { use super::*; - use frame_support::{pallet_prelude::Weight, traits::OnRuntimeUpgrade}; + use frame_support::{ensure, pallet_prelude::Weight, traits::OnRuntimeUpgrade}; /// Force update the UMP limits in the parachain host config. // NOTE: `OnRuntimeUpgrade` does not have a `self`, so everything must be compile time. @@ -99,9 +99,8 @@ pub mod latest { "Last pending HostConfig upgrade:\n\n{:#?}\n", pending.last() ); - assert_eq!( - pending.len(), - old_pending as usize + 1, + ensure!( + pending.len() == old_pending as usize + 1, "There must be a new pending upgrade enqueued" );