mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-07 15:53:07 +00:00
vault: extract common tests for unlocked funds
This commit is contained in:
parent
4533c82011
commit
682b65b24a
@ -34,6 +34,14 @@ describe("Vault", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("when a fund has no lock set", function () {
|
describe("when a fund has no lock set", function () {
|
||||||
|
|
||||||
|
it("does not have any balances", async function () {
|
||||||
|
const balance = await vault.getBalance(fund, account.address)
|
||||||
|
const designated = await vault.getDesignatedBalance(fund, account.address)
|
||||||
|
expect(balance).to.equal(0)
|
||||||
|
expect(designated).to.equal(0)
|
||||||
|
})
|
||||||
|
|
||||||
it("allows a lock to be set", async function () {
|
it("allows a lock to be set", async function () {
|
||||||
expiry = (await currentTime()) + 80
|
expiry = (await currentTime()) + 80
|
||||||
maximum = (await currentTime()) + 100
|
maximum = (await currentTime()) + 100
|
||||||
@ -48,49 +56,8 @@ describe("Vault", function () {
|
|||||||
await expect(locking).to.be.revertedWith("ExpiryPastMaximum")
|
await expect(locking).to.be.revertedWith("ExpiryPastMaximum")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("does not allow extending of lock", async function () {
|
describe("unlocked fund", function () {
|
||||||
await expect(
|
testUnlockedFund()
|
||||||
vault.extendLock(fund, (await currentTime()) + 1)
|
|
||||||
).to.be.revertedWith("LockRequired")
|
|
||||||
})
|
|
||||||
|
|
||||||
it("does not allow depositing of tokens", async function () {
|
|
||||||
const amount = 1000
|
|
||||||
await token.connect(controller).approve(vault.address, amount)
|
|
||||||
await expect(
|
|
||||||
vault.deposit(fund, account.address, amount)
|
|
||||||
).to.be.revertedWith("LockRequired")
|
|
||||||
})
|
|
||||||
|
|
||||||
it("does not have any balance", async function () {
|
|
||||||
const balance = await vault.getBalance(fund, account.address)
|
|
||||||
const designated = await vault.getDesignatedBalance(fund, account.address)
|
|
||||||
expect(balance).to.equal(0)
|
|
||||||
expect(designated).to.equal(0)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("does not allow designating tokens", async function () {
|
|
||||||
await expect(
|
|
||||||
vault.designate(fund, account.address, 0)
|
|
||||||
).to.be.revertedWith("LockRequired")
|
|
||||||
})
|
|
||||||
|
|
||||||
it("does not allow transfer of tokens", async function () {
|
|
||||||
await expect(
|
|
||||||
vault.transfer(fund, account.address, account2.address, 0)
|
|
||||||
).to.be.revertedWith("LockRequired")
|
|
||||||
})
|
|
||||||
|
|
||||||
it("does not allow flowing of tokens", async function () {
|
|
||||||
await expect(
|
|
||||||
vault.flow(fund, account.address, account2.address, 0)
|
|
||||||
).to.be.revertedWith("LockRequired")
|
|
||||||
})
|
|
||||||
|
|
||||||
it("does not allow burning of tokens", async function () {
|
|
||||||
await expect(vault.burn(fund, account.address)).to.be.revertedWith(
|
|
||||||
"LockRequired"
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -591,12 +558,6 @@ describe("Vault", function () {
|
|||||||
await expect(locking).to.be.revertedWith("AlreadyLocked")
|
await expect(locking).to.be.revertedWith("AlreadyLocked")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("cannot extend an expired lock", async function () {
|
|
||||||
await expire()
|
|
||||||
const extending = vault.extendLock(fund, maximum)
|
|
||||||
await expect(extending).to.be.revertedWith("LockRequired")
|
|
||||||
})
|
|
||||||
|
|
||||||
it("deletes lock when no tokens remain", async function () {
|
it("deletes lock when no tokens remain", async function () {
|
||||||
await token.connect(controller).approve(vault.address, 30)
|
await token.connect(controller).approve(vault.address, 30)
|
||||||
await vault.deposit(fund, account.address, 30)
|
await vault.deposit(fund, account.address, 30)
|
||||||
@ -660,14 +621,6 @@ describe("Vault", function () {
|
|||||||
expect(balance1After - balance1Before).to.equal(deposit - total)
|
expect(balance1After - balance1Before).to.equal(deposit - total)
|
||||||
expect(balance2After - balance2Before).to.equal(total)
|
expect(balance2After - balance2Before).to.equal(total)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("does not allow new flows to start", async function () {
|
|
||||||
await setAutomine(true)
|
|
||||||
await expire()
|
|
||||||
await expect(
|
|
||||||
vault.flow(fund, account.address, account2.address, 0)
|
|
||||||
).to.be.revertedWith("LockRequired")
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("withdrawing", function () {
|
describe("withdrawing", function () {
|
||||||
@ -759,9 +712,24 @@ describe("Vault", function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("unlocked fund", function () {
|
||||||
|
beforeEach(async function() {
|
||||||
|
setAutomine(true)
|
||||||
|
await expire()
|
||||||
|
})
|
||||||
|
|
||||||
|
testUnlockedFund()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function testUnlockedFund() {
|
||||||
|
it("does not allow extending of lock", async function () {
|
||||||
|
await expect(
|
||||||
|
vault.extendLock(fund, (await currentTime()) + 1)
|
||||||
|
).to.be.revertedWith("LockRequired")
|
||||||
|
})
|
||||||
|
|
||||||
it("does not allow depositing of tokens", async function () {
|
it("does not allow depositing of tokens", async function () {
|
||||||
setAutomine(true)
|
|
||||||
await expire()
|
|
||||||
const amount = 1000
|
const amount = 1000
|
||||||
await token.connect(controller).approve(vault.address, amount)
|
await token.connect(controller).approve(vault.address, amount)
|
||||||
await expect(
|
await expect(
|
||||||
@ -770,27 +738,27 @@ describe("Vault", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("does not allow designating tokens", async function () {
|
it("does not allow designating tokens", async function () {
|
||||||
setAutomine(true)
|
|
||||||
await expire()
|
|
||||||
await expect(
|
await expect(
|
||||||
vault.designate(fund, account.address, 0)
|
vault.designate(fund, account.address, 0)
|
||||||
).to.be.revertedWith("LockRequired")
|
).to.be.revertedWith("LockRequired")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("does not allow transfer of tokens", async function () {
|
it("does not allow transfer of tokens", async function () {
|
||||||
setAutomine(true)
|
|
||||||
await expire()
|
|
||||||
await expect(
|
await expect(
|
||||||
vault.transfer(fund, account.address, account2.address, 0)
|
vault.transfer(fund, account.address, account2.address, 0)
|
||||||
).to.be.revertedWith("LockRequired")
|
).to.be.revertedWith("LockRequired")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("does not allow new token flows to start", async function () {
|
||||||
|
await expect(
|
||||||
|
vault.flow(fund, account.address, account2.address, 0)
|
||||||
|
).to.be.revertedWith("LockRequired")
|
||||||
|
})
|
||||||
|
|
||||||
it("does not allow burning of tokens", async function () {
|
it("does not allow burning of tokens", async function () {
|
||||||
setAutomine(true)
|
|
||||||
await expire()
|
|
||||||
await expect(vault.burn(fund, account.address)).to.be.revertedWith(
|
await expect(vault.burn(fund, account.address)).to.be.revertedWith(
|
||||||
"LockRequired"
|
"LockRequired"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user