Skip to content

Commit

Permalink
Refactor verbose test (#5506)
Browse files Browse the repository at this point in the history
A test is triggering a log error. But is correct and successful. This is
a refactor without triggering the log error.
  • Loading branch information
gui1117 authored Aug 28, 2024
1 parent 9cf5e81 commit 97fa922
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::{
System,
},
};
use codec::Decode;
use frame_support::traits::OnRuntimeUpgrade;
use pallet_migrations::WeightInfo as _;

Expand All @@ -51,10 +52,18 @@ fn lazy_migration_works() {
let mut last_decodable = 0;
for block in 2..=65 {
run_to_block(block);

let mut decodable = 0;
for i in 0..1024 {
if crate::MyMap::<T>::get(i).is_some() {
let key = crate::MyMap::<T>::hashed_key_for(i);
let value =
frame_support::storage::unhashed::get_raw(&key[..]).expect("value exists");

if let Ok(value) = u64::decode(&mut &value[..]) {
assert_eq!(value, i as u64);
decodable += 1;
} else {
assert_eq!(u32::decode(&mut &value[..]).expect("not migrated yet"), i);
}
}

Expand Down

0 comments on commit 97fa922

Please sign in to comment.