mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 15:27:57 +00:00
Contracts: Ensure latest migration match pallet_version (#14676)
* Add version check * fix format * simplify * restructure imports * add version check * Fix benchmarking * Rename migrations -> BenchMigrations * doc * add more docs * fix format string * Update frame/contracts/build.rs * fix * add cargo:rerun-if-changed --------- Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
// This file is part of Substrate.
|
||||
mod pallet_dummy;
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
@@ -16,6 +15,8 @@ mod pallet_dummy;
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
mod pallet_dummy;
|
||||
|
||||
use self::test_utils::{ensure_stored, expected_deposit, hash};
|
||||
use crate::{
|
||||
self as pallet_contracts,
|
||||
@@ -24,13 +25,14 @@ use crate::{
|
||||
Result as ExtensionResult, RetVal, ReturnFlags, SysConfig,
|
||||
},
|
||||
exec::{Frame, Key},
|
||||
migration::codegen::LATEST_MIGRATION_VERSION,
|
||||
storage::DeletionQueueManager,
|
||||
tests::test_utils::{get_contract, get_contract_checked},
|
||||
wasm::{Determinism, ReturnCode as RuntimeReturnCode},
|
||||
weights::WeightInfo,
|
||||
BalanceOf, Code, CodeHash, CodeInfoOf, CollectEvents, Config, ContractInfo, ContractInfoOf,
|
||||
DebugInfo, DefaultAddressGenerator, DeletionQueueCounter, Error, MigrationInProgress,
|
||||
NoopMigration, Origin, Pallet, PristineCode, Schedule,
|
||||
DebugInfo, DefaultAddressGenerator, DeletionQueueCounter, Error, MigrationInProgress, Origin,
|
||||
Pallet, PristineCode, Schedule,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use codec::Encode;
|
||||
@@ -457,7 +459,7 @@ impl Config for Test {
|
||||
type MaxStorageKeyLen = ConstU32<128>;
|
||||
type UnsafeUnstableInterface = UnstableInterface;
|
||||
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
|
||||
type Migrations = (NoopMigration<1>, NoopMigration<2>);
|
||||
type Migrations = crate::migration::codegen::BenchMigrations;
|
||||
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
|
||||
type MaxDelegateDependencies = MaxDelegateDependencies;
|
||||
}
|
||||
@@ -610,17 +612,20 @@ fn calling_plain_account_fails() {
|
||||
fn migration_on_idle_hooks_works() {
|
||||
// Defines expectations of how many migration steps can be done given the weight limit.
|
||||
let tests = [
|
||||
(Weight::zero(), 0),
|
||||
(<Test as Config>::WeightInfo::migrate() + 1.into(), 1),
|
||||
(Weight::MAX, 2),
|
||||
(Weight::zero(), LATEST_MIGRATION_VERSION - 2),
|
||||
(<Test as Config>::WeightInfo::migrate() + 1.into(), LATEST_MIGRATION_VERSION - 1),
|
||||
(Weight::MAX, LATEST_MIGRATION_VERSION),
|
||||
];
|
||||
|
||||
for (weight, expected_version) in tests {
|
||||
ExtBuilder::default().set_storage_version(0).build().execute_with(|| {
|
||||
MigrationInProgress::<Test>::set(Some(Default::default()));
|
||||
Contracts::on_idle(System::block_number(), weight);
|
||||
assert_eq!(StorageVersion::get::<Pallet<Test>>(), expected_version);
|
||||
});
|
||||
ExtBuilder::default()
|
||||
.set_storage_version(LATEST_MIGRATION_VERSION - 2)
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
MigrationInProgress::<Test>::set(Some(Default::default()));
|
||||
Contracts::on_idle(System::block_number(), weight);
|
||||
assert_eq!(StorageVersion::get::<Pallet<Test>>(), expected_version);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user