git.delta.rocks / unique-network / refs/commits / 369a51ded768

difftreelog

Merge pull request #974 from UniqueNetwork/fix/evm-coder-leftovers

Yaroslav Bolyukin2023-08-30parents: #0ce92f0 #c466f2a.patch.diff
in: master

25 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -528,7 +528,7 @@
 				|r: sc_service::Result<
 					up_data_structs::TokenDataVersion1<CrossAccountId>,
 					sp_runtime::DispatchError,
-				>| r.and_then(|value| Ok(value.into())),
+				>| r.map(|value| value.into()),
 			)
 			.or_else(|_| {
 				Ok(api
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -297,7 +297,7 @@
 				default_runtime,
 				// Sudo account
 				get_account_id_from_seed::<sr25519::Public>("Alice"),
-				vec![
+				[
 					(
 						get_account_id_from_seed::<sr25519::Public>("Alice"),
 						get_from_seed::<AuraId>("Alice"),
@@ -371,7 +371,7 @@
 				default_runtime,
 				// Sudo account
 				get_account_id_from_seed::<sr25519::Public>("Alice"),
-				vec![
+				[
 					(
 						get_account_id_from_seed::<sr25519::Public>("Alice"),
 						get_from_seed::<AuraId>("Alice"),
modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -63,7 +63,7 @@
 	}
 	let bytes = id.to_string();
 	let len = data.len();
-	data[len - bytes.len()..].copy_from_slice(&bytes.as_bytes());
+	data[len - bytes.len()..].copy_from_slice(bytes.as_bytes());
 	data
 }
 pub fn property_value() -> PropertyValue {
@@ -80,7 +80,7 @@
 	cast: impl FnOnce(CollectionHandle<T>) -> R,
 ) -> Result<R, DispatchError> {
 	let imbalance = <T as Config>::Currency::deposit(
-		&owner.as_sub(),
+		owner.as_sub(),
 		T::CollectionCreationPrice::get(),
 		Precision::Exact,
 	)?;
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -2420,7 +2420,8 @@
 	}
 }
 
-#[cfg(feature = "tests")]
+#[cfg(any(feature = "tests", test))]
+#[allow(missing_docs)]
 pub mod tests {
 	use crate::{DispatchResult, DispatchError, LazyValue, Config};
 
@@ -2456,7 +2457,7 @@
 	}
 
 	#[rustfmt::skip]
-	pub const table: [TestCase; 16] = [
+	pub const TABLE: [TestCase; 16] = [
 		//                    ┌╴collection_admin
 		//                    │  ┌╴is_collection_admin
 		//                    │  │   ┌╴token_owner
modifiedpallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -286,7 +286,14 @@
 {
 	let call = C::parse_full(input)?;
 	if call.is_none() {
-		return Err("unrecognized selector".into());
+		let selector = if input.len() >= 4 {
+			let mut selector = [0; 4];
+			selector.copy_from_slice(&input[..4]);
+			u32::from_be_bytes(selector)
+		} else {
+			0
+		};
+		return Err(format!("unrecognized selector: 0x{selector:0>8x}").into());
 	}
 	let call = call.unwrap();
 
@@ -329,7 +336,7 @@
 		ERC165Call(ERC165Call, PhantomData<fn() -> T>),
 		OtherCall(ERC165Call),
 
-		#[weight(Weight::from_ref_time(a + b))]
+		#[weight(Weight::from_parts(a + b, 0))]
 		Example {
 			a: u64,
 			b: u64,
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -53,7 +53,7 @@
 		let data = (0..b).map(|i| {
 			bench_init!(to: cross_sub(i););
 			(to, 200)
-		}).collect::<BTreeMap<_, _>>().try_into().unwrap();
+		}).collect::<BTreeMap<_, _>>();
 	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	burn_item {
modifiedpallets/identity/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/identity/src/benchmarking.rs
+++ b/pallets/identity/src/benchmarking.rs
@@ -35,6 +35,7 @@
 //! Identity pallet benchmarking.
 
 #![cfg(feature = "runtime-benchmarks")]
+#![allow(clippy::no_effect)]
 
 use super::*;
 
modifiedpallets/identity/src/tests.rsdiffbeforeafterboth
--- a/pallets/identity/src/tests.rs
+++ b/pallets/identity/src/tests.rs
@@ -67,7 +67,7 @@
 
 parameter_types! {
 	pub BlockWeights: frame_system::limits::BlockWeights =
-		frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024));
+		frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_parts(1024, 0));
 }
 impl frame_system::Config for Test {
 	type BaseCallFilter = frame_support::traits::Everything;
modifiedpallets/identity/src/types.rsdiffbeforeafterboth
--- a/pallets/identity/src/types.rs
+++ b/pallets/identity/src/types.rs
@@ -481,7 +481,7 @@
 		let mut registry = scale_info::Registry::new();
 		let type_id = registry.register_type(&scale_info::meta_type::<Data>());
 		let registry: scale_info::PortableRegistry = registry.into();
-		let type_info = registry.resolve(type_id.id()).unwrap();
+		let type_info = registry.resolve(type_id.id).unwrap();
 
 		let check_type_info = |data: &Data| {
 			let variant_name = match data {
@@ -492,20 +492,20 @@
 				Data::ShaThree256(_) => "ShaThree256".to_string(),
 				Data::Raw(bytes) => format!("Raw{}", bytes.len()),
 			};
-			if let scale_info::TypeDef::Variant(variant) = type_info.type_def() {
+			if let scale_info::TypeDef::Variant(variant) = &type_info.type_def {
 				let variant = variant
-					.variants()
+					.variants
 					.iter()
-					.find(|v| v.name() == &variant_name)
+					.find(|v| v.name == variant_name)
 					.expect(&format!("Expected to find variant {}", variant_name));
 
 				let field_arr_len = variant
-					.fields()
+					.fields
 					.first()
-					.and_then(|f| registry.resolve(f.ty().id()))
+					.and_then(|f| registry.resolve(f.ty.id))
 					.map(|ty| {
-						if let scale_info::TypeDef::Array(arr) = ty.type_def() {
-							arr.len()
+						if let scale_info::TypeDef::Array(arr) = &ty.type_def {
+							arr.len
 						} else {
 							panic!("Should be an array type")
 						}
@@ -513,7 +513,7 @@
 					.unwrap_or(0);
 
 				let encoded = data.encode();
-				assert_eq!(encoded[0], variant.index());
+				assert_eq!(encoded[0], variant.index);
 				assert_eq!(encoded.len() as u32 - 1, field_arr_len);
 			} else {
 				panic!("Should be a variant type")
modifiedpallets/inflation/src/tests.rsdiffbeforeafterboth
--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -78,7 +78,7 @@
 parameter_types! {
 	pub const BlockHashCount: u64 = 250;
 	pub BlockWeights: frame_system::limits::BlockWeights =
-		frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1024));
+		frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0));
 	pub const SS58Prefix: u8 = 42;
 }
 
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -43,12 +43,12 @@
 	owner: T::CrossAccountId,
 ) -> Result<TokenId, DispatchError> {
 	<Pallet<T>>::create_item(
-		&collection,
+		collection,
 		sender,
 		create_max_item_data::<T>(owner),
 		&Unlimited,
 	)?;
-	Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
+	Ok(TokenId(<TokensMinted<T>>::get(collection.id)))
 }
 
 fn create_collection<T: Config>(
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -51,8 +51,8 @@
 	users: impl IntoIterator<Item = (T::CrossAccountId, u128)>,
 ) -> Result<TokenId, DispatchError> {
 	let data: CreateItemData<T> = create_max_item_data::<T>(users);
-	<Pallet<T>>::create_item(&collection, sender, data, &Unlimited)?;
-	Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
+	<Pallet<T>>::create_item(collection, sender, data, &Unlimited)?;
+	Ok(TokenId(<TokensMinted<T>>::get(collection.id)))
 }
 
 fn create_collection<T: Config>(
@@ -104,7 +104,7 @@
 		let data = vec![create_max_item_data::<T>((0..b).map(|u| {
 			bench_init!(to: cross_sub(u););
 			(to, 200)
-		}))].try_into().unwrap();
+		}))];
 	}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?}
 
 	// Other user left, token data is kept
modifiedpallets/scheduler-v2/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/scheduler-v2/src/benchmarking.rs
+++ b/pallets/scheduler-v2/src/benchmarking.rs
@@ -83,11 +83,11 @@
 ///
 /// # Arguments
 /// * `periodic` - makes the task periodic.
-/// 	Sets the task's period and repetition count to `100`.
+///     Sets the task's period and repetition count to `100`.
 /// * `named` - gives a name to the task: `u32_to_name(0)`.
 /// * `signed` - determines the origin of the task.
-/// 	If true, it will have the Signed origin. Otherwise it will have the Root origin.
-/// 	See [`make_origin`] for details.
+///     If true, it will have the Signed origin. Otherwise it will have the Root origin.
+///     See [`make_origin`] for details.
 /// * maybe_lookup_len - sets optional lookup length. It is used to benchmark task fetching from the `Preimages` store.
 /// * priority - the task's priority.
 fn make_task<T: Config>(
@@ -155,12 +155,10 @@
 		}
 		if maybe_lookup_len.is_some() {
 			len += 1;
+		} else if len > 0 {
+			len -= 1;
 		} else {
-			if len > 0 {
-				len -= 1;
-			} else {
-				break c;
-			}
+			break c;
 		}
 	}
 }
modifiedpallets/scheduler-v2/src/mock.rsdiffbeforeafterboth
--- a/pallets/scheduler-v2/src/mock.rs
+++ b/pallets/scheduler-v2/src/mock.rs
@@ -33,6 +33,7 @@
 // limitations under the License.
 
 //! # Scheduler test environment.
+#![allow(deprecated)]
 
 use super::*;
 
@@ -229,6 +230,10 @@
 			r => Err(O::from(r)),
 		})
 	}
