Skip to content

Commit

Permalink
fix: fixed lint
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulhakim2902 committed Oct 4, 2022
1 parent 93b8d24 commit 75f4276
Show file tree
Hide file tree
Showing 44 changed files with 587 additions and 293 deletions.
21 changes: 20 additions & 1 deletion pallets/certifications/benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ license = 'Unlicense'
targets = ['x86_64-unknown-linux-gnu']

[dependencies]
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }

pallet-assets = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
pallet-randomness-collective-flip = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18', default-features = false }

sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
Expand All @@ -26,7 +30,13 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech/su

labs = { path = '../../labs', default-features = false }
certifications = { path = '../../certifications', default-features = false }
services = { path = '../../services', default-features = false }
user-profile = { path = '../../user-profile', default-features = false }
genetic-testing = { path = '../../genetic-testing', default-features = false }
orders = { path = '../../orders', default-features = false }

primitives-profile-roles = { path = '../../../primitives/profile-roles', default-features = false }
primitives-ethereum-address = { path = '../../../primitives/ethereum-address', default-features = false }
primitives-area-code = { path = '../../../primitives/area-code', default-features = false }
traits-certifications = { path = '../../certifications/traits', default-features = false }

Expand All @@ -46,11 +56,20 @@ std = [
'frame-support/std',
'frame-system/std',

'pallet-assets/std',
'pallet-balances/std',
'pallet-timestamp/std',
'pallet-randomness-collective-flip/std',

'labs/std',
'certifications/std',
'services/std',
'user-profile/std',
'genetic-testing/std',
'orders/std',
'certifications/std',

'primitives-area-code/std',
'primitives-profile-roles/std',
'primitives-ethereum-address/std',
'traits-certifications/std',
]
4 changes: 1 addition & 3 deletions pallets/certifications/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use certifications::{CertificationInfo, Config as CertificationsConfig, Pallet a

use labs::{Config as LabsConfig, LabInfo, Pallet as Labs};

use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_benchmarking::{benchmarks, whitelisted_caller};
use frame_system::RawOrigin;

pub struct Pallet<T: Config>(Certifications<T>);
Expand Down Expand Up @@ -122,5 +122,3 @@ benchmarks! {
.unwrap();
}: delete_certification(RawOrigin::Signed(caller), _lab.certifications[0])
}

impl_benchmark_test_suite! {Pallet, crate::mock::ExternalityBuilder::build(), crate::mock::Test}
111 changes: 97 additions & 14 deletions pallets/certifications/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#![cfg(test)]

use super::*;
use frame_support::{parameter_types, traits::ConstU64, PalletId};
use pallet_balances::AccountData;
use primitives_ethereum_address::EthereumAddress;
use primitives_profile_roles::ProfileRoles;

