Allow ExistentialDeposit = 0 (#6185)

* Allow ExistentialDeposit = 0

* there are better ways to check is an account exists

* fix StorageMapShim

* test account events and fix some bugs
This commit is contained in:
Xiliang Chen
2020-06-03 03:22:21 +12:00
committed by GitHub
parent 7b9add7a71
commit 6547d7a09a
6 changed files with 186 additions and 42 deletions
@@ -26,7 +26,7 @@ use sp_runtime::{
};
use sp_core::H256;
use sp_io;
use frame_support::{impl_outer_origin, parameter_types};
use frame_support::{impl_outer_origin, impl_outer_event, parameter_types};
use frame_support::traits::Get;
use frame_support::weights::{Weight, DispatchInfo, IdentityFee};
use std::cell::RefCell;
@@ -37,6 +37,17 @@ impl_outer_origin!{
pub enum Origin for Test {}
}
mod balances {
pub use crate::Event;
}
impl_outer_event! {
pub enum Event for Test {
system<T>,
balances<T>,
}
}
thread_local! {
static EXISTENTIAL_DEPOSIT: RefCell<u64> = RefCell::new(0);
}
@@ -65,7 +76,7 @@ impl frame_system::Trait for Test {
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = ();
type Event = Event;
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = ();
@@ -93,7 +104,7 @@ impl pallet_transaction_payment::Trait for Test {
impl Trait for Test {
type Balance = u64;
type DustRemoval = ();
type Event = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = system::Module<Test>;
}
@@ -138,7 +149,10 @@ impl ExtBuilder {
vec![]
},
}.assimilate_storage(&mut t).unwrap();
t.into()
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}
}