diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index 5482389c9e54b462013cc3dbd189031f8d65ff0f..5290327c3c2fafb06d154df1cb485ec27e15cea9 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -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( diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 7e0d75935b7390963244f0019cd2edca0cbae237..797b1965d6d4a2a449ee39ea8adf49d95bab8d4a 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -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( - frame_system::RawOrigin::Signed(AccountKeyring::Eve.to_account_id()).into(), - MultiAddress::Id(AccountKeyring::Alice.to_account_id()), - 200 - ), - sp_runtime::DispatchError::ConsumerRemaining, - ); + // 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 + )); + // 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(), + })); }); }