use frame_support::parameter_types;
use sp_io::TestExternalities;
use sp_runtime::{
traits::{AccountIdLookup, IdentifyAccount, Verify},
MultiSignature,
Expand All @@ -25,6 +26,13 @@ frame_support::construct_runtime!(
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Labs: labs::{Pallet, Call, Storage, Event<T>},
Certifications: certifications::{Pallet, Call, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage},
UserProfile: user_profile::{Pallet, Call, Storage, Event<T>},
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
Orders: orders::{Pallet, Call, Storage, Event<T>},
GeneticTesting: genetic_testing::{Pallet, Call, Storage, Event<T>},
Services: services::{Pallet, Call, Storage, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
}
);

Expand Down Expand Up @@ -53,7 +61,7 @@ impl frame_system::Config for Test {
type PalletInfo = PalletInfo;
type OnNewAccount = ();
type OnKilledAccount = ();
type AccountData = ();
type AccountData = AccountData<Balance>;
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
Expand All @@ -78,26 +86,101 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
}

pub type AssetId = u32;
pub type AssetBalance = u128;

parameter_types! {
pub const ApprovalDeposit: Balance = 1;
pub const AssetDeposit: Balance = 1;
pub const MetadataDepositBase: Balance = 1;
pub const MetadataDepositPerByte: Balance = 1;
pub const StringLimit: u32 = 50;
}

impl pallet_assets::Config for Test {
type Event = Event;
type Balance = AssetBalance;
type AssetId = AssetId;
type Currency = Balances;
type ForceOrigin = frame_system::EnsureRoot<AccountId>;
type AssetAccountDeposit = ConstU64<10>;
type AssetDeposit = AssetDeposit;
type MetadataDepositBase = MetadataDepositBase;
type MetadataDepositPerByte = MetadataDepositPerByte;
type ApprovalDeposit = ApprovalDeposit;
type StringLimit = StringLimit;
type Freezer = ();
type Extra = ();
type WeightInfo = ();
}

impl pallet_randomness_collective_flip::Config for Test {}

pub type Moment = u64;
pub const MILLISECS_PER_BLOCK: Moment = 6000;
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;

parameter_types! {
pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
}

impl pallet_timestamp::Config for Test {
/// A timestamp: milliseconds since the unix epoch.
type Moment = Moment;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}

parameter_types! {
pub const LabPalletId: PalletId = PalletId(*b"dbio/lab");
}

impl labs::Config for Test {
type Event = Event;
type Currency = Balances;
type Services = ();
type Services = Services;
type Orders = Orders;
type Certifications = Certifications;
type EthereumAddress = ();
type ProfileRoles = ();
type UserProfile = ();
type EthereumAddress = EthereumAddress;
type ProfileRoles = ProfileRoles;
type UserProfile = UserProfile;
type LabWeightInfo = ();
type PalletId = LabPalletId;
}

impl services::Config for Test {
type Event = Event;
type Currency = Balances;
type ServiceOwner = Labs;
type WeightInfo = ();
}

impl certifications::Config for Test {
type Event = Event;
type CertificationOwner = Labs;
type WeightInfo = ();
}

pub struct ExternalityBuilder;
impl genetic_testing::Config for Test {
type Event = Event;
type Orders = Orders;
type RandomnessSource = RandomnessCollectiveFlip;
type GeneticTestingWeightInfo = ();
}

impl ExternalityBuilder {
pub fn build() -> TestExternalities {
let storage = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
TestExternalities::from(storage)
}
impl orders::Config for Test {
type Event = Event;
type Services = Services;
type GeneticTesting = GeneticTesting;
type Currency = Balances;
type Assets = Assets;
type OrdersWeightInfo = ();
}

impl user_profile::Config for Test {
type Event = Event;
type EthereumAddress = EthereumAddress;
type ProfileRoles = ProfileRoles;
type WeightInfo = ();
}
7 changes: 7 additions & 0 deletions pallets/doctor-certifications/benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ targets = ['x86_64-unknown-linux-gnu']

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
Expand All @@ -26,7 +27,10 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech/su

doctors = { path = '../../doctors', default-features = false }
doctor-certifications = { path = '../../doctor-certifications', default-features = false }
user-profile = { path = '../../user-profile', default-features = false }

primitives-profile-roles = { path = '../../../primitives/profile-roles', default-features = false }
primitives-ethereum-address = { path = '../../../primitives/ethereum-address', default-features = false }
primitives-area-code = { path = '../../../primitives/area-code', default-features = false }
traits-doctor-certifications = { path = '../../doctor-certifications/traits', default-features = false }

Expand All @@ -48,9 +52,12 @@ std = [

'pallet-balances/std',

'user-profile/std',
'doctors/std',
'doctor-certifications/std',

'primitives-area-code/std',
'primitives-profile-roles/std',
'primitives-ethereum-address/std',
'traits-doctor-certifications/std',
]
8 changes: 3 additions & 5 deletions pallets/doctor-certifications/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use doctor_certifications::{Config as DoctorCertificationsConfig, DoctorCertific
use doctors::Pallet as Doctors;
use doctors::{Config as DoctorsConfig, DoctorInfo};

use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_benchmarking::{benchmarks, whitelisted_caller};
use frame_system::RawOrigin;

pub struct Pallet<T: Config>(DoctorCertifications<T>);

pub trait Config: DoctorCertificationsConfig + DoctorsConfig {}

pub struct Pallet<T: Config>(DoctorCertifications<T>);

use doctor_certifications::Call;
use primitives_area_code::{CityCode, CountryCode, RegionCode};

Expand Down Expand Up @@ -116,5 +116,3 @@ benchmarks! {
.unwrap();
}: delete_certification(RawOrigin::Signed(caller), _doctor.certifications[0])
}

impl_benchmark_test_suite! {Pallet, crate::mock::ExternalityBuilder::build(), crate::mock::Test}
45 changes: 22 additions & 23 deletions pallets/doctor-certifications/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#![cfg(test)]

use super::*;

use frame_support::parameter_types;
use sp_io::TestExternalities;
use sp_runtime::{
traits::{AccountIdLookup, IdentifyAccount, Verify},
MultiSignature,
};
use pallet_balances::AccountData;

use sp_runtime::traits::{BlakeTwo256, IdentityLookup};

use primitives_ethereum_address::EthereumAddress;
use primitives_profile_roles::ProfileRoles;

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

pub type Signature = MultiSignature;
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
pub type AccountId = u64;

frame_support::construct_runtime!(
pub enum Test where
Expand All @@ -25,6 +23,7 @@ frame_support::construct_runtime!(
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Doctors: doctors::{Pallet, Call, Storage, Event<T>},
DoctorCertifications: doctor_certifications::{Pallet, Call, Storage, Event<T>},
UserProfile: user_profile::{Pallet, Call, Storage, Event<T>},
}
);

Expand All @@ -39,11 +38,11 @@ impl frame_system::Config for Test {
type BlockLength = ();
type AccountId = AccountId;
type Call = Call;
type Lookup = AccountIdLookup<AccountId, ()>;
type Lookup = IdentityLookup<Self::AccountId>;
type Index = u64;
type BlockNumber = u64;
type Hash = sp_core::H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type Hashing = BlakeTwo256;
type Header = sp_runtime::testing::Header;
type Event = Event;
type Origin = Origin;
Expand All @@ -53,7 +52,7 @@ impl frame_system::Config for Test {
type PalletInfo = PalletInfo;
type OnNewAccount = ();
type OnKilledAccount = ();
type AccountData = ();
type AccountData = AccountData<Balance>;
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
Expand Down Expand Up @@ -82,21 +81,21 @@ impl doctors::Config for Test {
type Event = Event;
type Currency = Balances;
type DoctorCertifications = DoctorCertifications;
type EthereumAddress = ();
type ProfileRoles = ();
type UserProfile = ();
type EthereumAddress = EthereumAddress;
type ProfileRoles = ProfileRoles;
type UserProfile = UserProfile;
type WeightInfo = ();
}

impl doctor_certifications::Config for Test {
type Event = Event;
type CertificationOwner = Doctors;
type DoctorCertificationOwner = Doctors;
type WeightInfo = ();
}

pub struct ExternalityBuilder;

impl ExternalityBuilder {
pub fn build() -> TestExternalities {
let storage = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
TestExternalities::from(storage)
}
impl user_profile::Config for Test {
type Event = Event;
type EthereumAddress = EthereumAddress;
type ProfileRoles = ProfileRoles;
type WeightInfo = ();
}
Loading

0 comments on commit 75f4276

Please sign in to comment.