mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
check can_dec_provider when transfer allow death (#9411)
This commit is contained in:
@@ -1484,7 +1484,7 @@ where
|
||||
// may not even be a provider.
|
||||
let allow_death = existence_requirement == ExistenceRequirement::AllowDeath;
|
||||
let allow_death =
|
||||
allow_death && !system::Pallet::<T>::is_provider_required(transactor);
|
||||
allow_death && system::Pallet::<T>::can_dec_provider(transactor);
|
||||
ensure!(
|
||||
allow_death || from_account.total() >= ed,
|
||||
Error::<T, I>::KeepAlive
|
||||
|
||||
@@ -76,6 +76,30 @@ macro_rules! decl_tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reap_failed_due_to_provider_and_consumer() {
|
||||
<$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| {
|
||||
// SCENARIO: only one provider and there are remaining consumers.
|
||||
assert_ok!(System::inc_consumers(&1));
|
||||
assert!(!System::can_dec_provider(&1));
|
||||
assert_noop!(
|
||||
<Balances as Currency<_>>::transfer(&1, &2, 10, AllowDeath),
|
||||
Error::<$test, _>::KeepAlive
|
||||
);
|
||||
assert!(System::account_exists(&1));
|
||||
assert_eq!(Balances::free_balance(1), 10);
|
||||
|
||||
// SCENARIO: more than one provider, but will not kill account due to other provider.
|
||||
assert_eq!(System::inc_providers(&1), frame_system::IncRefStatus::Existed);
|
||||
assert_eq!(System::providers(&1), 2);
|
||||
assert!(System::can_dec_provider(&1));
|
||||
assert_ok!(<Balances as Currency<_>>::transfer(&1, &2, 10, AllowDeath));
|
||||
assert_eq!(System::providers(&1), 1);
|
||||
assert!(System::account_exists(&1));
|
||||
assert_eq!(Balances::free_balance(1), 0);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn partial_locking_should_work() {
|
||||
<$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user