+	#[cfg(feature = "runtime-benchmarks")]
+	fn try_successful_origin() -> Result<O, ()> {
+		Ok(O::from(RawOrigin::Root))
+	}
 }
 
 pub struct Executor;
modifiedpallets/scheduler-v2/src/tests.rsdiffbeforeafterboth
before · pallets/scheduler-v2/src/tests.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license:18// This file is part of Substrate.1920// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// 	http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435//! # Scheduler tests.3637use super::*;38use crate::mock::{39	logger, new_test_ext, root, run_to_block, LoggerCall, RuntimeCall, Scheduler, Test, *,40};41use frame_support::{42	assert_noop, assert_ok,43	traits::{Contains, OnInitialize},44	assert_err,45};4647#[test]48fn basic_scheduling_works() {49	new_test_ext().execute_with(|| {50		let call = RuntimeCall::Logger(LoggerCall::log {51			i: 42,52			weight: Weight::from_ref_time(10),53		});54		assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(55			&call56		));57		assert_ok!(Scheduler::do_schedule(58			DispatchTime::At(4),59			None,60			127,61			root(),62			<ScheduledCall<Test>>::new(call).unwrap(),63		));64		run_to_block(3);65		assert!(logger::log().is_empty());66		run_to_block(4);67		assert_eq!(logger::log(), vec![(root(), 42u32)]);68		run_to_block(100);69		assert_eq!(logger::log(), vec![(root(), 42u32)]);70	});71}7273#[test]74fn schedule_after_works() {75	new_test_ext().execute_with(|| {76		run_to_block(2);77		let call = RuntimeCall::Logger(LoggerCall::log {78			i: 42,79			weight: Weight::from_ref_time(10),80		});81		assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(82			&call83		));84		// This will schedule the call 3 blocks after the next block... so block 3 + 3 = 685		assert_ok!(Scheduler::do_schedule(86			DispatchTime::After(3),87			None,88			127,89			root(),90			<ScheduledCall<Test>>::new(call).unwrap(),91		));92		run_to_block(5);93		assert!(logger::log().is_empty());94		run_to_block(6);95		assert_eq!(logger::log(), vec![(root(), 42u32)]);96		run_to_block(100);97		assert_eq!(logger::log(), vec![(root(), 42u32)]);98	});99}100101#[test]102fn schedule_after_zero_works() {103	new_test_ext().execute_with(|| {104		run_to_block(2);105		let call = RuntimeCall::Logger(LoggerCall::log {106			i: 42,107			weight: Weight::from_ref_time(10),108		});109		assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(110			&call111		));112		assert_ok!(Scheduler::do_schedule(113			DispatchTime::After(0),114			None,115			127,116			root(),117			<ScheduledCall<Test>>::new(call).unwrap(),118		));119		// Will trigger on the next block.120		run_to_block(3);121		assert_eq!(logger::log(), vec![(root(), 42u32)]);122		run_to_block(100);123		assert_eq!(logger::log(), vec![(root(), 42u32)]);124	});125}126127#[test]128fn periodic_scheduling_works() {129	new_test_ext().execute_with(|| {130		// at #4, every 3 blocks, 3 times.131		assert_ok!(Scheduler::do_schedule(132			DispatchTime::At(4),133			Some((3, 3)),134			127,135			root(),136			<ScheduledCall<Test>>::new(RuntimeCall::Logger(logger::Call::log {137				i: 42,138				weight: Weight::from_ref_time(10)139			}))140			.unwrap()141		));142		run_to_block(3);143		assert!(logger::log().is_empty());144		run_to_block(4);145		assert_eq!(logger::log(), vec![(root(), 42u32)]);146		run_to_block(6);147		assert_eq!(logger::log(), vec![(root(), 42u32)]);148		run_to_block(7);149		assert_eq!(logger::log(), vec![(root(), 42u32), (root(), 42u32)]);150		run_to_block(9);151		assert_eq!(logger::log(), vec![(root(), 42u32), (root(), 42u32)]);152		run_to_block(10);153		assert_eq!(154			logger::log(),155			vec![(root(), 42u32), (root(), 42u32), (root(), 42u32)]156		);157		run_to_block(100);158		assert_eq!(159			logger::log(),160			vec![(root(), 42u32), (root(), 42u32), (root(), 42u32)]161		);162	});163}164165#[test]166fn cancel_named_scheduling_works_with_normal_cancel() {167	new_test_ext().execute_with(|| {168		// at #4.169		Scheduler::do_schedule_named(170			[1u8; 32],171			DispatchTime::At(4),172			None,173			127,174			root(),175			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {176				i: 69,177				weight: Weight::from_ref_time(10),178			}))179			.unwrap(),180		)181		.unwrap();182		let i = Scheduler::do_schedule(183			DispatchTime::At(4),184			None,185			127,186			root(),187			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {188				i: 42,189				weight: Weight::from_ref_time(10),190			}))191			.unwrap(),192		)193		.unwrap();194		run_to_block(3);195		assert!(logger::log().is_empty());196		assert_ok!(Scheduler::do_cancel_named(None, [1u8; 32]));197		assert_ok!(Scheduler::do_cancel(None, i));198		run_to_block(100);199		assert!(logger::log().is_empty());200	});201}202203#[test]204fn cancel_named_periodic_scheduling_works() {205	new_test_ext().execute_with(|| {206		// at #4, every 3 blocks, 3 times.207		Scheduler::do_schedule_named(208			[1u8; 32],209			DispatchTime::At(4),210			Some((3, 3)),211			127,212			root(),213			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {214				i: 42,215				weight: Weight::from_ref_time(10),216			}))217			.unwrap(),218		)219		.unwrap();220		// same id results in error.221		assert!(Scheduler::do_schedule_named(222			[1u8; 32],223			DispatchTime::At(4),224			None,225			127,226			root(),227			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {228				i: 69,229				weight: Weight::from_ref_time(10)230			}))231			.unwrap(),232		)233		.is_err());234		// different id is ok.235		Scheduler::do_schedule_named(236			[2u8; 32],237			DispatchTime::At(8),238			None,239			127,240			root(),241			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {242				i: 69,243				weight: Weight::from_ref_time(10),244			}))245			.unwrap(),246		)247		.unwrap();248		run_to_block(3);249		assert!(logger::log().is_empty());250		run_to_block(4);251		assert_eq!(logger::log(), vec![(root(), 42u32)]);252		run_to_block(6);253		assert_ok!(Scheduler::do_cancel_named(None, [1u8; 32]));254		run_to_block(100);255		assert_eq!(logger::log(), vec![(root(), 42u32), (root(), 69u32)]);256	});257}258259#[test]260fn scheduler_respects_weight_limits() {261	let max_weight: Weight = <Test as Config>::MaximumWeight::get();262	new_test_ext().execute_with(|| {263		let call = RuntimeCall::Logger(LoggerCall::log {264			i: 42,265			weight: max_weight / 3 * 2,266		});267		assert_ok!(Scheduler::do_schedule(268			DispatchTime::At(4),269			None,270			127,271			root(),272			<ScheduledCall<Test>>::new(call).unwrap(),273		));274		let call = RuntimeCall::Logger(LoggerCall::log {275			i: 69,276			weight: max_weight / 3 * 2,277		});278		assert_ok!(Scheduler::do_schedule(279			DispatchTime::At(4),280			None,281			127,282			root(),283			<ScheduledCall<Test>>::new(call).unwrap(),284		));285		// 69 and 42 do not fit together286		run_to_block(4);287		assert_eq!(logger::log(), vec![(root(), 42u32)]);288		run_to_block(5);289		assert_eq!(logger::log(), vec![(root(), 42u32), (root(), 69u32)]);290	});291}292293/// Permanently overweight calls are not deleted but also not executed.294#[test]295fn scheduler_does_not_delete_permanently_overweight_call() {296	let max_weight: Weight = <Test as Config>::MaximumWeight::get();297	new_test_ext().execute_with(|| {298		let call = RuntimeCall::Logger(LoggerCall::log {299			i: 42,300			weight: max_weight,301		});302		assert_ok!(Scheduler::do_schedule(303			DispatchTime::At(4),304			None,305			127,306			root(),307			<ScheduledCall<Test>>::new(call).unwrap(),308		));309		// Never executes.310		run_to_block(100);311		assert_eq!(logger::log(), vec![]);312313		// Assert the `PermanentlyOverweight` event.314		assert_eq!(315			System::events().last().unwrap().event,316			crate::Event::PermanentlyOverweight {317				task: (4, 0),318				id: None319			}320			.into(),321		);322		// The call is still in the agenda.323		assert!(Agenda::<Test>::get(4).agenda[0].is_some());324	});325}326327#[test]328fn scheduler_periodic_tasks_always_find_place() {329	let max_weight: Weight = <Test as Config>::MaximumWeight::get();330	let max_per_block = <Test as Config>::MaxScheduledPerBlock::get();331332	new_test_ext().execute_with(|| {333		let call = RuntimeCall::Logger(LoggerCall::log {334			i: 42,335			weight: (max_weight / 3) * 2,336		});337		let call = <ScheduledCall<Test>>::new(call).unwrap();338339		assert_ok!(Scheduler::do_schedule(340			DispatchTime::At(4),341			Some((4, u32::MAX)),342			127,343			root(),344			call.clone(),345		));346		// Executes 5 times till block 20.347		run_to_block(20);348		assert_eq!(logger::log().len(), 5);349350		// Block 28 will already be full.351		for _ in 0..max_per_block {352			assert_ok!(Scheduler::do_schedule(353				DispatchTime::At(28),354				None,355				120,356				root(),357				call.clone(),358			));359		}360361		run_to_block(24);362		assert_eq!(logger::log().len(), 6);363364		// The periodic task should be postponed365		assert_eq!(<Agenda<Test>>::get(29).agenda.len(), 1);366367		run_to_block(27); // will call on_initialize(28)368		assert_eq!(logger::log().len(), 6);369370		run_to_block(28); // will call on_initialize(29)371		assert_eq!(logger::log().len(), 7);372	});373}374375#[test]376fn scheduler_respects_priority_ordering() {377	let max_weight: Weight = <Test as Config>::MaximumWeight::get();378	new_test_ext().execute_with(|| {379		let call = RuntimeCall::Logger(LoggerCall::log {380			i: 42,381			weight: max_weight / 3,382		});383		assert_ok!(Scheduler::do_schedule(384			DispatchTime::At(4),385			None,386			1,387			root(),388			<ScheduledCall<Test>>::new(call).unwrap(),389		));390		let call = RuntimeCall::Logger(LoggerCall::log {391			i: 69,392			weight: max_weight / 3,393		});394		assert_ok!(Scheduler::do_schedule(395			DispatchTime::At(4),396			None,397			0,398			root(),399			<ScheduledCall<Test>>::new(call).unwrap(),400		));401		run_to_block(4);402		assert_eq!(logger::log(), vec![(root(), 69u32), (root(), 42u32)]);403	});404}405406#[test]407fn scheduler_respects_priority_ordering_with_soft_deadlines() {408	new_test_ext().execute_with(|| {409		let max_weight: Weight = <Test as Config>::MaximumWeight::get();410		let call = RuntimeCall::Logger(LoggerCall::log {411			i: 42,412			weight: max_weight / 5 * 2,413		});414		assert_ok!(Scheduler::do_schedule(415			DispatchTime::At(4),416			None,417			255,418			root(),419			<ScheduledCall<Test>>::new(call).unwrap(),420		));421		let call = RuntimeCall::Logger(LoggerCall::log {422			i: 69,423			weight: max_weight / 5 * 2,424		});425		assert_ok!(Scheduler::do_schedule(426			DispatchTime::At(4),427			None,428			127,429			root(),430			<ScheduledCall<Test>>::new(call).unwrap(),431		));432		let call = RuntimeCall::Logger(LoggerCall::log {433			i: 2600,434			weight: max_weight / 5 * 4,435		});436		assert_ok!(Scheduler::do_schedule(437			DispatchTime::At(4),438			None,439			126,440			root(),441			<ScheduledCall<Test>>::new(call).unwrap(),442		));443444		// 2600 does not fit with 69 or 42, but has higher priority, so will go through445		run_to_block(4);446		assert_eq!(logger::log(), vec![(root(), 2600u32)]);447		// 69 and 42 fit together448		run_to_block(5);449		assert_eq!(450			logger::log(),451			vec![(root(), 2600u32), (root(), 69u32), (root(), 42u32)]452		);453	});454}455456#[test]457fn on_initialize_weight_is_correct() {458	new_test_ext().execute_with(|| {459		let call_weight = Weight::from_ref_time(25);460461		// Named462		let call = RuntimeCall::Logger(LoggerCall::log {463			i: 3,464			weight: call_weight + Weight::from_ref_time(1),465		});466		assert_ok!(Scheduler::do_schedule_named(467			[1u8; 32],468			DispatchTime::At(3),469			None,470			255,471			root(),472			<ScheduledCall<Test>>::new(call).unwrap(),473		));474		let call = RuntimeCall::Logger(LoggerCall::log {475			i: 42,476			weight: call_weight + Weight::from_ref_time(2),477		});478		// Anon Periodic479		assert_ok!(Scheduler::do_schedule(480			DispatchTime::At(2),481			Some((1000, 3)),482			128,483			root(),484			<ScheduledCall<Test>>::new(call).unwrap(),485		));486		let call = RuntimeCall::Logger(LoggerCall::log {487			i: 69,488			weight: call_weight + Weight::from_ref_time(3),489		});490		// Anon491		assert_ok!(Scheduler::do_schedule(492			DispatchTime::At(2),493			None,494			127,495			root(),496			<ScheduledCall<Test>>::new(call).unwrap(),497		));498		// Named Periodic499		let call = RuntimeCall::Logger(LoggerCall::log {500			i: 2600,501			weight: call_weight + Weight::from_ref_time(4),502		});503		assert_ok!(Scheduler::do_schedule_named(504			[2u8; 32],505			DispatchTime::At(1),506			Some((1000, 3)),507			126,508			root(),509			<ScheduledCall<Test>>::new(call).unwrap(),510		));511512		// Will include the named periodic only513		assert_eq!(514			Scheduler::on_initialize(1),515			TestWeightInfo::service_agendas_base()516				+ TestWeightInfo::service_agenda_base(1)517				+ <MarginalWeightInfo<Test>>::service_task(None, true, true)518				+ TestWeightInfo::execute_dispatch_unsigned()519				+ call_weight + Weight::from_ref_time(4)520		);521		assert_eq!(IncompleteSince::<Test>::get(), None);522		assert_eq!(logger::log(), vec![(root(), 2600u32)]);523524		// Will include anon and anon periodic525		assert_eq!(526			Scheduler::on_initialize(2),527			TestWeightInfo::service_agendas_base()528				+ TestWeightInfo::service_agenda_base(2)529				+ <MarginalWeightInfo<Test>>::service_task(None, false, true)530				+ TestWeightInfo::execute_dispatch_unsigned()531				+ call_weight + Weight::from_ref_time(3)532				+ <MarginalWeightInfo<Test>>::service_task(None, false, false)533				+ TestWeightInfo::execute_dispatch_unsigned()534				+ call_weight + Weight::from_ref_time(2)535		);536		assert_eq!(IncompleteSince::<Test>::get(), None);537		assert_eq!(538			logger::log(),539			vec![(root(), 2600u32), (root(), 69u32), (root(), 42u32)]540		);541542		// Will include named only543		assert_eq!(544			Scheduler::on_initialize(3),545			TestWeightInfo::service_agendas_base()546				+ TestWeightInfo::service_agenda_base(1)547				+ <MarginalWeightInfo<Test>>::service_task(None, true, false)548				+ TestWeightInfo::execute_dispatch_unsigned()549				+ call_weight + Weight::from_ref_time(1)550		);551		assert_eq!(IncompleteSince::<Test>::get(), None);552		assert_eq!(553			logger::log(),554			vec![555				(root(), 2600u32),556				(root(), 69u32),557				(root(), 42u32),558				(root(), 3u32)559			]560		);561562		// Will contain none563		let actual_weight = Scheduler::on_initialize(4);564		assert_eq!(565			actual_weight,566			TestWeightInfo::service_agendas_base() + TestWeightInfo::service_agenda_base(0)567		);568	});569}570571#[test]572fn root_calls_works() {573	new_test_ext().execute_with(|| {574		let call = Box::new(RuntimeCall::Logger(LoggerCall::log {575			i: 69,576			weight: Weight::from_ref_time(10),577		}));578		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log {579			i: 42,580			weight: Weight::from_ref_time(10),581		}));582		assert_ok!(Scheduler::schedule_named(583			RuntimeOrigin::root(),584			[1u8; 32],585			4,586			None,587			Some(127),588			call,589		));590		assert_ok!(Scheduler::schedule(591			RuntimeOrigin::root(),592			4,593			None,594			Some(127),595			call2596		));597		run_to_block(3);598		// Scheduled calls are in the agenda.599		assert_eq!(Agenda::<Test>::get(4).agenda.len(), 2);600		assert!(logger::log().is_empty());601		assert_ok!(Scheduler::cancel_named(RuntimeOrigin::root(), [1u8; 32]));602		assert_ok!(Scheduler::cancel(RuntimeOrigin::root(), 4, 1));603		// Scheduled calls are made NONE, so should not effect state604		run_to_block(100);605		assert!(logger::log().is_empty());606	});607}608609#[test]610fn fails_to_schedule_task_in_the_past() {611	new_test_ext().execute_with(|| {612		run_to_block(3);613614		let call1 = Box::new(RuntimeCall::Logger(LoggerCall::log {615			i: 69,616			weight: Weight::from_ref_time(10),617		}));618		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log {619			i: 42,620			weight: Weight::from_ref_time(10),621		}));622		let call3 = Box::new(RuntimeCall::Logger(LoggerCall::log {623			i: 42,624			weight: Weight::from_ref_time(10),625		}));626627		assert_noop!(628			Scheduler::schedule_named(RuntimeOrigin::root(), [1u8; 32], 2, None, Some(127), call1),629			Error::<Test>::TargetBlockNumberInPast,630		);631632		assert_noop!(633			Scheduler::schedule(RuntimeOrigin::root(), 2, None, Some(127), call2),634			Error::<Test>::TargetBlockNumberInPast,635		);636637		assert_noop!(638			Scheduler::schedule(RuntimeOrigin::root(), 3, None, Some(127), call3),639			Error::<Test>::TargetBlockNumberInPast,640		);641	});642}643644#[test]645fn should_use_origin() {646	new_test_ext().execute_with(|| {647		let call = Box::new(RuntimeCall::Logger(LoggerCall::log {648			i: 69,649			weight: Weight::from_ref_time(10),650		}));651		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log {652			i: 42,653			weight: Weight::from_ref_time(10),654		}));655		assert_ok!(Scheduler::schedule_named(656			system::RawOrigin::Signed(1).into(),657			[1u8; 32],658			4,659			None,660			None,661			call,662		));663		assert_ok!(Scheduler::schedule(664			system::RawOrigin::Signed(1).into(),665			4,666			None,667			None,668			call2,669		));670		run_to_block(3);671		// Scheduled calls are in the agenda.672		assert_eq!(Agenda::<Test>::get(4).agenda.len(), 2);673		assert!(logger::log().is_empty());674		assert_ok!(Scheduler::cancel_named(675			system::RawOrigin::Signed(1).into(),676			[1u8; 32]677		));678		assert_ok!(Scheduler::cancel(system::RawOrigin::Signed(1).into(), 4, 1));679		// Scheduled calls are made NONE, so should not effect state680		run_to_block(100);681		assert!(logger::log().is_empty());682	});683}684685#[test]686fn should_check_origin() {687	new_test_ext().execute_with(|| {688		let call = Box::new(RuntimeCall::Logger(LoggerCall::log {689			i: 69,690			weight: Weight::from_ref_time(10),691		}));692		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log {693			i: 42,694			weight: Weight::from_ref_time(10),695		}));696		assert_noop!(697			Scheduler::schedule_named(698				system::RawOrigin::Signed(2).into(),699				[1u8; 32],700				4,701				None,702				None,703				call704			),705			BadOrigin706		);707		assert_noop!(708			Scheduler::schedule(system::RawOrigin::Signed(2).into(), 4, None, None, call2),709			BadOrigin710		);711	});712}713714#[test]715fn should_check_origin_for_cancel() {716	new_test_ext().execute_with(|| {717		let call = Box::new(RuntimeCall::Logger(LoggerCall::log_without_filter {718			i: 69,719			weight: Weight::from_ref_time(10),720		}));721		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log_without_filter {722			i: 42,723			weight: Weight::from_ref_time(10),724		}));725		assert_ok!(Scheduler::schedule_named(726			system::RawOrigin::Signed(1).into(),727			[1u8; 32],728			4,729			None,730			None,731			call,732		));733		assert_ok!(Scheduler::schedule(734			system::RawOrigin::Signed(1).into(),735			4,736			None,737			None,738			call2,739		));740		run_to_block(3);741		// Scheduled calls are in the agenda.742		assert_eq!(Agenda::<Test>::get(4).agenda.len(), 2);743		assert!(logger::log().is_empty());744		assert_noop!(745			Scheduler::cancel_named(system::RawOrigin::Signed(2).into(), [1u8; 32]),746			BadOrigin747		);748		assert_noop!(749			Scheduler::cancel(system::RawOrigin::Signed(2).into(), 4, 1),750			BadOrigin751		);752		assert_noop!(753			Scheduler::cancel_named(system::RawOrigin::Root.into(), [1u8; 32]),754			BadOrigin755		);756		assert_noop!(757			Scheduler::cancel(system::RawOrigin::Root.into(), 4, 1),758			BadOrigin759		);760		run_to_block(5);761		assert_eq!(762			logger::log(),763			vec![764				(system::RawOrigin::Signed(1).into(), 69u32),765				(system::RawOrigin::Signed(1).into(), 42u32)766			]767		);768	});769}770771/// Cancelling a call and then scheduling a second call for the same772/// block results in different addresses.773#[test]774fn schedule_does_not_resuse_addr() {775	new_test_ext().execute_with(|| {776		let call = RuntimeCall::Logger(LoggerCall::log {777			i: 42,778			weight: Weight::from_ref_time(10),779		});780781		// Schedule both calls.782		let addr_1 = Scheduler::do_schedule(783			DispatchTime::At(4),784			None,785			127,786			root(),787			<ScheduledCall<Test>>::new(call.clone()).unwrap(),788		)789		.unwrap();790		// Cancel the call.791		assert_ok!(Scheduler::do_cancel(None, addr_1));792		let addr_2 = Scheduler::do_schedule(793			DispatchTime::At(4),794			None,795			127,796			root(),797			<ScheduledCall<Test>>::new(call).unwrap(),798		)799		.unwrap();800801		// Should not re-use the address.802		assert!(addr_1 != addr_2);803	});804}805806#[test]807fn schedule_agenda_overflows() {808	let max: u32 = <Test as Config>::MaxScheduledPerBlock::get();809810	new_test_ext().execute_with(|| {811		let call = RuntimeCall::Logger(LoggerCall::log {812			i: 42,813			weight: Weight::from_ref_time(10),814		});815		let call = <ScheduledCall<Test>>::new(call).unwrap();816817		// Schedule the maximal number allowed per block.818		for _ in 0..max {819			Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.clone()).unwrap();820		}821822		// One more time and it errors.823		assert_noop!(824			Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call,),825			<Error<Test>>::AgendaIsExhausted,826		);827828		run_to_block(4);829		// All scheduled calls are executed.830		assert_eq!(logger::log().len() as u32, max);831	});832}833834/// Cancelling and scheduling does not overflow the agenda but fills holes.835#[test]836fn cancel_and_schedule_fills_holes() {837	let max: u32 = <Test as Config>::MaxScheduledPerBlock::get();838	assert!(839		max > 3,840		"This test only makes sense for MaxScheduledPerBlock > 3"841	);842843	new_test_ext().execute_with(|| {844		let call = RuntimeCall::Logger(LoggerCall::log {845			i: 42,846			weight: Weight::from_ref_time(10),847		});848		let call = <ScheduledCall<Test>>::new(call).unwrap();849		let mut addrs = Vec::<_>::default();850851		// Schedule the maximal number allowed per block.852		for _ in 0..max {853			addrs.push(854				Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.clone())855					.unwrap(),856			);857		}858		// Cancel three of them.859		for addr in addrs.into_iter().take(3) {860			Scheduler::do_cancel(None, addr).unwrap();861		}862		// Schedule three new ones.863		for i in 0..3 {864			let (_block, index) =865				Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.clone())866					.unwrap();867			assert_eq!(i, index);868		}869870		run_to_block(4);871		// Maximum number of calls are executed.872		assert_eq!(logger::log().len() as u32, max);873	});874}875876#[test]877fn cannot_schedule_too_big_tasks() {878	new_test_ext().execute_with(|| {879		let call = Box::new(<<Test as Config>::RuntimeCall>::from(SystemCall::remark {880			remark: vec![0; EncodedCall::bound() - 4],881		}));882883		assert_ok!(Scheduler::schedule(884			RuntimeOrigin::root(),885			4,886			None,887			Some(127),888			call889		));890891		let call = Box::new(<<Test as Config>::RuntimeCall>::from(SystemCall::remark {892			remark: vec![0; EncodedCall::bound() - 3],893		}));894895		assert_err!(896			Scheduler::schedule(RuntimeOrigin::root(), 4, None, Some(127), call),897			<Error<Test>>::TooBigScheduledCall898		);899	});900}
after · pallets/scheduler-v2/src/tests.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license:18// This file is part of Substrate.1920// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// 	http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435//! # Scheduler tests.36#![allow(deprecated)]3738use super::*;39use crate::mock::{40	logger, new_test_ext, root, run_to_block, LoggerCall, RuntimeCall, Scheduler, Test, *,41};42use frame_support::{43	assert_noop, assert_ok,44	traits::{Contains, OnInitialize},45	assert_err,46};4748#[test]49fn basic_scheduling_works() {50	new_test_ext().execute_with(|| {51		let call = RuntimeCall::Logger(LoggerCall::log {52			i: 42,53			weight: Weight::from_ref_time(10),54		});55		assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(56			&call57		));58		assert_ok!(Scheduler::do_schedule(59			DispatchTime::At(4),60			None,61			127,62			root(),63			<ScheduledCall<Test>>::new(call).unwrap(),64		));65		run_to_block(3);66		assert!(logger::log().is_empty());67		run_to_block(4);68		assert_eq!(logger::log(), vec![(root(), 42u32)]);69		run_to_block(100);70		assert_eq!(logger::log(), vec![(root(), 42u32)]);71	});72}7374#[test]75fn schedule_after_works() {76	new_test_ext().execute_with(|| {77		run_to_block(2);78		let call = RuntimeCall::Logger(LoggerCall::log {79			i: 42,80			weight: Weight::from_ref_time(10),81		});82		assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(83			&call84		));85		// This will schedule the call 3 blocks after the next block... so block 3 + 3 = 686		assert_ok!(Scheduler::do_schedule(87			DispatchTime::After(3),88			None,89			127,90			root(),91			<ScheduledCall<Test>>::new(call).unwrap(),92		));93		run_to_block(5);94		assert!(logger::log().is_empty());95		run_to_block(6);96		assert_eq!(logger::log(), vec![(root(), 42u32)]);97		run_to_block(100);98		assert_eq!(logger::log(), vec![(root(), 42u32)]);99	});100}101102#[test]103fn schedule_after_zero_works() {104	new_test_ext().execute_with(|| {105		run_to_block(2);106		let call = RuntimeCall::Logger(LoggerCall::log {107			i: 42,108			weight: Weight::from_ref_time(10),109		});110		assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(111			&call112		));113		assert_ok!(Scheduler::do_schedule(114			DispatchTime::After(0),115			None,116			127,117			root(),118			<ScheduledCall<Test>>::new(call).unwrap(),119		));120		// Will trigger on the next block.121		run_to_block(3);122		assert_eq!(logger::log(), vec![(root(), 42u32)]);123		run_to_block(100);124		assert_eq!(logger::log(), vec![(root(), 42u32)]);125	});126}127128#[test]129fn periodic_scheduling_works() {130	new_test_ext().execute_with(|| {131		// at #4, every 3 blocks, 3 times.132		assert_ok!(Scheduler::do_schedule(133			DispatchTime::At(4),134			Some((3, 3)),135			127,136			root(),137			<ScheduledCall<Test>>::new(RuntimeCall::Logger(logger::Call::log {138				i: 42,139				weight: Weight::from_ref_time(10)140			}))141			.unwrap()142		));143		run_to_block(3);144		assert!(logger::log().is_empty());145		run_to_block(4);146		assert_eq!(logger::log(), vec![(root(), 42u32)]);147		run_to_block(6);148		assert_eq!(logger::log(), vec![(root(), 42u32)]);149		run_to_block(7);150		assert_eq!(logger::log(), vec![(root(), 42u32), (root(), 42u32)]);151		run_to_block(9);152		assert_eq!(logger::log(), vec![(root(), 42u32), (root(), 42u32)]);153		run_to_block(10);154		assert_eq!(155			logger::log(),156			vec![(root(), 42u32), (root(), 42u32), (root(), 42u32)]157		);158		run_to_block(100);159		assert_eq!(160			logger::log(),161			vec![(root(), 42u32), (root(), 42u32), (root(), 42u32)]162		);163	});164}165166#[test]167fn cancel_named_scheduling_works_with_normal_cancel() {168	new_test_ext().execute_with(|| {169		// at #4.170		Scheduler::do_schedule_named(171			[1u8; 32],172			DispatchTime::At(4),173			None,174			127,175			root(),176			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {177				i: 69,178				weight: Weight::from_ref_time(10),179			}))180			.unwrap(),181		)182		.unwrap();183		let i = Scheduler::do_schedule(184			DispatchTime::At(4),185			None,186			127,187			root(),188			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {189				i: 42,190				weight: Weight::from_ref_time(10),191			}))192			.unwrap(),193		)194		.unwrap();195		run_to_block(3);196		assert!(logger::log().is_empty());197		assert_ok!(Scheduler::do_cancel_named(None, [1u8; 32]));198		assert_ok!(Scheduler::do_cancel(None, i));199		run_to_block(100);200		assert!(logger::log().is_empty());201	});202}203204#[test]205fn cancel_named_periodic_scheduling_works() {206	new_test_ext().execute_with(|| {207		// at #4, every 3 blocks, 3 times.208		Scheduler::do_schedule_named(209			[1u8; 32],210			DispatchTime::At(4),211			Some((3, 3)),212			127,213			root(),214			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {215				i: 42,216				weight: Weight::from_ref_time(10),217			}))218			.unwrap(),219		)220		.unwrap();221		// same id results in error.222		assert!(Scheduler::do_schedule_named(223			[1u8; 32],224			DispatchTime::At(4),225			None,226			127,227			root(),228			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {229				i: 69,230				weight: Weight::from_ref_time(10)231			}))232			.unwrap(),233		)234		.is_err());235		// different id is ok.236		Scheduler::do_schedule_named(237			[2u8; 32],238			DispatchTime::At(8),239			None,240			127,241			root(),242			<ScheduledCall<Test>>::new(RuntimeCall::Logger(LoggerCall::log {243				i: 69,244				weight: Weight::from_ref_time(10),245			}))246			.unwrap(),247		)248		.unwrap();249		run_to_block(3);250		assert!(logger::log().is_empty());251		run_to_block(4);252		assert_eq!(logger::log(), vec![(root(), 42u32)]);253		run_to_block(6);254		assert_ok!(Scheduler::do_cancel_named(None, [1u8; 32]));255		run_to_block(100);256		assert_eq!(logger::log(), vec![(root(), 42u32), (root(), 69u32)]);257	});258}259260#[test]261fn scheduler_respects_weight_limits() {262	let max_weight: Weight = <Test as Config>::MaximumWeight::get();263	new_test_ext().execute_with(|| {264		let call = RuntimeCall::Logger(LoggerCall::log {265			i: 42,266			weight: max_weight / 3 * 2,267		});268		assert_ok!(Scheduler::do_schedule(269			DispatchTime::At(4),270			None,271			127,272			root(),273			<ScheduledCall<Test>>::new(call).unwrap(),274		));275		let call = RuntimeCall::Logger(LoggerCall::log {276			i: 69,277			weight: max_weight / 3 * 2,278		});279		assert_ok!(Scheduler::do_schedule(280			DispatchTime::At(4),281			None,282			127,283			root(),284			<ScheduledCall<Test>>::new(call).unwrap(),285		));286		// 69 and 42 do not fit together287		run_to_block(4);288		assert_eq!(logger::log(), vec![(root(), 42u32)]);289		run_to_block(5);290		assert_eq!(logger::log(), vec![(root(), 42u32), (root(), 69u32)]);291	});292}293294/// Permanently overweight calls are not deleted but also not executed.295#[test]296fn scheduler_does_not_delete_permanently_overweight_call() {297	let max_weight: Weight = <Test as Config>::MaximumWeight::get();298	new_test_ext().execute_with(|| {299		let call = RuntimeCall::Logger(LoggerCall::log {300			i: 42,301			weight: max_weight,302		});303		assert_ok!(Scheduler::do_schedule(304			DispatchTime::At(4),305			None,306			127,307			root(),308			<ScheduledCall<Test>>::new(call).unwrap(),309		));310		// Never executes.311		run_to_block(100);312		assert_eq!(logger::log(), vec![]);313314		// Assert the `PermanentlyOverweight` event.315		assert_eq!(316			System::events().last().unwrap().event,317			crate::Event::PermanentlyOverweight {318				task: (4, 0),319				id: None320			}321			.into(),322		);323		// The call is still in the agenda.324		assert!(Agenda::<Test>::get(4).agenda[0].is_some());325	});326}327328#[test]329fn scheduler_periodic_tasks_always_find_place() {330	let max_weight: Weight = <Test as Config>::MaximumWeight::get();331	let max_per_block = <Test as Config>::MaxScheduledPerBlock::get();332333	new_test_ext().execute_with(|| {334		let call = RuntimeCall::Logger(LoggerCall::log {335			i: 42,336			weight: (max_weight / 3) * 2,337		});338		let call = <ScheduledCall<Test>>::new(call).unwrap();339340		assert_ok!(Scheduler::do_schedule(341			DispatchTime::At(4),342			Some((4, u32::MAX)),343			127,344			root(),345			call.clone(),346		));347		// Executes 5 times till block 20.348		run_to_block(20);349		assert_eq!(logger::log().len(), 5);350351		// Block 28 will already be full.352		for _ in 0..max_per_block {353			assert_ok!(Scheduler::do_schedule(354				DispatchTime::At(28),355				None,356				120,357				root(),358				call.clone(),359			));360		}361362		run_to_block(24);363		assert_eq!(logger::log().len(), 6);364365		// The periodic task should be postponed366		assert_eq!(<Agenda<Test>>::get(29).agenda.len(), 1);367368		run_to_block(27); // will call on_initialize(28)369		assert_eq!(logger::log().len(), 6);370371		run_to_block(28); // will call on_initialize(29)372		assert_eq!(logger::log().len(), 7);373	});374}375376#[test]377fn scheduler_respects_priority_ordering() {378	let max_weight: Weight = <Test as Config>::MaximumWeight::get();379	new_test_ext().execute_with(|| {380		let call = RuntimeCall::Logger(LoggerCall::log {381			i: 42,382			weight: max_weight / 3,383		});384		assert_ok!(Scheduler::do_schedule(385			DispatchTime::At(4),386			None,387			1,388			root(),389			<ScheduledCall<Test>>::new(call).unwrap(),390		));391		let call = RuntimeCall::Logger(LoggerCall::log {392			i: 69,393			weight: max_weight / 3,394		});395		assert_ok!(Scheduler::do_schedule(396			DispatchTime::At(4),397			None,398			0,399			root(),400			<ScheduledCall<Test>>::new(call).unwrap(),401		));402		run_to_block(4);403		assert_eq!(logger::log(), vec![(root(), 69u32), (root(), 42u32)]);404	});405}406407#[test]408fn scheduler_respects_priority_ordering_with_soft_deadlines() {409	new_test_ext().execute_with(|| {410		let max_weight: Weight = <Test as Config>::MaximumWeight::get();411		let call = RuntimeCall::Logger(LoggerCall::log {412			i: 42,413			weight: max_weight / 5 * 2,414		});415		assert_ok!(Scheduler::do_schedule(416			DispatchTime::At(4),417			None,418			255,419			root(),420			<ScheduledCall<Test>>::new(call).unwrap(),421		));422		let call = RuntimeCall::Logger(LoggerCall::log {423			i: 69,424			weight: max_weight / 5 * 2,425		});426		assert_ok!(Scheduler::do_schedule(427			DispatchTime::At(4),428			None,429			127,430			root(),431			<ScheduledCall<Test>>::new(call).unwrap(),432		));433		let call = RuntimeCall::Logger(LoggerCall::log {434			i: 2600,435			weight: max_weight / 5 * 4,436		});437		assert_ok!(Scheduler::do_schedule(438			DispatchTime::At(4),439			None,440			126,441			root(),442			<ScheduledCall<Test>>::new(call).unwrap(),443		));444445		// 2600 does not fit with 69 or 42, but has higher priority, so will go through446		run_to_block(4);447		assert_eq!(logger::log(), vec![(root(), 2600u32)]);448		// 69 and 42 fit together449		run_to_block(5);450		assert_eq!(451			logger::log(),452			vec![(root(), 2600u32), (root(), 69u32), (root(), 42u32)]453		);454	});455}456457#[test]458fn on_initialize_weight_is_correct() {459	new_test_ext().execute_with(|| {460		let call_weight = Weight::from_ref_time(25);461462		// Named463		let call = RuntimeCall::Logger(LoggerCall::log {464			i: 3,465			weight: call_weight + Weight::from_ref_time(1),466		});467		assert_ok!(Scheduler::do_schedule_named(468			[1u8; 32],469			DispatchTime::At(3),470			None,471			255,472			root(),473			<ScheduledCall<Test>>::new(call).unwrap(),474		));475		let call = RuntimeCall::Logger(LoggerCall::log {476			i: 42,477			weight: call_weight + Weight::from_ref_time(2),478		});479		// Anon Periodic480		assert_ok!(Scheduler::do_schedule(481			DispatchTime::At(2),482			Some((1000, 3)),483			128,484			root(),485			<ScheduledCall<Test>>::new(call).unwrap(),486		));487		let call = RuntimeCall::Logger(LoggerCall::log {488			i: 69,489			weight: call_weight + Weight::from_ref_time(3),490		});491		// Anon492		assert_ok!(Scheduler::do_schedule(493			DispatchTime::At(2),494			None,495			127,496			root(),497			<ScheduledCall<Test>>::new(call).unwrap(),498		));499		// Named Periodic500		let call = RuntimeCall::Logger(LoggerCall::log {501			i: 2600,502			weight: call_weight + Weight::from_ref_time(4),503		});504		assert_ok!(Scheduler::do_schedule_named(505			[2u8; 32],506			DispatchTime::At(1),507			Some((1000, 3)),508			126,509			root(),510			<ScheduledCall<Test>>::new(call).unwrap(),511		));512513		// Will include the named periodic only514		assert_eq!(515			Scheduler::on_initialize(1),516			TestWeightInfo::service_agendas_base()517				+ TestWeightInfo::service_agenda_base(1)518				+ <MarginalWeightInfo<Test>>::service_task(None, true, true)519				+ TestWeightInfo::execute_dispatch_unsigned()520				+ call_weight + Weight::from_ref_time(4)521		);522		assert_eq!(IncompleteSince::<Test>::get(), None);523		assert_eq!(logger::log(), vec![(root(), 2600u32)]);524525		// Will include anon and anon periodic526		assert_eq!(527			Scheduler::on_initialize(2),528			TestWeightInfo::service_agendas_base()529				+ TestWeightInfo::service_agenda_base(2)530				+ <MarginalWeightInfo<Test>>::service_task(None, false, true)531				+ TestWeightInfo::execute_dispatch_unsigned()532				+ call_weight + Weight::from_ref_time(3)533				+ <MarginalWeightInfo<Test>>::service_task(None, false, false)534				+ TestWeightInfo::execute_dispatch_unsigned()535				+ call_weight + Weight::from_ref_time(2)536		);537		assert_eq!(IncompleteSince::<Test>::get(), None);538		assert_eq!(539			logger::log(),540			vec![(root(), 2600u32), (root(), 69u32), (root(), 42u32)]541		);542543		// Will include named only544		assert_eq!(545			Scheduler::on_initialize(3),546			TestWeightInfo::service_agendas_base()547				+ TestWeightInfo::service_agenda_base(1)548				+ <MarginalWeightInfo<Test>>::service_task(None, true, false)549				+ TestWeightInfo::execute_dispatch_unsigned()550				+ call_weight + Weight::from_ref_time(1)551		);552		assert_eq!(IncompleteSince::<Test>::get(), None);553		assert_eq!(554			logger::log(),555			vec![556				(root(), 2600u32),557				(root(), 69u32),558				(root(), 42u32),559				(root(), 3u32)560			]561		);562563		// Will contain none564		let actual_weight = Scheduler::on_initialize(4);565		assert_eq!(566			actual_weight,567			TestWeightInfo::service_agendas_base() + TestWeightInfo::service_agenda_base(0)568		);569	});570}571572#[test]573fn root_calls_works() {574	new_test_ext().execute_with(|| {575		let call = Box::new(RuntimeCall::Logger(LoggerCall::log {576			i: 69,577			weight: Weight::from_ref_time(10),578		}));579		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log {580			i: 42,581			weight: Weight::from_ref_time(10),582		}));583		assert_ok!(Scheduler::schedule_named(584			RuntimeOrigin::root(),585			[1u8; 32],586			4,587			None,588			Some(127),589			call,590		));591		assert_ok!(Scheduler::schedule(592			RuntimeOrigin::root(),593			4,594			None,595			Some(127),596			call2597		));598		run_to_block(3);599		// Scheduled calls are in the agenda.600		assert_eq!(Agenda::<Test>::get(4).agenda.len(), 2);601		assert!(logger::log().is_empty());602		assert_ok!(Scheduler::cancel_named(RuntimeOrigin::root(), [1u8; 32]));603		assert_ok!(Scheduler::cancel(RuntimeOrigin::root(), 4, 1));604		// Scheduled calls are made NONE, so should not effect state605		run_to_block(100);606		assert!(logger::log().is_empty());607	});608}609610#[test]611fn fails_to_schedule_task_in_the_past() {612	new_test_ext().execute_with(|| {613		run_to_block(3);614615		let call1 = Box::new(RuntimeCall::Logger(LoggerCall::log {616			i: 69,617			weight: Weight::from_ref_time(10),618		}));619		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log {620			i: 42,621			weight: Weight::from_ref_time(10),622		}));623		let call3 = Box::new(RuntimeCall::Logger(LoggerCall::log {624			i: 42,625			weight: Weight::from_ref_time(10),626		}));627628		assert_noop!(629			Scheduler::schedule_named(RuntimeOrigin::root(), [1u8; 32], 2, None, Some(127), call1),630			Error::<Test>::TargetBlockNumberInPast,631		);632633		assert_noop!(634			Scheduler::schedule(RuntimeOrigin::root(), 2, None, Some(127), call2),635			Error::<Test>::TargetBlockNumberInPast,636		);637638		assert_noop!(639			Scheduler::schedule(RuntimeOrigin::root(), 3, None, Some(127), call3),640			Error::<Test>::TargetBlockNumberInPast,641		);642	});643}644645#[test]646fn should_use_origin() {647	new_test_ext().execute_with(|| {648		let call = Box::new(RuntimeCall::Logger(LoggerCall::log {649			i: 69,650			weight: Weight::from_ref_time(10),651		}));652		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log {653			i: 42,654			weight: Weight::from_ref_time(10),655		}));656		assert_ok!(Scheduler::schedule_named(657			system::RawOrigin::Signed(1).into(),658			[1u8; 32],659			4,660			None,661			None,662			call,663		));664		assert_ok!(Scheduler::schedule(665			system::RawOrigin::Signed(1).into(),666			4,667			None,668			None,669			call2,670		));671		run_to_block(3);672		// Scheduled calls are in the agenda.673		assert_eq!(Agenda::<Test>::get(4).agenda.len(), 2);674		assert!(logger::log().is_empty());675		assert_ok!(Scheduler::cancel_named(676			system::RawOrigin::Signed(1).into(),677			[1u8; 32]678		));679		assert_ok!(Scheduler::cancel(system::RawOrigin::Signed(1).into(), 4, 1));680		// Scheduled calls are made NONE, so should not effect state681		run_to_block(100);682		assert!(logger::log().is_empty());683	});684}685686#[test]687fn should_check_origin() {688	new_test_ext().execute_with(|| {689		let call = Box::new(RuntimeCall::Logger(LoggerCall::log {690			i: 69,691			weight: Weight::from_ref_time(10),692		}));693		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log {694			i: 42,695			weight: Weight::from_ref_time(10),696		}));697		assert_noop!(698			Scheduler::schedule_named(699				system::RawOrigin::Signed(2).into(),700				[1u8; 32],701				4,702				None,703				None,704				call705			),706			BadOrigin707		);708		assert_noop!(709			Scheduler::schedule(system::RawOrigin::Signed(2).into(), 4, None, None, call2),710			BadOrigin711		);712	});713}714715#[test]716fn should_check_origin_for_cancel() {717	new_test_ext().execute_with(|| {718		let call = Box::new(RuntimeCall::Logger(LoggerCall::log_without_filter {719			i: 69,720			weight: Weight::from_ref_time(10),721		}));722		let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log_without_filter {723			i: 42,724			weight: Weight::from_ref_time(10),725		}));726		assert_ok!(Scheduler::schedule_named(727			system::RawOrigin::Signed(1).into(),728			[1u8; 32],729			4,730			None,731			None,732			call,733		));734		assert_ok!(Scheduler::schedule(735			system::RawOrigin::Signed(1).into(),736			4,737			None,738			None,739			call2,740		));741		run_to_block(3);742		// Scheduled calls are in the agenda.743		assert_eq!(Agenda::<Test>::get(4).agenda.len(), 2);744		assert!(logger::log().is_empty());745		assert_noop!(746			Scheduler::cancel_named(system::RawOrigin::Signed(2).into(), [1u8; 32]),747			BadOrigin748		);749		assert_noop!(750			Scheduler::cancel(system::RawOrigin::Signed(2).into(), 4, 1),751			BadOrigin752		);753		assert_noop!(754			Scheduler::cancel_named(system::RawOrigin::Root.into(), [1u8; 32]),755			BadOrigin756		);757		assert_noop!(758			Scheduler::cancel(system::RawOrigin::Root.into(), 4, 1),759			BadOrigin760		);761		run_to_block(5);762		assert_eq!(763			logger::log(),764			vec![765				(system::RawOrigin::Signed(1).into(), 69u32),766				(system::RawOrigin::Signed(1).into(), 42u32)767			]768		);769	});770}771772/// Cancelling a call and then scheduling a second call for the same773/// block results in different addresses.774#[test]775fn schedule_does_not_resuse_addr() {776	new_test_ext().execute_with(|| {777		let call = RuntimeCall::Logger(LoggerCall::log {778			i: 42,779			weight: Weight::from_ref_time(10),780		});781782		// Schedule both calls.783		let addr_1 = Scheduler::do_schedule(784			DispatchTime::At(4),785			None,786			127,787			root(),788			<ScheduledCall<Test>>::new(call.clone()).unwrap(),789		)790		.unwrap();791		// Cancel the call.792		assert_ok!(Scheduler::do_cancel(None, addr_1));793		let addr_2 = Scheduler::do_schedule(794			DispatchTime::At(4),795			None,796			127,797			root(),798			<ScheduledCall<Test>>::new(call).unwrap(),799		)800		.unwrap();801802		// Should not re-use the address.803		assert!(addr_1 != addr_2);804	});805}806807#[test]808fn schedule_agenda_overflows() {809	let max: u32 = <Test as Config>::MaxScheduledPerBlock::get();810811	new_test_ext().execute_with(|| {812		let call = RuntimeCall::Logger(LoggerCall::log {813			i: 42,814			weight: Weight::from_ref_time(10),815		});816		let call = <ScheduledCall<Test>>::new(call).unwrap();817818		// Schedule the maximal number allowed per block.819		for _ in 0..max {820			Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.clone()).unwrap();821		}822823		// One more time and it errors.824		assert_noop!(825			Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call,),826			<Error<Test>>::AgendaIsExhausted,827		);828829		run_to_block(4);830		// All scheduled calls are executed.831		assert_eq!(logger::log().len() as u32, max);832	});833}834835/// Cancelling and scheduling does not overflow the agenda but fills holes.836#[test]837fn cancel_and_schedule_fills_holes() {838	let max: u32 = <Test as Config>::MaxScheduledPerBlock::get();839	assert!(840		max > 3,841		"This test only makes sense for MaxScheduledPerBlock > 3"842	);843844	new_test_ext().execute_with(|| {845		let call = RuntimeCall::Logger(LoggerCall::log {846			i: 42,847			weight: Weight::from_ref_time(10),848		});849		let call = <ScheduledCall<Test>>::new(call).unwrap();850		let mut addrs = Vec::<_>::default();851852		// Schedule the maximal number allowed per block.853		for _ in 0..max {854			addrs.push(855				Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.clone())856					.unwrap(),857			);858		}859		// Cancel three of them.860		for addr in addrs.into_iter().take(3) {861			Scheduler::do_cancel(None, addr).unwrap();862		}863		// Schedule three new ones.864		for i in 0..3 {865			let (_block, index) =866				Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.clone())867					.unwrap();868			assert_eq!(i, index);869		}870871		run_to_block(4);872		// Maximum number of calls are executed.873		assert_eq!(logger::log().len() as u32, max);874	});875}876877#[test]878fn cannot_schedule_too_big_tasks() {879	new_test_ext().execute_with(|| {880		let call = Box::new(<<Test as Config>::RuntimeCall>::from(SystemCall::remark {881			remark: vec![0; EncodedCall::bound() - 4],882		}));883884		assert_ok!(Scheduler::schedule(885			RuntimeOrigin::root(),886			4,887			None,888			Some(127),889			call890		));891892		let call = Box::new(<<Test as Config>::RuntimeCall>::from(SystemCall::remark {893			remark: vec![0; EncodedCall::bound() - 3],894		}));895896		assert_err!(897			Scheduler::schedule(RuntimeOrigin::root(), 4, None, Some(127), call),898			<Error<Test>>::TooBigScheduledCall899		);900	});901}
modifiedpallets/structure/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/structure/src/benchmarking.rs
+++ b/pallets/structure/src/benchmarking.rs
@@ -19,8 +19,7 @@
 use frame_benchmarking::{benchmarks, account};
 use frame_support::traits::{fungible::Balanced, Get, tokens::Precision};
 use up_data_structs::{
-	CreateCollectionData, CollectionMode, CreateItemData, CollectionFlags, CreateNftData,
-	budget::Unlimited,
+	CreateCollectionData, CollectionMode, CreateItemData, CreateNftData, budget::Unlimited,
 };
 use pallet_common::Config as CommonConfig;
 use pallet_evm::account::CrossAccountId;
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -24,8 +24,7 @@
 		weights::CommonWeights,
 		RelayChainBlockNumberProvider,
 	},
