Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
assert to ensure in migration post-upgrade
Signed-off-by: muraca <[email protected]>
  • Loading branch information
muraca committed Nov 10, 2023
commit ea52ad0c577420afc72c7c30e253614274fb95e0
15 changes: 9 additions & 6 deletions substrate/frame/assets/src/migration/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ impl<T: Config<I>, I: 'static, A: Get<Vec<(T::AssetId, T::AccountId)>>> OnRuntim
let mut old_assets: Vec<(
T::AssetId,
old::AssetDetails<T::Balance, T::AccountId, DepositBalanceOf<T, I>>,
)> = Decode::decode(&mut old_status.as_slice())
.expect("the state parameter should be something that was generated by pre_upgrade");
)> = Decode::decode(&mut old_status.as_slice()).map_err(|_| {
"the state parameter should be something that was generated by pre_upgrade"
})?;

assert_eq!(
old_assets.len(),
Asset::<T, I>::iter().count(),
ensure!(
old_assets.len() == Asset::<T, I>::iter().count(),
"the number of assets should be the same"
);

Expand All @@ -168,7 +168,10 @@ impl<T: Config<I>, I: 'static, A: Get<Vec<(T::AssetId, T::AccountId)>>> OnRuntim
.map(|(_, b)| *b)
.unwrap_or_else(|| Zero::zero());
asset.inactive = inactive;
assert_eq!(Asset::<T, I>::get(&asset_id), Some(asset));
ensure!(
Asset::<T, I>::get(&asset_id) == Some(asset),
"migrated asset does not match expected inactive value"
);
}

Ok(())
Expand Down