Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove migrations #972

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions asset-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ mod mock;
#[cfg(test)]
mod tests;

mod migrations;
pub use migrations::Migration;

#[frame_support::pallet]
pub mod module {
use super::*;
Expand Down
44 changes: 0 additions & 44 deletions asset-registry/src/migrations.rs

This file was deleted.

129 changes: 1 addition & 128 deletions asset-registry/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
use super::*;
use crate as orml_asset_registry;
use crate::tests::para::{AdminAssetTwo, AssetRegistry, CustomMetadata, RuntimeOrigin, Tokens, TreasuryAccount};
use frame_support::{
assert_noop, assert_ok,
storage::migration::{get_storage_value, put_storage_value},
traits::OnRuntimeUpgrade,
StorageHasher,
};
use frame_support::{assert_noop, assert_ok, traits::OnRuntimeUpgrade, StorageHasher};
use mock::{para::RuntimeCall, *};
use orml_traits::MultiCurrency;
use polkadot_parachain_primitives::primitives::Sibling;
Expand Down Expand Up @@ -594,128 +589,6 @@ fn test_v2_to_v3_incompatible_multilocation() {
);
}

#[test]
fn from_unversioned_to_v2_storage() {
TestNet::reset();

ParaA::execute_with(|| {
let module_prefix = b"AssetRegistry";
let storage_prefix = b"LocationToAssetId";

// StorageVersion is 0 before migration
assert_eq!(StorageVersion::get::<Pallet<para::Runtime>>(), 0);

// V2 storage
let old_multilocation_0 = xcm::v2::MultiLocation::new(
0,
xcm::v2::Junctions::X1(xcm::v2::Junction::GeneralKey(vec![0].try_into().unwrap())),
);
let old_multilocation_1 = xcm::v2::MultiLocation::new(
1,
xcm::v2::Junctions::X2(
xcm::v2::Junction::Parachain(2096),
xcm::v2::Junction::GeneralKey(vec![0, 0, 0, 0, 0, 0, 0, 0, 0].try_into().unwrap()),
),
);
let old_multilocation_2 = xcm::v2::MultiLocation::new(
1,
xcm::v2::Junctions::X2(
xcm::v2::Junction::Parachain(2096),
xcm::v2::Junction::GeneralKey(vec![1, 1].try_into().unwrap()),
),
);

let asset_id_0: para::ParaAssetId = 5u32;
let asset_id_1: para::ParaAssetId = 6u32;
let asset_id_2: para::ParaAssetId = 7u32;

// Store raw xcm::v2 data
put_storage_value(
module_prefix,
storage_prefix,
&Twox64Concat::hash(&old_multilocation_0.encode()),
asset_id_0,
);
put_storage_value(
module_prefix,
storage_prefix,
&Twox64Concat::hash(&old_multilocation_1.encode()),
asset_id_1,
);
put_storage_value(
module_prefix,
storage_prefix,
&Twox64Concat::hash(&old_multilocation_2.encode()),
asset_id_2,
);

// V3 storage key
let new_multilocation_0 = MultiLocation::new(0, X1(Junction::from(BoundedVec::try_from(vec![0]).unwrap())));
let new_multilocation_1 = MultiLocation::new(
1,
X2(
Parachain(2096),
Junction::from(BoundedVec::try_from(vec![0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap()),
),
);
let new_multilocation_2 = MultiLocation::new(
1,
X2(
Parachain(2096),
Junction::from(BoundedVec::try_from(vec![1, 1]).unwrap()),
),
);

// Assert new StorageKey still does not exist
assert_eq!(AssetRegistry::location_to_asset_id(new_multilocation_0), None);
assert_eq!(AssetRegistry::location_to_asset_id(new_multilocation_1), None);
assert_eq!(AssetRegistry::location_to_asset_id(new_multilocation_2), None);

// Run StorageKey migration
crate::Migration::<para::Runtime>::on_runtime_upgrade();

// StorageVersion is 2 after migration
assert_eq!(StorageVersion::get::<Pallet<para::Runtime>>(), 2);

// Assert the StorageKey exists and has been migrated to xcm::v3
assert_eq!(
AssetRegistry::location_to_asset_id(new_multilocation_0),
Some(asset_id_0)
);
assert_eq!(
AssetRegistry::location_to_asset_id(new_multilocation_1),
Some(asset_id_1)
);
assert_eq!(
AssetRegistry::location_to_asset_id(new_multilocation_2),
Some(asset_id_2)
);

// Assert the old key does not exist anymore
assert!(get_storage_value::<para::ParaAssetId>(
module_prefix,
storage_prefix,
&Twox64Concat::hash(&old_multilocation_0.encode()),
)
.is_none());
assert!(get_storage_value::<para::ParaAssetId>(
module_prefix,
storage_prefix,
&Twox64Concat::hash(&old_multilocation_1.encode()),
)
.is_none());
assert!(get_storage_value::<para::ParaAssetId>(
module_prefix,
storage_prefix,
&Twox64Concat::hash(&old_multilocation_2.encode()),
)
.is_none());

// Assert further calls are no-op
assert_eq!(crate::Migration::<para::Runtime>::on_runtime_upgrade(), Weight::zero());
});
}

#[test]
fn test_decode_bounded_vec() {
TestNet::reset();
Expand Down
3 changes: 0 additions & 3 deletions unknown-tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ pub use module::*;
mod mock;
mod tests;

mod migrations;
pub use migrations::Migration;

#[frame_support::pallet]
pub mod module {
use super::*;
Expand Down
86 changes: 0 additions & 86 deletions unknown-tokens/src/migrations.rs

This file was deleted.

Loading