-	Runtime, RuntimeEvent, RuntimeCall, RUNTIME_NAME, TOKEN_SYMBOL, DECIMALS,
-	Balances,
+	Runtime, RuntimeEvent, RuntimeCall, RUNTIME_NAME, TOKEN_SYMBOL, DECIMALS, Balances,
 };
 use frame_support::traits::{ConstU32, ConstU64, Currency};
 use up_common::{
modifiedruntime/common/ethereum/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring.rs
+++ b/runtime/common/ethereum/sponsoring.rs
@@ -161,7 +161,8 @@
 					}
 				}
 				CollectionMode::ReFungible => {
-					let call = <UniqueRefungibleCall<T>>::parse_full(&call_context.input).ok()??;
+					let call =
+						<UniqueRefungibleCall<T>>::parse_full(&call_context.input).ok()??;
 					refungible::call_sponsor(call, collection, who).map(|()| sponsor)
 				}
 				CollectionMode::Fungible(_) => {
modifiedruntime/common/tests/mod.rsdiffbeforeafterboth
--- a/runtime/common/tests/mod.rs
+++ b/runtime/common/tests/mod.rs
@@ -16,7 +16,6 @@
 
 use sp_runtime::{BuildStorage, Storage};
 use sp_core::{Public, Pair};
-use sp_std::vec;
 use up_common::types::AuraId;
 use crate::{Runtime, GenesisConfig, ParachainInfoConfig, RuntimeEvent, System};
 
@@ -76,7 +75,7 @@
 		AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
 	}
 
