mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-05 14:53:08 +00:00
vault: burning funds
This commit is contained in:
parent
230e2140eb
commit
eb1b821346
@ -41,4 +41,11 @@ contract Vault {
|
||||
delete _available[controller][context][recipient];
|
||||
_token.safeTransfer(Recipient.unwrap(recipient), amount);
|
||||
}
|
||||
|
||||
function burn(Context context, Recipient recipient) public {
|
||||
Controller controller = Controller.wrap(msg.sender);
|
||||
uint256 amount = _available[controller][context][recipient];
|
||||
delete _available[controller][context][recipient];
|
||||
_token.safeTransfer(address(0xdead), amount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,4 +96,35 @@ describe("Vault", function () {
|
||||
expect(after).to.equal(before)
|
||||
})
|
||||
})
|
||||
|
||||
describe("burning", function () {
|
||||
const context = randomBytes(32)
|
||||
const amount = 42
|
||||
|
||||
beforeEach(async function () {
|
||||
await token.connect(account).approve(vault.address, amount)
|
||||
await vault.deposit(context, account.address, amount)
|
||||
})
|
||||
|
||||
it("can burn a deposit", async function () {
|
||||
await vault.burn(context, account.address)
|
||||
expect(await vault.balance(context, account.address)).to.equal(0)
|
||||
})
|
||||
|
||||
it("no longer allows withdrawal", async function () {
|
||||
await vault.burn(context, account.address)
|
||||
const before = await token.balanceOf(account.address)
|
||||
await vault.withdraw(context, account.address)
|
||||
const after = await token.balanceOf(account.address)
|
||||
expect(after).to.equal(before)
|
||||
})
|
||||
|
||||
it("moves the tokens to address 0xdead", async function () {
|
||||
const dead = "0x000000000000000000000000000000000000dead"
|
||||
const before = await token.balanceOf(dead)
|
||||
await vault.burn(context, account.address)
|
||||
const after = await token.balanceOf(dead)
|
||||
expect(after - before).to.equal(amount)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user