mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-02-25 15:33:11 +00:00
vault: fix transfer to self
This commit is contained in:
parent
450e5308d9
commit
a83a6f4cad
@ -126,15 +126,13 @@ abstract contract VaultBase {
|
||||
require(lock.isLocked(), LockRequired());
|
||||
|
||||
Account memory sender = _getAccount(controller, fund, from);
|
||||
Account memory receiver = _getAccount(controller, fund, to);
|
||||
|
||||
require(amount <= sender.balance.available, InsufficientBalance());
|
||||
sender.balance.available -= amount;
|
||||
receiver.balance.available += amount;
|
||||
|
||||
_checkAccountInvariant(sender, lock);
|
||||
|
||||
_accounts[controller][fund][from] = sender;
|
||||
|
||||
Account memory receiver = _getAccount(controller, fund, to);
|
||||
receiver.balance.available += amount;
|
||||
_accounts[controller][fund][to] = receiver;
|
||||
}
|
||||
|
||||
|
||||
@ -292,6 +292,12 @@ describe("Vault", function () {
|
||||
expect(await vault.getBalance(fund, address3)).to.equal(amount)
|
||||
})
|
||||
|
||||
it("can transfer to self", async function () {
|
||||
await setAutomine(true)
|
||||
await vault.transfer(fund, address1, address1, amount)
|
||||
expect(await vault.getBalance(fund, address1)).to.equal(amount);
|
||||
})
|
||||
|
||||
it("does not transfer more than the balance", async function () {
|
||||
await setAutomine(true)
|
||||
await expect(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user