1
1
// This file is part of Substrate.
2
- mod pallet_dummy;
3
2
4
3
// Copyright (C) Parity Technologies (UK) Ltd.
5
4
// SPDX-License-Identifier: Apache-2.0
@@ -16,6 +15,8 @@ mod pallet_dummy;
16
15
// See the License for the specific language governing permissions and
17
16
// limitations under the License.
18
17
18
+ mod pallet_dummy;
19
+
19
20
use self :: test_utils:: { ensure_stored, expected_deposit, hash} ;
20
21
use crate :: {
21
22
self as pallet_contracts,
@@ -24,13 +25,14 @@ use crate::{
24
25
Result as ExtensionResult , RetVal , ReturnFlags , SysConfig ,
25
26
} ,
26
27
exec:: { Frame , Key } ,
28
+ migration:: codegen:: LATEST_MIGRATION_VERSION ,
27
29
storage:: DeletionQueueManager ,
28
30
tests:: test_utils:: { get_contract, get_contract_checked} ,
29
31
wasm:: { Determinism , ReturnCode as RuntimeReturnCode } ,
30
32
weights:: WeightInfo ,
31
33
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 ,
34
36
} ;
35
37
use assert_matches:: assert_matches;
36
38
use codec:: Encode ;
@@ -457,7 +459,7 @@ impl Config for Test {
457
459
type MaxStorageKeyLen = ConstU32 < 128 > ;
458
460
type UnsafeUnstableInterface = UnstableInterface ;
459
461
type MaxDebugBufferLen = ConstU32 < { 2 * 1024 * 1024 } > ;
460
- type Migrations = ( NoopMigration < 1 > , NoopMigration < 2 > ) ;
462
+ type Migrations = crate :: migration :: codegen :: BenchMigrations ;
461
463
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent ;
462
464
type MaxDelegateDependencies = MaxDelegateDependencies ;
463
465
}
@@ -610,17 +612,20 @@ fn calling_plain_account_fails() {
610
612
fn migration_on_idle_hooks_works ( ) {
611
613
// Defines expectations of how many migration steps can be done given the weight limit.
612
614
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 ) ,
616
618
] ;
617
619
618
620
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
+ } ) ;
624
629
}
625
630
}
626
631
0 commit comments