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.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) 2020-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//! Identity pallet benchmarking.3637#![cfg(feature = "runtime-benchmarks")]3839use super::*;4041use crate::Pallet as Identity;42use frame_benchmarking::{account, benchmarks, whitelisted_caller};43use frame_support::{44 ensure, assert_ok,45 traits::{EnsureOrigin, Get},46};47use frame_system::RawOrigin;48use sp_runtime::traits::Bounded;4950const SEED: u32 = 0;5152fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {53 frame_system::Pallet::<T>::assert_last_event(generic_event.into());54}5556// Adds `r` registrars to the Identity Pallet. These registrars will have set fees and fields.57fn add_registrars<T: Config>(r: u32) -> Result<(), &'static str> {58 for i in 0..r {59 let registrar: T::AccountId = account("registrar", i, SEED);60 let registrar_lookup = T::Lookup::unlookup(registrar.clone());61 let _ = T::Currency::make_free_balance_be(®istrar, BalanceOf::<T>::max_value());62 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();63 Identity::<T>::add_registrar(registrar_origin, registrar_lookup)?;64 Identity::<T>::set_fee(RawOrigin::Signed(registrar.clone()).into(), i, 10u32.into())?;65 let fields = IdentityFields(66 IdentityField::Display67 | IdentityField::Legal68 | IdentityField::Web69 | IdentityField::Riot70 | IdentityField::Email71 | IdentityField::PgpFingerprint72 | IdentityField::Image73 | IdentityField::Twitter,74 );75 Identity::<T>::set_fields(RawOrigin::Signed(registrar.clone()).into(), i, fields)?;76 }7778 assert_eq!(Registrars::<T>::get().len(), r as usize);79 Ok(())80}8182// Create `s` sub-accounts for the identity of `who` and return them.83// Each will have 32 bytes of raw data added to it.84fn create_sub_accounts<T: Config>(85 who: &T::AccountId,86 s: u32,87) -> Result<Vec<(T::AccountId, Data)>, &'static str> {88 let mut subs = Vec::new();89 let who_origin = RawOrigin::Signed(who.clone());90 let data = Data::Raw(vec![0; 32].try_into().unwrap());9192 for i in 0..s {93 let sub_account = account("sub", i, SEED);94 subs.push((sub_account, data.clone()));95 }9697 // Set identity so `set_subs` does not fail.98 if IdentityOf::<T>::get(who).is_none() {99 let _ = T::Currency::make_free_balance_be(who, BalanceOf::<T>::max_value() / 2u32.into());100 let info = create_identity_info::<T>(1);101 Identity::<T>::set_identity(who_origin.into(), Box::new(info))?;102 }103104 Ok(subs)105}106107// Adds `s` sub-accounts to the identity of `who`. Each will have 32 bytes of raw data added to it.108// This additionally returns the vector of sub-accounts so it can be modified if needed.109fn add_sub_accounts<T: Config>(110 who: &T::AccountId,111 s: u32,112) -> Result<Vec<(T::AccountId, Data)>, &'static str> {113 let who_origin = RawOrigin::Signed(who.clone());114 let subs = create_sub_accounts::<T>(who, s)?;115116 Identity::<T>::set_subs(who_origin.into(), subs.clone())?;117118 Ok(subs)119}120121// This creates an `IdentityInfo` object with `num_fields` extra fields.122// All data is pre-populated with some arbitrary bytes.123fn create_identity_info<T: Config>(num_fields: u32) -> IdentityInfo<T::MaxAdditionalFields> {124 let data = Data::Raw(vec![0; 32].try_into().unwrap());125126 IdentityInfo {127 additional: vec![(data.clone(), data.clone()); num_fields as usize]128 .try_into()129 .unwrap(),130 display: data.clone(),131 legal: data.clone(),132 web: data.clone(),133 riot: data.clone(),134 email: data.clone(),135 pgp_fingerprint: Some([0; 20]),136 image: data.clone(),137 twitter: data,138 }139}140141/// `Currency::minimum_balance` was used originally, but in unique-chain, we have142/// zero existential deposit, thus triggering zero bond assertion.143fn balance_unit<T: Config>() -> <T::Currency as Currency<T::AccountId>>::Balance {144 200u32.into()145}146147benchmarks! {148 add_registrar {149 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;150 ensure!(Registrars::<T>::get().len() as u32 == r, "Registrars not set up correctly.");151 let origin = T::RegistrarOrigin::try_successful_origin().unwrap();152 let account = T::Lookup::unlookup(account("registrar", r + 1, SEED));153 }: _<T::RuntimeOrigin>(origin, account)154 verify {155 ensure!(Registrars::<T>::get().len() as u32 == r + 1, "Registrars not added.");156 }157158 set_identity {159 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;160 let x in 0 .. T::MaxAdditionalFields::get();161 let caller = {162 // The target user163 let caller: T::AccountId = whitelisted_caller();164 let caller_lookup = T::Lookup::unlookup(caller.clone());165 let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();166 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());167168 // Add an initial identity169 let initial_info = create_identity_info::<T>(1);170 Identity::<T>::set_identity(caller_origin.clone(), Box::new(initial_info.clone()))?;171172 // User requests judgement from all the registrars, and they approve173 for i in 0..r {174 let registrar: T::AccountId = account("registrar", i, SEED);175 let registrar_lookup = T::Lookup::unlookup(registrar.clone());176 let balance_to_use = balance_unit::<T>() * 10u32.into();177 let _ = T::Currency::make_free_balance_be(®istrar, balance_to_use);178179 Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;180 Identity::<T>::provide_judgement(181 RawOrigin::Signed(registrar).into(),182 i,183 caller_lookup.clone(),184 Judgement::Reasonable,185 T::Hashing::hash_of(&initial_info),186 )?;187 }188 caller189 };190 }: _(RawOrigin::Signed(caller.clone()), Box::new(create_identity_info::<T>(x)))191 verify {192 assert_last_event::<T>(Event::<T>::IdentitySet { who: caller }.into());193 }194195 // We need to split `set_subs` into two benchmarks to accurately isolate the potential196 // writes caused by new or old sub accounts. The actual weight should simply be197 // the sum of these two weights.198 set_subs_new {199 let caller: T::AccountId = whitelisted_caller();200 // Create a new subs vec with s sub accounts201 let s in 0 .. T::MaxSubAccounts::get() => ();202 let subs = create_sub_accounts::<T>(&caller, s)?;203 ensure!(SubsOf::<T>::get(&caller).1.len() == 0, "Caller already has subs");204 }: set_subs(RawOrigin::Signed(caller.clone()), subs)205 verify {206 ensure!(SubsOf::<T>::get(&caller).1.len() as u32 == s, "Subs not added");207 }208209 set_subs_old {210 let caller: T::AccountId = whitelisted_caller();211 // Give them p many previous sub accounts.212 let p in 0 .. T::MaxSubAccounts::get() => {213 let _ = add_sub_accounts::<T>(&caller, p)?;214 };215 // Remove all subs.216 let subs = create_sub_accounts::<T>(&caller, 0)?;217 ensure!(218 SubsOf::<T>::get(&caller).1.len() as u32 == p,219 "Caller does have subs",220 );221 }: set_subs(RawOrigin::Signed(caller.clone()), subs)222 verify {223 ensure!(SubsOf::<T>::get(&caller).1.len() == 0, "Subs not removed");224 }225226 clear_identity {227 let caller: T::AccountId = whitelisted_caller();228 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));229 let caller_lookup = <T::Lookup as StaticLookup>::unlookup(caller.clone());230 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());231232 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;233 let s in 0 .. T::MaxSubAccounts::get() => {234 // Give them s many sub accounts235 let caller: T::AccountId = whitelisted_caller();236 let _ = add_sub_accounts::<T>(&caller, s)?;237 };238 let x in 0 .. T::MaxAdditionalFields::get();239240 // Create their main identity with x additional fields241 let info = create_identity_info::<T>(x);242 let caller: T::AccountId = whitelisted_caller();243 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));244 Identity::<T>::set_identity(caller_origin.clone(), Box::new(info.clone()))?;245246 // User requests judgement from all the registrars, and they approve247 for i in 0..r {248 let registrar: T::AccountId = account("registrar", i, SEED);249 let balance_to_use = balance_unit::<T>() * 10u32.into();250 let _ = T::Currency::make_free_balance_be(®istrar, balance_to_use);251252 Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;253 Identity::<T>::provide_judgement(254 RawOrigin::Signed(registrar).into(),255 i,256 caller_lookup.clone(),257 Judgement::Reasonable,258 T::Hashing::hash_of(&info),259 )?;260 }261 ensure!(IdentityOf::<T>::contains_key(&caller), "Identity does not exist.");262 }: _(RawOrigin::Signed(caller.clone()))263 verify {264 ensure!(!IdentityOf::<T>::contains_key(&caller), "Identity not cleared.");265 }266267 request_judgement {268 let caller: T::AccountId = whitelisted_caller();269 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());270271 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;272 let x in 0 .. T::MaxAdditionalFields::get() => {273 // Create their main identity with x additional fields274 let info = create_identity_info::<T>(x);275 let caller: T::AccountId = whitelisted_caller();276 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller));277 Identity::<T>::set_identity(caller_origin, Box::new(info))?;278 };279 }: _(RawOrigin::Signed(caller.clone()), r - 1, 10u32.into())280 verify {281 assert_last_event::<T>(Event::<T>::JudgementRequested { who: caller, registrar_index: r-1 }.into());282 }283284 cancel_request {285 let caller: T::AccountId = whitelisted_caller();286 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));287 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());288289 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;290 let x in 0 .. T::MaxAdditionalFields::get() => {291 // Create their main identity with x additional fields292 let info = create_identity_info::<T>(x);293 let caller: T::AccountId = whitelisted_caller();294 let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller));295 Identity::<T>::set_identity(caller_origin, Box::new(info))?;296 };297298 Identity::<T>::request_judgement(caller_origin, r - 1, 10u32.into())?;299 }: _(RawOrigin::Signed(caller.clone()), r - 1)300 verify {301 assert_last_event::<T>(Event::<T>::JudgementUnrequested { who: caller, registrar_index: r-1 }.into());302 }303304 set_fee {305 let caller: T::AccountId = whitelisted_caller();306 let caller_lookup = T::Lookup::unlookup(caller.clone());307308 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;309310 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();311 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;312 let registrars = Registrars::<T>::get();313 ensure!(registrars[r as usize].as_ref().unwrap().fee == 0u32.into(), "Fee already set.");314 }: _(RawOrigin::Signed(caller), r, 100u32.into())315 verify {316 let registrars = Registrars::<T>::get();317 ensure!(registrars[r as usize].as_ref().unwrap().fee == 100u32.into(), "Fee not changed.");318 }319320 set_account_id {321 let caller: T::AccountId = whitelisted_caller();322 let caller_lookup = T::Lookup::unlookup(caller.clone());323 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());324325 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;326327 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();328 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;329 let registrars = Registrars::<T>::get();330 ensure!(registrars[r as usize].as_ref().unwrap().account == caller, "id not set.");331 let new_account = T::Lookup::unlookup(account("new", 0, SEED));332 }: _(RawOrigin::Signed(caller), r, new_account)333 verify {334 let registrars = Registrars::<T>::get();335 ensure!(registrars[r as usize].as_ref().unwrap().account == account("new", 0, SEED), "id not changed.");336 }337338 set_fields {339 let caller: T::AccountId = whitelisted_caller();340 let caller_lookup = T::Lookup::unlookup(caller.clone());341 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());342343 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;344345 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();346 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;347 let fields = IdentityFields(348 IdentityField::Display | IdentityField::Legal | IdentityField::Web | IdentityField::Riot349 | IdentityField::Email | IdentityField::PgpFingerprint | IdentityField::Image | IdentityField::Twitter350 );351 let registrars = Registrars::<T>::get();352 ensure!(registrars[r as usize].as_ref().unwrap().fields == Default::default(), "fields already set.");353 }: _(RawOrigin::Signed(caller), r, fields)354 verify {355 let registrars = Registrars::<T>::get();356 ensure!(registrars[r as usize].as_ref().unwrap().fields != Default::default(), "fields not set.");357 }358359 provide_judgement {360 // The user361 let user: T::AccountId = account("user", r, SEED);362 let user_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(user.clone()));363 let user_lookup = <T::Lookup as StaticLookup>::unlookup(user.clone());364 let _ = T::Currency::make_free_balance_be(&user, BalanceOf::<T>::max_value());365366 let caller: T::AccountId = whitelisted_caller();367 let caller_lookup = T::Lookup::unlookup(caller.clone());368 let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());369370 let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;371 let x in 0 .. T::MaxAdditionalFields::get();372373 let info = create_identity_info::<T>(x);374 let info_hash = T::Hashing::hash_of(&info);375 Identity::<T>::set_identity(user_origin.clone(), Box::new(info))?;376377 let registrar_origin = T::RegistrarOrigin::try_successful_origin().unwrap();378 Identity::<T>::add_registrar(registrar_origin, caller_lookup)?;379 Identity::<T>::request_judgement(user_origin, r, 10u32.into())?;380 }: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable, info_hash)381 verify {382 assert_last_event::<T>(Event::<T>::JudgementGiven { target: user, registrar_index: r }.into())383 }384385 kill_identity {386 let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;387 let s in 0 .. T::MaxSubAccounts::get();388 let x in 0 .. T::MaxAdditionalFields::get();389390 let target: T::AccountId = account("target", 0, SEED);391 let target_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(target.clone()).into();392 let target_lookup = T::Lookup::unlookup(target.clone());393 let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());394395 let info = create_identity_info::<T>(x);396 Identity::<T>::set_identity(target_origin.clone(), Box::new(info.clone()))?;397 let _ = add_sub_accounts::<T>(&target, s)?;398399 // User requests judgement from all the registrars, and they approve400 for i in 0..r {401 let registrar: T::AccountId = account("registrar", i, SEED);402 let balance_to_use = balance_unit::<T>() * 10u32.into();403 let _ = T::Currency::make_free_balance_be(®istrar, balance_to_use);404405 Identity::<T>::request_judgement(target_origin.clone(), i, 10u32.into())?;406 Identity::<T>::provide_judgement(407 RawOrigin::Signed(registrar).into(),408 i,409 target_lookup.clone(),410 Judgement::Reasonable,411 T::Hashing::hash_of(&info),412 )?;413 }414 ensure!(IdentityOf::<T>::contains_key(&target), "Identity not set");415 let origin = T::ForceOrigin::try_successful_origin().unwrap();416 }: _<T::RuntimeOrigin>(origin, target_lookup)417 verify {418 ensure!(!IdentityOf::<T>::contains_key(&target), "Identity not removed");419 }420421 force_insert_identities {422 let x in 0 .. T::MaxAdditionalFields::get();423 let n in 0..600;424 use frame_benchmarking::account;425 let identities = (0..n).map(|i| (426 account("caller", i, SEED),427 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {428 judgements: Default::default(),429 deposit: Default::default(),430 info: create_identity_info::<T>(x),431 },432 )).collect::<Vec<_>>();433 let origin = T::ForceOrigin::try_successful_origin().unwrap();434 }: _<T::RuntimeOrigin>(origin, identities)435436 force_remove_identities {437 let x in 0 .. T::MaxAdditionalFields::get();438 let n in 0..600;439 use frame_benchmarking::account;440 let origin = T::ForceOrigin::try_successful_origin().unwrap();441 let identities = (0..n).map(|i| (442 account("caller", i, SEED),443 Registration::<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields> {444 judgements: Default::default(),445 deposit: Default::default(),446 info: create_identity_info::<T>(x),447 },448 )).collect::<Vec<_>>();449 assert_ok!(450 Identity::<T>::force_insert_identities(origin.clone(), identities.clone()),451 );452 let identities = identities.into_iter().map(|(acc, _)| acc).collect::<Vec<_>>();453 }: _<T::RuntimeOrigin>(origin, identities)454455 force_set_subs {456 let s in 0 .. T::MaxSubAccounts::get();457 let n in 0..600;458 use frame_benchmarking::account;459 let identities = (0..n).map(|i| {460 let caller: T::AccountId = account("caller", i, SEED);461 (462 caller.clone(),463 (464 BalanceOf::<T>::max_value(),465 create_sub_accounts::<T>(&caller, s).unwrap().try_into().unwrap(),466 ),467 )468 }).collect::<Vec<_>>();469 let origin = T::ForceOrigin::try_successful_origin().unwrap();470 }: _<T::RuntimeOrigin>(origin, identities)471472 add_sub {473 let s in 0 .. T::MaxSubAccounts::get() - 1;474475 let caller: T::AccountId = whitelisted_caller();476 let _ = add_sub_accounts::<T>(&caller, s)?;477 let sub = account("new_sub", 0, SEED);478 let data = Data::Raw(vec![0; 32].try_into().unwrap());479 ensure!(SubsOf::<T>::get(&caller).1.len() as u32 == s, "Subs not set.");480 }: _(RawOrigin::Signed(caller.clone()), T::Lookup::unlookup(sub), data)481 verify {482 ensure!(SubsOf::<T>::get(&caller).1.len() as u32 == s + 1, "Subs not added.");483 }484485 rename_sub {486 let s in 1 .. T::MaxSubAccounts::get();487488 let caller: T::AccountId = whitelisted_caller();489 let (sub, _) = add_sub_accounts::<T>(&caller, s)?.remove(0);490 let data = Data::Raw(vec![1; 32].try_into().unwrap());491 ensure!(SuperOf::<T>::get(&sub).unwrap().1 != data, "data already set");492 }: _(RawOrigin::Signed(caller), T::Lookup::unlookup(sub.clone()), data.clone())493 verify {494 ensure!(SuperOf::<T>::get(&sub).unwrap().1 == data, "data not set");495 }496497 remove_sub {498 let s in 1 .. T::MaxSubAccounts::get();499500 let caller: T::AccountId = whitelisted_caller();501 let (sub, _) = add_sub_accounts::<T>(&caller, s)?.remove(0);502 ensure!(SuperOf::<T>::contains_key(&sub), "Sub doesn't exists");503 }: _(RawOrigin::Signed(caller), T::Lookup::unlookup(sub.clone()))504 verify {505 ensure!(!SuperOf::<T>::contains_key(&sub), "Sub not removed");506 }507508 quit_sub {509 let s in 0 .. T::MaxSubAccounts::get() - 1;510511 let caller: T::AccountId = whitelisted_caller();512 let sup = account("super", 0, SEED);513 let _ = add_sub_accounts::<T>(&sup, s)?;514 let sup_origin = RawOrigin::Signed(sup).into();515 Identity::<T>::add_sub(sup_origin, T::Lookup::unlookup(caller.clone()), Data::Raw(vec![0; 32].try_into().unwrap()))?;516 ensure!(SuperOf::<T>::contains_key(&caller), "Sub doesn't exists");517 }: _(RawOrigin::Signed(caller.clone()))518 verify {519 ensure!(!SuperOf::<T>::contains_key(&caller), "Sub not removed");520 }521522 impl_benchmark_test_suite!(Identity, crate::tests::new_test_ext(), crate::tests::Test);523}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.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;
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;