mirror of
https://github.com/status-im/codex-contracts-eth.git
synced 2025-02-07 14:13:28 +00:00
vault: fix transfer to self
This commit is contained in:
parent
523544a4e8
commit
f6fb441dec
@ -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