From 085698d0c587d0980932b4388f69997464555827 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 23 May 2022 06:10:23 -0400 Subject: [PATCH] Fix State Trie Migration Benchmarks (#11502) * enable signed migrations in benchmarks * T instead of Test Signed-off-by: Oliver Tale-Yazdi * Remove 'mut' Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi --- frame/state-trie-migration/src/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index d78fd7d9ca932..899250cc3f3c3 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -848,6 +848,8 @@ mod benchmarks { // function. let null = MigrationLimits::default(); let caller = frame_benchmarking::whitelisted_caller(); + // Allow signed migrations. + SignedMigrationMaxLimits::::put(MigrationLimits { size: 1024, item: 5 }); }: _(frame_system::RawOrigin::Signed(caller), null, 0, StateTrieMigration::::migration_process()) verify { assert_eq!(StateTrieMigration::::migration_process(), Default::default()) @@ -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::::put(MigrationLimits { size: 1024, item: 5 }); - }); - - ext + (custom_storage, version).into() } pub(crate) fn run_to_block(n: u32) -> (H256, u64) { @@ -1292,6 +1287,9 @@ mod test { new_test_ext(StateVersion::V0, true, None, None).execute_with(|| { assert_eq!(MigrationProcess::::get(), Default::default()); + // Allow signed migrations. + SignedMigrationMaxLimits::::put(MigrationLimits { size: 1024, item: 5 }); + // can't submit if limit is too high. frame_support::assert_err!( StateTrieMigration::continue_migrate(