--- a/pallets/collator-selection/Cargo.toml +++ b/pallets/collator-selection/Cargo.toml @@ -55,9 +55,12 @@ "frame-system/std", "log/std", "pallet-authorship/std", + 'pallet-aura/std', + 'pallet-balances/std', "pallet-session/std", "rand/std", "scale-info/std", + "sp-consensus-aura/std", "sp-runtime/std", "sp-staking/std", "sp-std/std", --- a/pallets/collator-selection/src/mock.rs +++ b/pallets/collator-selection/src/mock.rs @@ -102,6 +102,8 @@ parameter_types! { pub const ExistentialDeposit: u64 = 5; pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 2; + pub const MaxFreezes: u32 = 2; } impl pallet_balances::Config for Test { @@ -114,6 +116,10 @@ type MaxLocks = (); type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; + type HoldIdentifier = [u8; 16]; + type FreezeIdentifier = [u8; 16]; + type MaxHolds = MaxHolds; + type MaxFreezes = MaxFreezes; } pub struct Author4; @@ -209,6 +215,7 @@ pub const MaxXcmAllowedLocations: u32 = 16; pub AppPromotionDailyRate: Perbill = Perbill::from_rational(5u32, 10_000); pub const DayRelayBlocks: u32 = 1; + pub const LicenceBondIdentifier: [u8; 16] = *b"licenceidentifie"; } impl pallet_configuration::Config for Test { @@ -257,6 +264,7 @@ type ValidatorId = ::AccountId; type ValidatorIdOf = IdentityCollator; type ValidatorRegistration = IsRegistered; + type LicenceBondIdentifier = LicenceBondIdentifier; type WeightInfo = (); } @@ -267,7 +275,9 @@ .unwrap(); let invulnerables = vec![1, 2]; - let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)]; + let ed = ::ExistentialDeposit::get(); + + let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (33, ed)]; let keys = balances .iter() .map(|&(i, _)| { --- a/pallets/collator-selection/src/tests.rs +++ b/pallets/collator-selection/src/tests.rs @@ -34,16 +34,16 @@ use crate::{mock::*, Error}; use frame_support::{ assert_noop, assert_ok, - traits::{Currency, GenesisBuild, OnInitialize}, + traits::{fungible, GenesisBuild, OnInitialize}, }; use frame_system::RawOrigin; -use pallet_balances::Error as BalancesError; -use sp_runtime::traits::BadOrigin; +use sp_runtime::{traits::BadOrigin, TokenError}; use pallet_configuration::{ CollatorSelectionDesiredCollatorsOverride as DesiredCollators, CollatorSelectionKickThresholdOverride as KickThreshold, CollatorSelectionLicenseBondOverride as LicenseBond, }; +use scale_info::prelude::*; fn get_license_and_onboard(account_id: ::AccountId) { assert_ok!(CollatorSelection::get_license(RuntimeOrigin::signed( @@ -226,8 +226,9 @@ #[test] fn cannot_obtain_license_if_poor() { new_test_ext().execute_with(|| { + let ed = ::ExistentialDeposit::get(); assert_eq!(Balances::free_balance(&3), 100); - assert_eq!(Balances::free_balance(&33), 0); + assert_eq!(Balances::free_balance(&33), ed); // works assert_ok!(CollatorSelection::get_license(RuntimeOrigin::signed(3))); @@ -235,7 +236,7 @@ // poor assert_noop!( CollatorSelection::get_license(RuntimeOrigin::signed(33)), - BalancesError::::InsufficientBalance, + TokenError::FundsUnavailable, ); }); } @@ -417,10 +418,7 @@ fn authorship_event_handler() { new_test_ext().execute_with(|| { // put 100 in the pot + 5 for ED - as fungible::Mutate>::set_balance( - &CollatorSelection::account_id(), - 105, - ); + >::set_balance(&CollatorSelection::account_id(), 105); // 4 is the default author. assert_eq!(Balances::free_balance(4), 100); @@ -444,10 +442,7 @@ // Nothing panics, no reward when no ED in balance Authorship::on_initialize(1); // put some money into the pot at ED - as fungible::Mutate>::set_balance( - &CollatorSelection::account_id(), - 5, - ); + >::set_balance(&CollatorSelection::account_id(), 5); // 4 is the default author. assert_eq!(Balances::free_balance(4), 100); get_license_and_onboard(4); --- a/pallets/foreign-assets/Cargo.toml +++ b/pallets/foreign-assets/Cargo.toml @@ -42,5 +42,6 @@ "sp-runtime/std", "sp-std/std", "up-data-structs/std", + "xcm-executor/std" ] try-runtime = ["frame-support/try-runtime"] --- a/pallets/identity/Cargo.toml +++ b/pallets/identity/Cargo.toml @@ -46,5 +46,6 @@ "sp-io/std", "sp-runtime/std", "sp-std/std", + "pallet-balances/std", ] try-runtime = ["frame-support/try-runtime"] --- a/pallets/identity/src/tests.rs +++ b/pallets/identity/src/tests.rs @@ -106,6 +106,10 @@ type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); + type HoldIdentifier = (); + type FreezeIdentifier = (); + type MaxHolds = (); + type MaxFreezes = (); } parameter_types! { --- a/pallets/inflation/src/lib.rs +++ b/pallets/inflation/src/lib.rs @@ -187,12 +187,11 @@ >::set(inflation_start_relay_block + block_interval.into()); // First time deposit - create Treasury account so that we can call deposit_into_existing everywhere else - let imbalance = T::Currency::deposit( + let _ = T::Currency::deposit( &T::TreasuryAccountId::get(), >::get(), Precision::Exact, )?; - debug_assert!(imbalance.peek().is_zero()); } Ok(()) --- a/pallets/inflation/src/tests.rs +++ b/pallets/inflation/src/tests.rs @@ -20,7 +20,7 @@ use frame_support::{ assert_ok, parameter_types, - traits::{Currency, OnInitialize, Everything, ConstU32}, + traits::{fungible::{Balanced, Inspect}, OnInitialize, Everything, ConstU32, tokens::Precision}, weights::Weight, }; use frame_system::RawOrigin; @@ -53,6 +53,10 @@ type MaxLocks = MaxLocks; type MaxReserves = (); type ReserveIdentifier = (); + type HoldIdentifier = (); + type FreezeIdentifier = (); + type MaxHolds = (); + type MaxFreezes = (); } frame_support::construct_runtime!( @@ -141,7 +145,7 @@ fn uninitialized_inflation() { new_test_ext().execute_with(|| { let initial_issuance: u64 = 1_000_000_000; - let _ = >::deposit_creating(&1234, initial_issuance); + let _ = >::deposit(&1234, initial_issuance, Precision::Exact); assert_eq!(Balances::free_balance(1234), initial_issuance); // BlockInflation should be set after inflation is started @@ -157,7 +161,7 @@ new_test_ext().execute_with(|| { // Total issuance = 1_000_000_000 let initial_issuance: u64 = 1_000_000_000; - let _ = >::deposit_creating(&1234, initial_issuance); + let _ = >::deposit(&1234, initial_issuance, Precision::Exact); assert_eq!(Balances::free_balance(1234), initial_issuance); // BlockInflation should be set after inflation is started @@ -187,7 +191,7 @@ new_test_ext().execute_with(|| { // Total issuance = 1_000_000_000 let initial_issuance: u64 = 1_000_000_000; - let _ = >::deposit_creating(&1234, initial_issuance); + let _ = >::deposit(&1234, initial_issuance, Precision::Exact); assert_eq!(Balances::free_balance(1234), initial_issuance); MockBlockNumberProvider::set(1); @@ -218,7 +222,7 @@ new_test_ext().execute_with(|| { // Total issuance = 1_000_000_000 let initial_issuance: u64 = 1_000_000_000; - let _ = >::deposit_creating(&1234, initial_issuance); + let _ = >::deposit(&1234, initial_issuance, Precision::Exact); assert_eq!(Balances::free_balance(1234), initial_issuance); MockBlockNumberProvider::set(1); @@ -234,7 +238,7 @@ } assert_eq!( initial_issuance + (FIRST_YEAR_BLOCK_INFLATION * (YEAR / 100)), - >::total_issuance() + >::total_issuance() ); MockBlockNumberProvider::set(YEAR + 1); @@ -254,7 +258,7 @@ // Total issuance = 1_000_000_000 let initial_issuance: u64 = 1_000_000_000; let start_block: u64 = 10457457; - let _ = >::deposit_creating(&1234, initial_issuance); + let _ = >::deposit(&1234, initial_issuance, Precision::Exact); assert_eq!(Balances::free_balance(1234), initial_issuance); MockBlockNumberProvider::set(start_block); @@ -273,7 +277,7 @@ } assert_eq!( initial_issuance + (FIRST_YEAR_BLOCK_INFLATION * (YEAR / 100)), - >::total_issuance() + >::total_issuance() ); MockBlockNumberProvider::set(start_block + YEAR + 1); @@ -292,7 +296,7 @@ new_test_ext().execute_with(|| { // Total issuance = 1_000_000_000 let initial_issuance: u64 = 1_000_000_000; - let _ = >::deposit_creating(&1234, initial_issuance); + let _ = >::deposit(&1234, initial_issuance, Precision::Exact); assert_eq!(Balances::free_balance(1234), initial_issuance); MockBlockNumberProvider::set(YEAR * 9 + 1); @@ -327,7 +331,7 @@ // For accuracy total issuance = payout0 * payouts * 10; let initial_issuance: u64 = payout_by_year[0] * payouts * 10; - let _ = >::deposit_creating(&1234, initial_issuance); + let _ = >::deposit(&1234, initial_issuance, Precision::Exact); assert_eq!(Balances::free_balance(1234), initial_issuance); // Start inflation as sudo