check can_dec_provider when transfer allow death (#9411)

This commit is contained in:
wangjj9219
2021-07-28 00:59:34 +08:00
committed by GitHub
parent 23e8088c1c
commit 32fe61306b
2 changed files with 25 additions and 1 deletions
+24
View File
@@ -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(|| {