Skip to content
Snippets Groups Projects
Commit c4bedc5f authored by Cédric Moreau's avatar Cédric Moreau
Browse files

WIP: test pass

parent 373c1ce8
No related branches found
No related tags found
No related merge requests found
Pipeline #35804 failed
......@@ -248,8 +248,7 @@ pub mod pallet {
if account_data.free >= T::ExistentialDeposit::get() + price {
// The account can pay the new account price, we should:
// 1. Withdraw the "new account price" amount
// TODO: supprimer 2. Increment consumers to prevent the destruction of the account before the random id is assigned
// 3. Manage the funds collected
// 2. Manage the funds collected
let res = <pallet_balances::Pallet<T> as Currency<T::AccountId>>::withdraw(
&account_id,
price,
......@@ -261,7 +260,6 @@ pub mod pallet {
"Cannot fail because we checked that the free balance was sufficient"
);
if let Ok(imbalance) = res {
// TODO: decrement consumers?
T::OnUnbalanced::on_unbalanced(imbalance);
total_weight +=
<T as pallet::Config>::WeightInfo::on_initialize_with_balance(
......
......@@ -1034,36 +1034,25 @@ fn test_create_new_account() {
// 100 initial + 300 deposit
assert_eq!(Balances::free_balance(Treasury::account_id()), 400);
// TODO: yes we can: We can't remove the account until the random id is assigned
run_to_block(4);
// can not remove using transfer
assert_noop!(
Balances::transfer(
// can remove an account using transfer
assert_ok!(Balances::transfer(
frame_system::RawOrigin::Signed(AccountKeyring::Eve.to_account_id()).into(),
MultiAddress::Id(AccountKeyring::Alice.to_account_id()),
200
),
sp_runtime::DispatchError::ConsumerRemaining,
);
));
// Account reaped
assert_eq!(
Balances::free_balance(AccountKeyring::Eve.to_account_id()),
200
);
// can not remove using transfer_all either
assert_noop!(
Balances::transfer_all(
frame_system::RawOrigin::Signed(AccountKeyring::Eve.to_account_id()).into(),
MultiAddress::Id(AccountKeyring::Alice.to_account_id()),
false
),
sp_runtime::DispatchError::ConsumerRemaining,
0
);
// Transfer failed, so free_balance remains the same
assert_eq!(
Balances::free_balance(AccountKeyring::Eve.to_account_id()),
200
frame_system::Pallet::<Runtime>::get(&AccountKeyring::Eve.to_account_id()),
pallet_duniter_account::AccountData::default()
);
// TODO detail account removal
System::assert_has_event(RuntimeEvent::System(frame_system::Event::KilledAccount {
account: AccountKeyring::Eve.to_account_id(),
}));
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment