difftreelog
Merge pull request #974 from UniqueNetwork/fix/evm-coder-leftovers
in: master
25 files changed
client/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
node/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"),
pallets/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,
)?;
pallets/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
pallets/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,
pallets/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 {
pallets/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::*;
pallets/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;
pallets/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")
pallets/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;
}
pallets/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>(
pallets/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
pallets/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;
}
}
}
pallets/scheduler-v2/src/mock.rsdiffbeforeafterboth1// 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 test environment.3637use super::*;3839use crate as scheduler;40use frame_support::{41 ord_parameter_types, parameter_types,42 traits::{ConstU32, ConstU64, Contains, EqualPrivilegeOnly, OnFinalize, OnInitialize},43 weights::constants::RocksDbWeight,44};45use frame_system::{EnsureRoot, RawOrigin};46use sp_core::H256;47use sp_runtime::{48 testing::Header,49 traits::{BlakeTwo256, IdentityLookup},50 Perbill,51};5253// Logger module to track execution.54#[frame_support::pallet]55pub mod logger {56 use super::{OriginCaller, OriginTrait};57 use frame_support::{pallet_prelude::*, parameter_types};58 use frame_system::pallet_prelude::*;5960 parameter_types! {61 static Log: Vec<(OriginCaller, u32)> = Vec::new();62 }63 pub fn log() -> Vec<(OriginCaller, u32)> {64 Log::get().clone()65 }6667 #[pallet::pallet]68 pub struct Pallet<T>(PhantomData<T>);6970 #[pallet::hooks]71 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}7273 #[pallet::config]74 pub trait Config: frame_system::Config {75 type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;76 }7778 #[pallet::event]79 #[pallet::generate_deposit(pub(super) fn deposit_event)]80 pub enum Event<T: Config> {81 Logged(u32, Weight),82 }8384 #[pallet::call]85 impl<T: Config> Pallet<T>86 where87 <T as frame_system::Config>::RuntimeOrigin: OriginTrait<PalletsOrigin = OriginCaller>,88 {89 #[pallet::call_index(0)]90 #[pallet::weight(*weight)]91 pub fn log(origin: OriginFor<T>, i: u32, weight: Weight) -> DispatchResult {92 Self::deposit_event(Event::Logged(i, weight));93 Log::mutate(|log| {94 log.push((origin.caller().clone(), i));95 });96 Ok(())97 }9899 #[pallet::call_index(1)]100 #[pallet::weight(*weight)]101 pub fn log_without_filter(origin: OriginFor<T>, i: u32, weight: Weight) -> DispatchResult {102 Self::deposit_event(Event::Logged(i, weight));103 Log::mutate(|log| {104 log.push((origin.caller().clone(), i));105 });106 Ok(())107 }108 }109}110111type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;112type Block = frame_system::mocking::MockBlock<Test>;113114frame_support::construct_runtime!(115 pub enum Test where116 Block = Block,117 NodeBlock = Block,118 UncheckedExtrinsic = UncheckedExtrinsic,119 {120 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},121 Logger: logger::{Pallet, Call, Event<T>},122 Scheduler: scheduler::{Pallet, Call, Storage, Event<T>},123 }124);125126// Scheduler must dispatch with root and no filter, this tests base filter is indeed not used.127pub struct BaseFilter;128impl Contains<RuntimeCall> for BaseFilter {129 fn contains(call: &RuntimeCall) -> bool {130 !matches!(call, RuntimeCall::Logger(LoggerCall::log { .. }))131 }132}133134parameter_types! {135 pub BlockWeights: frame_system::limits::BlockWeights =136 frame_system::limits::BlockWeights::simple_max(137 Weight::from_ref_time(2_000_000_000_000).set_proof_size(u64::MAX)138 );139}140impl system::Config for Test {141 type BaseCallFilter = BaseFilter;142 type BlockWeights = BlockWeights;143 type BlockLength = ();144 type DbWeight = RocksDbWeight;145 type RuntimeOrigin = RuntimeOrigin;146 type RuntimeCall = RuntimeCall;147 type Index = u64;148 type BlockNumber = u64;149 type Hash = H256;150 type Hashing = BlakeTwo256;151 type AccountId = u64;152 type Lookup = IdentityLookup<Self::AccountId>;153 type Header = Header;154 type RuntimeEvent = RuntimeEvent;155 type BlockHashCount = ConstU64<250>;156 type Version = ();157 type PalletInfo = PalletInfo;158 type AccountData = ();159 type OnNewAccount = ();160 type OnKilledAccount = ();161 type SystemWeightInfo = ();162 type SS58Prefix = ();163 type OnSetCode = ();164 type MaxConsumers = ConstU32<16>;165}166impl logger::Config for Test {167 type RuntimeEvent = RuntimeEvent;168}169ord_parameter_types! {170 pub const One: u64 = 1;171}172173pub struct TestWeightInfo;174impl WeightInfo for TestWeightInfo {175 fn service_agendas_base() -> Weight {176 Weight::from_ref_time(0b0000_0001)177 }178 fn service_agenda_base(i: u32) -> Weight {179 Weight::from_ref_time((i << 8) as u64 + 0b0000_0010)180 }181 fn service_task_base() -> Weight {182 Weight::from_ref_time(0b0000_0100)183 }184 fn service_task_periodic() -> Weight {185 Weight::from_ref_time(0b0000_1100)186 }187 fn service_task_named() -> Weight {188 Weight::from_ref_time(0b0001_0100)189 }190 // fn service_task_fetched(s: u32) -> Weight {191 // Weight::from_ref_time((s << 8) as u64 + 0b0010_0100)192 // }193 fn execute_dispatch_signed() -> Weight {194 Weight::from_ref_time(0b0100_0000)195 }196 fn execute_dispatch_unsigned() -> Weight {197 Weight::from_ref_time(0b1000_0000)198 }199 fn schedule(_s: u32) -> Weight {200 Weight::from_ref_time(50)201 }202 fn cancel(_s: u32) -> Weight {203 Weight::from_ref_time(50)204 }205 fn schedule_named(_s: u32) -> Weight {206 Weight::from_ref_time(50)207 }208 fn cancel_named(_s: u32) -> Weight {209 Weight::from_ref_time(50)210 }211 fn change_named_priority(_s: u32) -> Weight {212 Weight::from_ref_time(50)213 }214}215parameter_types! {216 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *217 BlockWeights::get().max_block;218}219220pub struct EnsureSignedOneOrRoot;221impl<O: Into<Result<RawOrigin<u64>, O>> + From<RawOrigin<u64>>> EnsureOrigin<O>222 for EnsureSignedOneOrRoot223{224 type Success = ScheduledEnsureOriginSuccess<u64>;225 fn try_origin(o: O) -> Result<Self::Success, O> {226 o.into().and_then(|o| match o {227 RawOrigin::Root => Ok(ScheduledEnsureOriginSuccess::Root),228 RawOrigin::Signed(1) => Ok(ScheduledEnsureOriginSuccess::Signed(1)),229 r => Err(O::from(r)),230 })231 }232}233234pub struct Executor;235impl DispatchCall<Test, sp_core::H160> for Executor {236 fn dispatch_call(237 signer: Option<u64>,238 function: RuntimeCall,239 ) -> Result<240 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,241 TransactionValidityError,242 > {243 let origin = match signer {244 Some(who) => RuntimeOrigin::signed(who),245 None => RuntimeOrigin::none(),246 };247 Ok(function.dispatch(origin))248 }249}250251impl Config for Test {252 type RuntimeEvent = RuntimeEvent;253 type RuntimeOrigin = RuntimeOrigin;254 type PalletsOrigin = OriginCaller;255 type RuntimeCall = RuntimeCall;256 type MaximumWeight = MaximumSchedulerWeight;257 type ScheduleOrigin = EnsureSignedOneOrRoot;258 type MaxScheduledPerBlock = ConstU32<10>;259 type WeightInfo = TestWeightInfo;260 type OriginPrivilegeCmp = EqualPrivilegeOnly;261 type Preimages = ();262 type PrioritySetOrigin = EnsureRoot<u64>;263 type CallExecutor = Executor;264}265266pub type LoggerCall = logger::Call<Test>;267268pub type SystemCall = frame_system::Call<Test>;269270pub fn new_test_ext() -> sp_io::TestExternalities {271 let t = system::GenesisConfig::default()272 .build_storage::<Test>()273 .unwrap();274 t.into()275}276277pub fn run_to_block(n: u64) {278 while System::block_number() < n {279 Scheduler::on_finalize(System::block_number());280 System::set_block_number(System::block_number() + 1);281 Scheduler::on_initialize(System::block_number());282 }283}284285pub fn root() -> OriginCaller {286 system::RawOrigin::Root.into()287}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 test environment.36#![allow(deprecated)]3738use super::*;3940use crate as scheduler;41use frame_support::{42 ord_parameter_types, parameter_types,43 traits::{ConstU32, ConstU64, Contains, EqualPrivilegeOnly, OnFinalize, OnInitialize},44 weights::constants::RocksDbWeight,45};46use frame_system::{EnsureRoot, RawOrigin};47use sp_core::H256;48use sp_runtime::{49 testing::Header,50 traits::{BlakeTwo256, IdentityLookup},51 Perbill,52};5354// Logger module to track execution.55#[frame_support::pallet]56pub mod logger {57 use super::{OriginCaller, OriginTrait};58 use frame_support::{pallet_prelude::*, parameter_types};59 use frame_system::pallet_prelude::*;6061 parameter_types! {62 static Log: Vec<(OriginCaller, u32)> = Vec::new();63 }64 pub fn log() -> Vec<(OriginCaller, u32)> {65 Log::get().clone()66 }6768 #[pallet::pallet]69 pub struct Pallet<T>(PhantomData<T>);7071 #[pallet::hooks]72 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}7374 #[pallet::config]75 pub trait Config: frame_system::Config {76 type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;77 }7879 #[pallet::event]80 #[pallet::generate_deposit(pub(super) fn deposit_event)]81 pub enum Event<T: Config> {82 Logged(u32, Weight),83 }8485 #[pallet::call]86 impl<T: Config> Pallet<T>87 where88 <T as frame_system::Config>::RuntimeOrigin: OriginTrait<PalletsOrigin = OriginCaller>,89 {90 #[pallet::call_index(0)]91 #[pallet::weight(*weight)]92 pub fn log(origin: OriginFor<T>, i: u32, weight: Weight) -> DispatchResult {93 Self::deposit_event(Event::Logged(i, weight));94 Log::mutate(|log| {95 log.push((origin.caller().clone(), i));96 });97 Ok(())98 }99100 #[pallet::call_index(1)]101 #[pallet::weight(*weight)]102 pub fn log_without_filter(origin: OriginFor<T>, i: u32, weight: Weight) -> DispatchResult {103 Self::deposit_event(Event::Logged(i, weight));104 Log::mutate(|log| {105 log.push((origin.caller().clone(), i));106 });107 Ok(())108 }109 }110}111112type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;113type Block = frame_system::mocking::MockBlock<Test>;114115frame_support::construct_runtime!(116 pub enum Test where117 Block = Block,118 NodeBlock = Block,119 UncheckedExtrinsic = UncheckedExtrinsic,120 {121 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},122 Logger: logger::{Pallet, Call, Event<T>},123 Scheduler: scheduler::{Pallet, Call, Storage, Event<T>},124 }125);126127// Scheduler must dispatch with root and no filter, this tests base filter is indeed not used.128pub struct BaseFilter;129impl Contains<RuntimeCall> for BaseFilter {130 fn contains(call: &RuntimeCall) -> bool {131 !matches!(call, RuntimeCall::Logger(LoggerCall::log { .. }))132 }133}134135parameter_types! {136 pub BlockWeights: frame_system::limits::BlockWeights =137 frame_system::limits::BlockWeights::simple_max(138 Weight::from_ref_time(2_000_000_000_000).set_proof_size(u64::MAX)139 );140}141impl system::Config for Test {142 type BaseCallFilter = BaseFilter;143 type BlockWeights = BlockWeights;144 type BlockLength = ();145 type DbWeight = RocksDbWeight;146 type RuntimeOrigin = RuntimeOrigin;147 type RuntimeCall = RuntimeCall;148 type Index = u64;149 type BlockNumber = u64;150 type Hash = H256;151 type Hashing = BlakeTwo256;152 type AccountId = u64;153 type Lookup = IdentityLookup<Self::AccountId>;154 type Header = Header;155 type RuntimeEvent = RuntimeEvent;156 type BlockHashCount = ConstU64<250>;157 type Version = ();158 type PalletInfo = PalletInfo;159 type AccountData = ();160 type OnNewAccount = ();161 type OnKilledAccount = ();162 type SystemWeightInfo = ();163 type SS58Prefix = ();164 type OnSetCode = ();165 type MaxConsumers = ConstU32<16>;166}167impl logger::Config for Test {168 type RuntimeEvent = RuntimeEvent;169}170ord_parameter_types! {171 pub const One: u64 = 1;172}173174pub struct TestWeightInfo;175impl WeightInfo for TestWeightInfo {176 fn service_agendas_base() -> Weight {177 Weight::from_ref_time(0b0000_0001)178 }179 fn service_agenda_base(i: u32) -> Weight {180 Weight::from_ref_time((i << 8) as u64 + 0b0000_0010)181 }182 fn service_task_base() -> Weight {183 Weight::from_ref_time(0b0000_0100)184 }185 fn service_task_periodic() -> Weight {186 Weight::from_ref_time(0b0000_1100)187 }188 fn service_task_named() -> Weight {189 Weight::from_ref_time(0b0001_0100)190 }191 // fn service_task_fetched(s: u32) -> Weight {192 // Weight::from_ref_time((s << 8) as u64 + 0b0010_0100)193 // }194 fn execute_dispatch_signed() -> Weight {195 Weight::from_ref_time(0b0100_0000)196 }197 fn execute_dispatch_unsigned() -> Weight {198 Weight::from_ref_time(0b1000_0000)199 }200 fn schedule(_s: u32) -> Weight {201 Weight::from_ref_time(50)202 }203 fn cancel(_s: u32) -> Weight {204 Weight::from_ref_time(50)205 }206 fn schedule_named(_s: u32) -> Weight {207 Weight::from_ref_time(50)208 }209 fn cancel_named(_s: u32) -> Weight {210 Weight::from_ref_time(50)211 }212 fn change_named_priority(_s: u32) -> Weight {213 Weight::from_ref_time(50)214 }215}216parameter_types! {217 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *218 BlockWeights::get().max_block;219}220221pub struct EnsureSignedOneOrRoot;222impl<O: Into<Result<RawOrigin<u64>, O>> + From<RawOrigin<u64>>> EnsureOrigin<O>223 for EnsureSignedOneOrRoot224{225 type Success = ScheduledEnsureOriginSuccess<u64>;226 fn try_origin(o: O) -> Result<Self::Success, O> {227 o.into().and_then(|o| match o {228 RawOrigin::Root => Ok(ScheduledEnsureOriginSuccess::Root),229 RawOrigin::Signed(1) => Ok(ScheduledEnsureOriginSuccess::Signed(1)),230 r => Err(O::from(r)),231 })232 }233 #[cfg(feature = "runtime-benchmarks")]234 fn try_successful_origin() -> Result<O, ()> {235 Ok(O::from(RawOrigin::Root))236 }237}238239pub struct Executor;240impl DispatchCall<Test, sp_core::H160> for Executor {241 fn dispatch_call(242 signer: Option<u64>,243 function: RuntimeCall,244 ) -> Result<245 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,246 TransactionValidityError,247 > {248 let origin = match signer {249 Some(who) => RuntimeOrigin::signed(who),250 None => RuntimeOrigin::none(),251 };252 Ok(function.dispatch(origin))253 }254}255256impl Config for Test {257 type RuntimeEvent = RuntimeEvent;258 type RuntimeOrigin = RuntimeOrigin;259 type PalletsOrigin = OriginCaller;260 type RuntimeCall = RuntimeCall;261 type MaximumWeight = MaximumSchedulerWeight;262 type ScheduleOrigin = EnsureSignedOneOrRoot;263 type MaxScheduledPerBlock = ConstU32<10>;264 type WeightInfo = TestWeightInfo;265 type OriginPrivilegeCmp = EqualPrivilegeOnly;266 type Preimages = ();267 type PrioritySetOrigin = EnsureRoot<u64>;268 type CallExecutor = Executor;269}270271pub type LoggerCall = logger::Call<Test>;272273pub type SystemCall = frame_system::Call<Test>;274275pub fn new_test_ext() -> sp_io::TestExternalities {276 let t = system::GenesisConfig::default()277 .build_storage::<Test>()278 .unwrap();279 t.into()280}281282pub fn run_to_block(n: u64) {283 while System::block_number() < n {284 Scheduler::on_finalize(System::block_number());285 System::set_block_number(System::block_number() + 1);286 Scheduler::on_initialize(System::block_number());287 }288}289290pub fn root() -> OriginCaller {291 system::RawOrigin::Root.into()292}pallets/scheduler-v2/src/tests.rsdiffbeforeafterboth--- a/pallets/scheduler-v2/src/tests.rs
+++ b/pallets/scheduler-v2/src/tests.rs
@@ -33,6 +33,7 @@
// limitations under the License.
//! # Scheduler tests.
+#![allow(deprecated)]
use super::*;
use crate::mock::{
pallets/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;
runtime/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::{
runtime/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(_) => {
runtime/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"))]
runtime/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() {
runtime/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"] }
runtime/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);
tests/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}) => {
tests/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
tests/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;