-	let accounts = vec!["Alice", "Bob"];
+	let accounts = ["Alice", "Bob"];
 	let keys = accounts
 		.iter()
 		.map(|&acc| {
@@ -104,7 +103,7 @@
 		..GenesisConfig::default()
 	};
 
-	cfg.build_storage().unwrap().into()
+	cfg.build_storage().unwrap()
 }
 
 #[cfg(not(feature = "collator-selection"))]
modifiedruntime/common/tests/xcm.rsdiffbeforeafterboth
--- a/runtime/common/tests/xcm.rs
+++ b/runtime/common/tests/xcm.rs
@@ -26,7 +26,7 @@
 const ALICE: AccountId = AccountId::new([0u8; 32]);
 const BOB: AccountId = AccountId::new([1u8; 32]);
 
-const INITIAL_BALANCE: u128 = 1000000000000000000_0000; // 1000 UNQ
+const INITIAL_BALANCE: u128 = 10_000_000_000_000_000_000_000; // 10_000 UNQ
 
 #[test]
 pub fn xcm_transact_is_forbidden() {
modifiedruntime/tests/Cargo.tomldiffbeforeafterboth
--- a/runtime/tests/Cargo.toml
+++ b/runtime/tests/Cargo.toml
@@ -5,7 +5,6 @@
 
 [features]
 default = ['refungible']
-tests = ['pallet-common/tests']
 
 refungible = []
 
@@ -44,3 +43,6 @@
 evm-coder = { workspace = true }
 up-sponsorship = { workspace = true }
 xcm = { workspace = true }
+
+[dev-dependencies]
+pallet-common = { workspace = true, features = ["tests"] }
modifiedruntime/tests/src/tests.rsdiffbeforeafterboth
--- a/runtime/tests/src/tests.rs
+++ b/runtime/tests/src/tests.rs
@@ -99,7 +99,7 @@
 	.try_into()
 	.unwrap();
 
-	let data: CreateCollectionData<u64> = CreateCollectionData {
+	let data = CreateCollectionData {
 		name: col_name1.try_into().unwrap(),
 		description: col_desc1.try_into().unwrap(),
 		token_prefix: token_prefix1.try_into().unwrap(),
@@ -204,14 +204,13 @@
 		let description: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
 		let token_prefix: Vec<u8> = b"token_prefix1\0".to_vec();
 
-		let data: CreateCollectionData<<Test as frame_system::Config>::AccountId> =
-			CreateCollectionData {
-				name: name.try_into().unwrap(),
-				description: description.try_into().unwrap(),
-				token_prefix: token_prefix.try_into().unwrap(),
-				mode: CollectionMode::NFT,
-				..Default::default()
-			};
+		let data = CreateCollectionData {
+			name: name.try_into().unwrap(),
+			description: description.try_into().unwrap(),
+			token_prefix: token_prefix.try_into().unwrap(),
+			mode: CollectionMode::NFT,
+			..Default::default()
+		};
 
 		let result = Unique::create_collection_ex(RuntimeOrigin::signed(acc), data);
 		assert_err!(result, <CommonError<Test>>::NotSufficientFounds);
@@ -225,7 +224,7 @@
 		let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
 		let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();
 
-		let data: CreateCollectionData<u64> = CreateCollectionData {
+		let data = CreateCollectionData {
 			name: col_name1.try_into().unwrap(),
 			description: col_desc1.try_into().unwrap(),
 			token_prefix: token_prefix1.try_into().unwrap(),
@@ -2364,7 +2363,7 @@
 		let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
 		let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();
 
-		let data: CreateCollectionData<u64> = CreateCollectionData {
+		let data = CreateCollectionData {
 			name: col_name1.try_into().unwrap(),
 			description: col_desc1.try_into().unwrap(),
 			token_prefix: token_prefix1.try_into().unwrap(),
@@ -2618,9 +2617,7 @@
 
 mod check_token_permissions {
 	use super::*;
-	use frame_support::once_cell::sync::Lazy;
 	use pallet_common::LazyValue;
-	use sp_runtime::DispatchError;
 
 	fn test<FTE: FnOnce() -> bool>(
 		i: usize,
@@ -2662,7 +2659,7 @@
 	fn no_permission_only() {
 		new_test_ext().execute_with(|| {
 			let mut check_token_existence = LazyValue::new(|| true);
-			for (i, row) in pallet_common::tests::table.iter().enumerate() {
+			for (i, row) in pallet_common::tests::TABLE.iter().enumerate() {
 				test(i, row, &mut check_token_existence);
 			}
 		});
@@ -2671,7 +2668,7 @@
 	#[test]
 	fn no_permission_and_token_not_found() {
 		new_test_ext().execute_with(|| {
-			for (i, row) in pallet_common::tests::table.iter().enumerate() {
+			for (i, row) in pallet_common::tests::TABLE.iter().enumerate() {
 				// This is inside the loop to keep track of whether the lambda was called
 				let mut check_token_existence = LazyValue::new(|| false);
 				test(i, row, &mut check_token_existence);
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -106,15 +106,17 @@
       flags: [CollectionFlag.Erc721metadata],
     }, 'nft');
 
-    await mintCollectionHelper(helper, alice, {
+    // User can not set Foreign flag itself
+
+    await expect(mintCollectionHelper(helper, alice, {
       name: 'name', description: 'descr', tokenPrefix: 'COL',
       flags: [CollectionFlag.Foreign],
-    }, 'nft');
+    }, 'nft')).to.be.rejectedWith(/common.NoPermission/);
 
-    await mintCollectionHelper(helper, alice, {
+    await expect(mintCollectionHelper(helper, alice, {
       name: 'name', description: 'descr', tokenPrefix: 'COL',
       flags: [CollectionFlag.Erc721metadata, CollectionFlag.Foreign],
-    }, 'nft');
+    }, 'nft')).to.be.rejectedWith(/common.NoPermission/);
   });
 
   itSub('Create new collection with extra fields', async ({helper}) => {
modifiedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionLimits.test.ts
+++ b/tests/src/eth/collectionLimits.test.ts
@@ -106,7 +106,7 @@
 
       // Cannot disable limits
       await expect(collectionEvm.methods
-        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: false, value: 200}})
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: false, value: 0}})
         .call()).to.be.rejectedWith('user can\'t disable limits');
 
       await expect(collectionEvm.methods
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -41,7 +41,7 @@
       for(const arg of args) {
         if(typeof arg !== 'string')
           continue;
-        const skippedWarnings = ['1000:: Normal connection closure', 'Not decorating unknown runtime apis:', 'RPC methods not decorated:', 'Not decorating runtime apis'];
+        const skippedWarnings = ['1000:: Normal connection closure', 'Not decorating unknown runtime apis:', 'RPC methods not decorated:', 'Not decorating runtime apis', 'Bad input data provided to validate_transaction', 'account balance too low', '1006:: Abnormal Closure'];
         const needToSkip = skippedWarnings.reduce((a,  b) => a || arg.includes(b), false);
         if(needToSkip || arg === 'Normal connection closure')
           return;