Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix State Trie Migration Benchmarks (#11502)
Browse files Browse the repository at this point in the history
* enable signed migrations in benchmarks

* T instead of Test

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Remove 'mut'

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

Co-authored-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
shawntabrizi and ggwpez authored May 23, 2022
1 parent 6386eea commit 3a4f965
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions frame/state-trie-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,8 @@ mod benchmarks {
// function.
let null = MigrationLimits::default();
let caller = frame_benchmarking::whitelisted_caller();
// Allow signed migrations.
SignedMigrationMaxLimits::<T>::put(MigrationLimits { size: 1024, item: 5 });
}: _(frame_system::RawOrigin::Signed(caller), null, 0, StateTrieMigration::<T>::migration_process())
verify {
assert_eq!(StateTrieMigration::<T>::migration_process(), Default::default())
Expand Down Expand Up @@ -1146,14 +1148,7 @@ mod mock {
}

sp_tracing::try_init_simple();
let mut ext: sp_io::TestExternalities = (custom_storage, version).into();

// set some genesis values for this pallet as well.
ext.execute_with(|| {
SignedMigrationMaxLimits::<Test>::put(MigrationLimits { size: 1024, item: 5 });
});

ext
(custom_storage, version).into()
}

pub(crate) fn run_to_block(n: u32) -> (H256, u64) {
Expand Down Expand Up @@ -1292,6 +1287,9 @@ mod test {
new_test_ext(StateVersion::V0, true, None, None).execute_with(|| {
assert_eq!(MigrationProcess::<Test>::get(), Default::default());

// Allow signed migrations.
SignedMigrationMaxLimits::<Test>::put(MigrationLimits { size: 1024, item: 5 });

// can't submit if limit is too high.
frame_support::assert_err!(
StateTrieMigration::continue_migrate(
Expand Down

0 comments on commit 3a4f965

Please sign in to comment.