mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-09 08:43:08 +00:00
vault: lock is deleted upon withdrawal
This commit is contained in:
parent
caf86d184e
commit
16a8b020bc
@ -67,7 +67,9 @@ contract Vault {
|
||||
}
|
||||
|
||||
function withdraw(Context context, Recipient recipient) public {
|
||||
Controller controller = Controller.wrap(msg.sender);
|
||||
require(!lock(context).expiry.isFuture(), Locked());
|
||||
delete _locks[controller][context];
|
||||
uint256 amount = balance(context, recipient);
|
||||
_delete(context, recipient);
|
||||
_token.safeTransfer(Recipient.unwrap(recipient), amount);
|
||||
|
||||
@ -359,5 +359,15 @@ describe("Vault", function () {
|
||||
const extending = vault.extend(context, maximum)
|
||||
await expect(extending).to.be.revertedWith("LockExpired")
|
||||
})
|
||||
|
||||
it("deletes lock when funds are withdrawn", async function () {
|
||||
let start = await currentTime()
|
||||
let expiry = start + 10
|
||||
await vault.lockup(context, expiry, expiry)
|
||||
await advanceTimeToForNextBlock(expiry)
|
||||
await vault.withdraw(context, account.address)
|
||||
expect((await vault.lock(context))[0]).to.equal(0)
|
||||
expect((await vault.lock(context))[1]).to.equal(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user