Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ decl_storage! {
config(balances): Vec<(T::AccountId, T::Balance)>;
// ^^ begin, length, amount liquid at genesis
build(|config: &GenesisConfig<T, I>| {
assert!(
<T as Trait<I>>::ExistentialDeposit::get() > Zero::zero(),
"The existential deposit should be greater than zero."
);
for (_, balance) in &config.balances {
assert!(
*balance >= <T as Trait<I>>::ExistentialDeposit::get(),
Expand Down
5 changes: 1 addition & 4 deletions frame/balances/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub struct ExtBuilder {
impl Default for ExtBuilder {
fn default() -> Self {
Self {
existential_deposit: 0,
existential_deposit: 1,
creation_fee: 0,
monied: false,
}
Expand All @@ -120,9 +120,6 @@ impl ExtBuilder {
}
pub fn monied(mut self, monied: bool) -> Self {
self.monied = monied;
if self.existential_deposit == 0 {
self.existential_deposit = 1;
}
self
}
pub fn set_associated_consts(&self) {
Expand Down
11 changes: 8 additions & 3 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ mod tests {

let mut gas_meter = GasMeter::<Test>::with_limit(1000, 1);

let result = ctx.instantiate(0, &mut gas_meter, &code, vec![]);
let result = ctx.instantiate(1, &mut gas_meter, &code, vec![]);
assert_matches!(result, Ok(_));

let mut toks = gas_meter.tokens().iter();
Expand Down Expand Up @@ -1302,8 +1302,10 @@ mod tests {
let cfg = Config::preload();
let mut ctx = ExecutionContext::top_level(ALICE, &cfg, &vm, &loader);

ctx.overlay.set_balance(&ALICE, 1);

let result = ctx.instantiate(
0,
1,
&mut GasMeter::<Test>::with_limit(10000, 1),
&input_data_ch,
vec![1, 2, 3, 4],
Expand Down Expand Up @@ -1348,6 +1350,7 @@ mod tests {
ExtBuilder::default().build().execute_with(|| {
let cfg = Config::preload();
let mut ctx = ExecutionContext::top_level(ALICE, &cfg, &vm, &loader);
ctx.overlay.set_balance(&BOB, 1);
ctx.overlay.instantiate_contract(&BOB, recurse_ch).unwrap();

let result = ctx.call(
Expand Down Expand Up @@ -1661,8 +1664,10 @@ mod tests {
let cfg = Config::preload();
let mut ctx = ExecutionContext::top_level(ALICE, &cfg, &vm, &loader);

ctx.overlay.set_balance(&ALICE, 1);

let result = ctx.instantiate(
0,
1,
&mut GasMeter::<Test>::with_limit(10000, 1),
&rent_allowance_ch,
vec![],
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub struct ExtBuilder {
impl Default for ExtBuilder {
fn default() -> Self {
Self {
existential_deposit: 0,
existential_deposit: 1,
gas_price: 2,
block_gas_limit: 100_000_000,
transfer_fee: 0,
Expand Down
2 changes: 1 addition & 1 deletion frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ mod tests {
type ModuleToIndex = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
impl pallet_balances::Trait for Test {
Expand Down
2 changes: 1 addition & 1 deletion frame/elections/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl frame_system::Trait for Test {
}

parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
impl pallet_balances::Trait for Test {
Expand Down
2 changes: 1 addition & 1 deletion frame/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ mod tests {
type ModuleToIndex = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
impl pallet_balances::Trait for Test {
Expand Down
2 changes: 1 addition & 1 deletion frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ mod tests {
type ModuleToIndex = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
impl pallet_balances::Trait for Runtime {
Expand Down
2 changes: 1 addition & 1 deletion frame/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ mod tests {
type ModuleToIndex = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
impl pallet_balances::Trait for Test {
Expand Down
2 changes: 1 addition & 1 deletion frame/nicks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ mod tests {
type ModuleToIndex = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
impl pallet_balances::Trait for Test {
Expand Down
2 changes: 1 addition & 1 deletion frame/scored-pool/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ parameter_types! {
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();

pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
ord_parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions frame/society/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, d
use frame_support::weights::SimpleDispatchInfo;
use frame_support::traits::{
Currency, ReservableCurrency, Randomness, Get, ChangeMembers,
ExistenceRequirement::{KeepAlive, AllowDeath},
ExistenceRequirement::AllowDeath,
};
use frame_system::{self as system, ensure_signed, ensure_root};

Expand Down Expand Up @@ -788,7 +788,7 @@ decl_module! {
let mut payouts = <Payouts<T, I>>::get(&who);
if let Some((when, amount)) = payouts.first() {
if when <= &<system::Module<T>>::block_number() {
T::Currency::transfer(&Self::payouts(), &who, *amount, KeepAlive)?;
T::Currency::transfer(&Self::payouts(), &who, *amount, AllowDeath)?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gavofyork: ping on this change

The payouts transfer allow death in all the other parts of the code. I assume this was just missed.

A user should be able to get paid out using the full funds of the payouts account.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a test which was failing now that ED is non-zero, and we weren't allowing a full payout.

payouts.remove(0);
if payouts.is_empty() {
<Payouts<T, I>>::remove(&who);
Expand Down
2 changes: 1 addition & 1 deletion frame/society/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ parameter_types! {
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();

pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions frame/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub struct ExtBuilder {
impl Default for ExtBuilder {
fn default() -> Self {
Self {
existential_deposit: 0,
existential_deposit: 1,
validator_pool: false,
nominate: true,
validator_count: 2,
Expand Down Expand Up @@ -290,7 +290,7 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
self.set_associated_consts();
let mut storage = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let balance_factor = if self.existential_deposit > 0 {
let balance_factor = if self.existential_deposit > 1 {
256
} else {
1
Expand Down
5 changes: 3 additions & 2 deletions frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2066,7 +2066,8 @@ fn slash_in_old_span_does_not_deselect() {
),
reporters: vec![],
}],
&[Perbill::from_percent(100)],
// NOTE: A 100% slash here would clean up the account, causing de-registration.
&[Perbill::from_percent(95)],
1,
);

Expand Down Expand Up @@ -2272,7 +2273,7 @@ fn only_slash_for_max_in_era() {

#[test]
fn garbage_collection_after_slashing() {
ExtBuilder::default().existential_deposit(1).build().execute_with(|| {
ExtBuilder::default().existential_deposit(2).build().execute_with(|| {
assert_eq!(Balances::free_balance(11), 256_000);

on_offence_now(
Expand Down
22 changes: 13 additions & 9 deletions frame/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mod tests {

parameter_types! {
pub const CreationFee: u64 = 0;
pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
}

impl pallet_balances::Trait for Runtime {
Expand Down Expand Up @@ -394,14 +394,18 @@ mod tests {
self.set_constants();
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
pallet_balances::GenesisConfig::<Runtime> {
balances: vec![
(1, 10 * self.balance_factor),
(2, 20 * self.balance_factor),
(3, 30 * self.balance_factor),
(4, 40 * self.balance_factor),
(5, 50 * self.balance_factor),
(6, 60 * self.balance_factor)
],
balances: if self.balance_factor > 0 {
vec![
(1, 10 * self.balance_factor),
(2, 20 * self.balance_factor),
(3, 30 * self.balance_factor),
(4, 40 * self.balance_factor),
(5, 50 * self.balance_factor),
(6, 60 * self.balance_factor)
]
} else {
vec![]
},
}.assimilate_storage(&mut t).unwrap();
t.into()
}
Expand Down
2 changes: 1 addition & 1 deletion frame/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ mod tests {
type ModuleToIndex = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
impl pallet_balances::Trait for Test {
Expand Down