11// This file is part of Substrate.
2- mod pallet_dummy;
32
43// Copyright (C) Parity Technologies (UK) Ltd.
54// SPDX-License-Identifier: Apache-2.0
@@ -16,6 +15,8 @@ mod pallet_dummy;
1615// See the License for the specific language governing permissions and
1716// limitations under the License.
1817
18+ mod pallet_dummy;
19+
1920use self :: test_utils:: { ensure_stored, expected_deposit, hash} ;
2021use crate :: {
2122 self as pallet_contracts,
@@ -24,13 +25,14 @@ use crate::{
2425 Result as ExtensionResult , RetVal , ReturnFlags , SysConfig ,
2526 } ,
2627 exec:: { Frame , Key } ,
28+ migration:: codegen:: LATEST_MIGRATION_VERSION ,
2729 storage:: DeletionQueueManager ,
2830 tests:: test_utils:: { get_contract, get_contract_checked} ,
2931 wasm:: { Determinism , ReturnCode as RuntimeReturnCode } ,
3032 weights:: WeightInfo ,
3133 BalanceOf , Code , CodeHash , CodeInfoOf , CollectEvents , Config , ContractInfo , ContractInfoOf ,
32- DebugInfo , DefaultAddressGenerator , DeletionQueueCounter , Error , MigrationInProgress ,
33- NoopMigration , Origin , Pallet , PristineCode , Schedule ,
34+ DebugInfo , DefaultAddressGenerator , DeletionQueueCounter , Error , MigrationInProgress , Origin ,
35+ Pallet , PristineCode , Schedule ,
3436} ;
3537use assert_matches:: assert_matches;
3638use codec:: Encode ;
@@ -457,7 +459,7 @@ impl Config for Test {
457459 type MaxStorageKeyLen = ConstU32 < 128 > ;
458460 type UnsafeUnstableInterface = UnstableInterface ;
459461 type MaxDebugBufferLen = ConstU32 < { 2 * 1024 * 1024 } > ;
460- type Migrations = ( NoopMigration < 1 > , NoopMigration < 2 > ) ;
462+ type Migrations = crate :: migration :: codegen :: BenchMigrations ;
461463 type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent ;
462464 type MaxDelegateDependencies = MaxDelegateDependencies ;
463465}
@@ -610,17 +612,20 @@ fn calling_plain_account_fails() {
610612fn migration_on_idle_hooks_works ( ) {
611613 // Defines expectations of how many migration steps can be done given the weight limit.
612614 let tests = [
613- ( Weight :: zero ( ) , 0 ) ,
614- ( <Test as Config >:: WeightInfo :: migrate ( ) + 1 . into ( ) , 1 ) ,
615- ( Weight :: MAX , 2 ) ,
615+ ( Weight :: zero ( ) , LATEST_MIGRATION_VERSION - 2 ) ,
616+ ( <Test as Config >:: WeightInfo :: migrate ( ) + 1 . into ( ) , LATEST_MIGRATION_VERSION - 1 ) ,
617+ ( Weight :: MAX , LATEST_MIGRATION_VERSION ) ,
616618 ] ;
617619
618620 for ( weight, expected_version) in tests {
619- ExtBuilder :: default ( ) . set_storage_version ( 0 ) . build ( ) . execute_with ( || {
620- MigrationInProgress :: < Test > :: set ( Some ( Default :: default ( ) ) ) ;
621- Contracts :: on_idle ( System :: block_number ( ) , weight) ;
622- assert_eq ! ( StorageVersion :: get:: <Pallet <Test >>( ) , expected_version) ;
623- } ) ;
621+ ExtBuilder :: default ( )
622+ . set_storage_version ( LATEST_MIGRATION_VERSION - 2 )
623+ . build ( )
624+ . execute_with ( || {
625+ MigrationInProgress :: < Test > :: set ( Some ( Default :: default ( ) ) ) ;
626+ Contracts :: on_idle ( System :: block_number ( ) , weight) ;
627+ assert_eq ! ( StorageVersion :: get:: <Pallet <Test >>( ) , expected_version) ;
628+ } ) ;
624629 }
625630}
626631
0 commit comments