diff --git a/unknown-tokens/Cargo.toml b/unknown-tokens/Cargo.toml index 383778f55..bbacff904 100644 --- a/unknown-tokens/Cargo.toml +++ b/unknown-tokens/Cargo.toml @@ -24,6 +24,7 @@ orml-xcm-support = { path = "../xcm-support", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" } +hex-literal = "0.3.1" [features] default = ["std"] diff --git a/unknown-tokens/src/migrations.rs b/unknown-tokens/src/migrations.rs index 69a4fa309..9c866d30c 100644 --- a/unknown-tokens/src/migrations.rs +++ b/unknown-tokens/src/migrations.rs @@ -31,7 +31,9 @@ mod v2 { weight.saturating_accrue(T::DbWeight::get().reads(1)); - let old_data = storage_iter::(module_prefix, storage_prefix).drain(); + let old_data = storage_iter::(module_prefix, storage_prefix) + .drain() + .collect::>(); for (raw_k, value) in old_data { let mut full_key = Vec::new(); @@ -59,7 +61,7 @@ mod v2 { let old_data = storage_iter::(module_prefix, storage_prefix) .drain() - .collect::>(); + .collect::>(); for (raw_k, value) in old_data { let mut full_key = Vec::new(); diff --git a/unknown-tokens/src/tests.rs b/unknown-tokens/src/tests.rs index 45d699ddb..66d573cc6 100644 --- a/unknown-tokens/src/tests.rs +++ b/unknown-tokens/src/tests.rs @@ -7,7 +7,10 @@ use mock::*; use frame_support::{ assert_err, assert_ok, - storage::migration::{get_storage_value, put_storage_value}, + storage::{ + migration::{get_storage_value, put_storage_value}, + unhashed::put_raw, + }, traits::OnRuntimeUpgrade, }; @@ -250,3 +253,12 @@ fn from_unversioned_to_v2_storage() { assert_eq!(crate::Migration::::on_runtime_upgrade(), Weight::zero()); }); } + +#[test] +fn migrate_should_not_panic() { + ExtBuilder.build().execute_with(|| { + put_raw(&hex_literal::hex!["8d4649c9ee31ba6b2d10c66f5fcc252e76391a415c3fca956dccff701fe02e98082b3a7e1c0db7de23c07c6f14cc6c51000100411f728d113b5f9fee983dba4cbb22827c05000106080081"], &hex_literal::hex!["0b2493d4010000000000000000000000"]); + + crate::Migration::::on_runtime_upgrade(); + }); +}