diff --git a/Cargo.lock b/Cargo.lock index 24393d392f42f2a692251762f1b954e5287338c0..aff1b2220107f54eec3425a305566723b081ca46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5227,6 +5227,7 @@ dependencies = [ "median-accumulator", "pallet-authority-members", "pallet-authorship", + "pallet-balances", "pallet-certification", "pallet-identity", "pallet-membership", diff --git a/pallets/distance/Cargo.toml b/pallets/distance/Cargo.toml index b2cb197a9fa0959eae518e369c26273e65dde624..d426154c63b173570765bf397199b421c2147487 100644 --- a/pallets/distance/Cargo.toml +++ b/pallets/distance/Cargo.toml @@ -88,6 +88,10 @@ default-features = false git = 'https://github.com/duniter/substrate' branch = 'duniter-substrate-v0.9.32' +[dev-dependencies.pallet-balances] +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + ### DOC ### [package.metadata.docs.rs] diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs index 565c86ad584932460dbf16d9ee709a49a10626db..a45bcce4fd780b775d342665e192d2d3bcfc5b98 100644 --- a/pallets/distance/src/lib.rs +++ b/pallets/distance/src/lib.rs @@ -48,7 +48,6 @@ pub mod pallet { }; use frame_system::pallet_prelude::*; use sp_runtime::Perbill; - use std::collections::BTreeMap; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); diff --git a/pallets/distance/src/mock.rs b/pallets/distance/src/mock.rs index 363f410e523bf2497e37eb0c8b4a2337d99e7360..ae7c28f555043bd40ea9950558a892b0a30b95b2 100644 --- a/pallets/distance/src/mock.rs +++ b/pallets/distance/src/mock.rs @@ -24,14 +24,14 @@ use frame_support::{ }; use frame_system as system; use pallet_session::{ShouldEndSession, TestSessionHandler}; -use sp_core::{ConstU32, H256}; +use sp_core::{ConstU128, ConstU32, ConstU64, H256}; use sp_runtime::testing::{TestSignature, UintAuthorityId}; use sp_runtime::traits::{ConvertInto, IdentifyAccount, IsMember, Verify}; use sp_runtime::{ impl_opaque_keys, testing::Header, traits::{BlakeTwo256, IdentityLookup}, - BuildStorage, ConsensusEngineId, MultiSignature, + BuildStorage, ConsensusEngineId, MultiSignature, Perbill, }; // type AccountId = u64; @@ -44,6 +44,7 @@ pub type AccountPublic = <Signature as Verify>::Signer; // pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId; type AccountId = u64; +type Balance = u64; // type Block = frame_system::mocking::MockBlock<Test>; // type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; @@ -55,6 +56,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, + Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Session: pallet_session::{Pallet, Call, Storage, Config<T>, Event}, Authorship: pallet_authorship::{Pallet, Call, Storage}, Distance: pallet_distance::{Pallet, Call, Config<T>, Storage, Event<T>}, @@ -87,7 +89,7 @@ impl system::Config for Test { type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); + type AccountData = pallet_balances::AccountData<Balance>; type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); @@ -110,14 +112,35 @@ impl frame_support::traits::EnsureOrigin<(RuntimeOrigin, IdtyIndex, IdtyIndex)> } } +parameter_types! { + pub const ExistentialDeposit: Balance = 10; + pub const MaxLocks: u32 = 50; +} + +impl pallet_balances::Config for Test { + type Balance = Balance; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = pallet_balances::weights::SubstrateWeight<Test>; + type MaxLocks = MaxLocks; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; + type RuntimeEvent = RuntimeEvent; +} + +parameter_types! { + pub const MinAccessibleReferees: Perbill = Perbill::from_percent(80); +} + impl pallet_distance::Config for Test { type RuntimeEvent = RuntimeEvent; - type Currency = (); - type EvaluationPrice = ConstU32<100>; + type Currency = Balances; + type EvaluationPrice = ConstU64<100>; type MaxEvaluationsPerSession = ConstU32<10>; - type MaxEvaluatorsPerSession = (); - type MinAccessibleReferees = (); - type ResultExpiration = (); + type MaxEvaluatorsPerSession = frame_support::traits::ConstU32<100>; + type MinAccessibleReferees = MinAccessibleReferees; + type ResultExpiration = frame_support::traits::ConstU32<720>; } impl_opaque_keys! {