From 8c9c6cf4d098ca9ec703c533fa716ecc50adb2cd Mon Sep 17 00:00:00 2001 From: runcomet Date: Tue, 19 Nov 2024 14:15:02 -0800 Subject: [PATCH] comp imports --- Cargo.lock | 3 ++- substrate/frame/alliance/Cargo.toml | 1 + substrate/frame/alliance/src/benchmarking.rs | 8 +++++--- substrate/frame/alliance/src/lib.rs | 9 ++++++++- substrate/frame/alliance/src/migration.rs | 4 +++- substrate/frame/alliance/src/mock.rs | 19 +++++++++++++++++-- substrate/frame/alliance/src/tests.rs | 4 +++- substrate/frame/alliance/src/types.rs | 2 +- 8 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad9d0f898f5b..b504ab366491 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11612,7 +11612,8 @@ dependencies = [ "pallet-collective 28.0.0", "pallet-identity 29.0.0", "parity-scale-codec", - "polkadot-sdk-frame", + "polkadot-sdk-frame 0.1.0", + "pretty_assertions", "scale-info", "sp-core 28.0.0", "sp-crypto-hashing 0.1.0", diff --git a/substrate/frame/alliance/Cargo.toml b/substrate/frame/alliance/Cargo.toml index 732a97bb8d54..9c58ca9fccbb 100644 --- a/substrate/frame/alliance/Cargo.toml +++ b/substrate/frame/alliance/Cargo.toml @@ -37,6 +37,7 @@ array-bytes = { workspace = true, default-features = true } sp-crypto-hashing = { workspace = true } pallet-balances = { workspace = true, default-features = true } pallet-collective = { workspace = true, default-features = true } +pretty_assertions = { workspace = true } [features] default = ["std"] diff --git a/substrate/frame/alliance/src/benchmarking.rs b/substrate/frame/alliance/src/benchmarking.rs index 09e2045555b6..c7a8312f648e 100644 --- a/substrate/frame/alliance/src/benchmarking.rs +++ b/substrate/frame/alliance/src/benchmarking.rs @@ -20,13 +20,15 @@ #![cfg(feature = "runtime-benchmarks")] use core::{cmp, mem::size_of}; +/* use sp_runtime::traits::{Bounded, Hash, StaticLookup}; use frame_benchmarking::{account, v2::*, BenchmarkError}; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin}; - +*/ use super::{Call as AllianceCall, Pallet as Alliance, *}; +use frame::{benchmarking::prelude::*, deps::{frame_system::{Pallet as System, RawOrigin as SystemOrigin}, frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}}}; const SEED: u32 = 0; @@ -193,7 +195,7 @@ mod benchmarks { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); - frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); + add_to_whitelist(voter_key.into()); #[extrinsic_call] _(SystemOrigin::Signed(voter), last_hash, index, approve); @@ -264,7 +266,7 @@ mod benchmarks { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); - frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); + add_to_whitelist(voter_key.into()); #[extrinsic_call] close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage); diff --git a/substrate/frame/alliance/src/lib.rs b/substrate/frame/alliance/src/lib.rs index 9c956adb3a60..4b57cd29cbeb 100644 --- a/substrate/frame/alliance/src/lib.rs +++ b/substrate/frame/alliance/src/lib.rs @@ -98,7 +98,14 @@ extern crate alloc; use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; -use frame::{prelude::*, traits::{Dispatchable, Saturating, StaticLookup, Zero}, deps::sp_runtime::DispatchError, derive::DefaultNoBound}; +use frame::{ + deps::sp_runtime::DispatchError, + prelude::*, + traits::{ + ChangeMembers, Currency, Dispatchable, InitializeMembers, OnUnbalanced, ReservableCurrency, + Saturating, StaticLookup, Zero, + }, +}; /* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; diff --git a/substrate/frame/alliance/src/migration.rs b/substrate/frame/alliance/src/migration.rs index 7f66310f5871..c0113ba88fa7 100644 --- a/substrate/frame/alliance/src/migration.rs +++ b/substrate/frame/alliance/src/migration.rs @@ -17,7 +17,7 @@ use crate::{Config, Pallet, Weight, LOG_TARGET}; //use frame_support::{pallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade}; -use frame::{prelude::*, traits::OnRuntimeUpgrade, deps::frame_support::storage::migration}; +use frame::{deps::frame_support::storage::migration, prelude::*, traits::OnRuntimeUpgrade}; use log; /// The in-code storage version. @@ -163,6 +163,8 @@ pub(crate) mod v1_to_v2 { #[cfg(test)] mod test { use super::*; + use frame::testing_prelude::assert_ok; + use pretty_assertions::assert_eq; use crate::{mock::*, MemberRole, Members}; #[test] diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index 625cabf3457f..5013e105dfbd 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -16,7 +16,7 @@ // limitations under the License. //! Test utilities - +/* pub use sp_core::H256; use sp_runtime::traits::Hash; pub use sp_runtime::{ @@ -29,6 +29,21 @@ pub use frame_support::{ traits::EitherOfDiverse, BoundedVec, }; use frame_system::{EnsureRoot, EnsureSignedBy}; +*/ +use frame::{ + deps::{ + frame_support::{traits::EitherOfDiverse, BoundedVec}, + sp_runtime::traits::{IdentifyAccount, Lazy, Verify}, + }, + runtime::{ + prelude::{ + construct_runtime, derive_impl, ord_parameter_types, parameter_types, EnsureRoot, + EnsureSignedBy, + }, + testing_prelude::BuildStorage, + }, + testing_prelude::{assert_noop, assert_ok}, +}; use pallet_identity::{ legacy::{IdentityField, IdentityInfo}, Data, IdentityOf, Judgement, SuperOf, @@ -237,7 +252,7 @@ impl Config for Test { type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, diff --git a/substrate/frame/alliance/src/tests.rs b/substrate/frame/alliance/src/tests.rs index 2397ebfe7db4..3d412f51fd8a 100644 --- a/substrate/frame/alliance/src/tests.rs +++ b/substrate/frame/alliance/src/tests.rs @@ -17,12 +17,14 @@ //! Tests for the alliance pallet. +/* use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase}; use sp_runtime::traits::BadOrigin; - +*/ use super::*; use crate::{self as alliance, mock::*}; +use frame::{testing_prelude::{assert_noop, assert_ok}, deps::{sp_runtime::DispatchError::BadOrigin, frame_system::{EventRecord, Phase}}}; type AllianceMotionEvent = pallet_collective::Event; diff --git a/substrate/frame/alliance/src/types.rs b/substrate/frame/alliance/src/types.rs index 103234c4cf20..04e4e78b6130 100644 --- a/substrate/frame/alliance/src/types.rs +++ b/substrate/frame/alliance/src/types.rs @@ -20,7 +20,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; // use frame_support::{traits::ConstU32, BoundedVec}; use scale_info::TypeInfo; // use sp_runtime::RuntimeDebug; -use frame::{runtime::prelude::ConstU32, derive::RuntimeDebug, deps::frame_support::BoundedVec}; +use frame::{deps::frame_support::BoundedVec, derive::RuntimeDebug, runtime::prelude::ConstU32}; /// A Multihash instance that only supports the basic functionality and no hashing. #[derive(