difftreelog
fix rust tests
in: master
8 files changed
pallets/collator-selection/Cargo.tomldiffbeforeafterboth55 "frame-system/std",55 "frame-system/std",56 "log/std",56 "log/std",57 "pallet-authorship/std",57 "pallet-authorship/std",58 'pallet-aura/std',59 'pallet-balances/std',58 "pallet-session/std",60 "pallet-session/std",59 "rand/std",61 "rand/std",60 "scale-info/std",62 "scale-info/std",63 "sp-consensus-aura/std",61 "sp-runtime/std",64 "sp-runtime/std",62 "sp-staking/std",65 "sp-staking/std",63 "sp-std/std",66 "sp-std/std",pallets/collator-selection/src/mock.rsdiffbeforeafterboth--- 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 = <Self as frame_system::Config>::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 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
+
+ let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (33, ed)];
let keys = balances
.iter()
.map(|&(i, _)| {
pallets/collator-selection/src/tests.rsdiffbeforeafterboth--- 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: <Test as frame_system::Config>::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 = <Test as pallet_balances::Config>::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::<Test>::InsufficientBalance,
+ TokenError::FundsUnavailable,
);
});
}
@@ -417,10 +418,7 @@
fn authorship_event_handler() {
new_test_ext().execute_with(|| {
// put 100 in the pot + 5 for ED
- <pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::set_balance(
- &CollatorSelection::account_id(),
- 105,
- );
+ <Balances as fungible::Mutate<_>>::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
- <pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::set_balance(
- &CollatorSelection::account_id(),
- 5,
- );
+ <Balances as fungible::Mutate<_>>::set_balance(&CollatorSelection::account_id(), 5);
// 4 is the default author.
assert_eq!(Balances::free_balance(4), 100);
get_license_and_onboard(4);
pallets/foreign-assets/Cargo.tomldiffbeforeafterboth--- 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"]
pallets/identity/Cargo.tomldiffbeforeafterboth--- 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"]
pallets/identity/src/tests.rsdiffbeforeafterboth--- 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! {
pallets/inflation/src/lib.rsdiffbeforeafterboth--- a/pallets/inflation/src/lib.rs
+++ b/pallets/inflation/src/lib.rs
@@ -187,12 +187,11 @@
<NextInflationBlock<T>>::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(),
<BlockInflation<T>>::get(),
Precision::Exact,
)?;
- debug_assert!(imbalance.peek().is_zero());
}
Ok(())
pallets/inflation/src/tests.rsdiffbeforeafterboth--- 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 _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+ let _ = <Balances as Balanced<_>>::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 _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+ let _ = <Balances as Balanced<_>>::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 _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+ let _ = <Balances as Balanced<_>>::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 _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+ let _ = <Balances as Balanced<_>>::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)),
- <Balances as Currency<_>>::total_issuance()
+ <Balances as Inspect<_>>::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 _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+ let _ = <Balances as Balanced<_>>::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)),
- <Balances as Currency<_>>::total_issuance()
+ <Balances as Inspect<_>>::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 _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+ let _ = <Balances as Balanced<_>>::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 _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+ let _ = <Balances as Balanced<_>>::deposit(&1234, initial_issuance, Precision::Exact);
assert_eq!(Balances::free_balance(1234), initial_issuance);
// Start inflation as sudo