Preimage: Check that at least one is upgraded (#1648)

Sanity check.
This commit is contained in:
Gavin Wood
2023-09-20 15:28:28 +01:00
committed by GitHub
parent 1517eb8dd4
commit bb792af268
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -216,7 +216,7 @@ benchmarks! {
}
ensure_updated {
let n in 0..MAX_HASH_UPGRADE_BULK_COUNT;
let n in 1..MAX_HASH_UPGRADE_BULK_COUNT;
let caller = funded_account::<T>();
let hashes = (0..n).map(|i| insert_old_unrequested::<T>(i)).collect::<Vec<_>>();
+3
View File
@@ -156,6 +156,8 @@ pub mod pallet {
NotRequested,
/// More than `MAX_HASH_UPGRADE_BULK_COUNT` hashes were requested to be upgraded at once.
TooMany,
/// Too few hashes were requested to be upgraded (i.e. zero).
TooFew,
}
/// A reason for this pallet placing a hold on funds.
@@ -242,6 +244,7 @@ pub mod pallet {
hashes: Vec<T::Hash>,
) -> DispatchResultWithPostInfo {
ensure_signed(origin)?;
ensure!(hashes.len() > 0, Error::<T>::TooFew);
ensure!(hashes.len() <= MAX_HASH_UPGRADE_BULK_COUNT as usize, Error::<T>::TooMany);
let updated = hashes.iter().map(Self::do_ensure_updated).filter(|b| *b).count() as u32;