mirror of
https://github.com/status-im/codex-contracts-eth.git
synced 2025-02-12 08:26:46 +00:00
vault: simplify example flow rates in test
This commit is contained in:
parent
e9b346a122
commit
9f22c56026
@ -438,8 +438,8 @@ describe("Vault", function () {
|
|||||||
let maximum
|
let maximum
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
expiry = (await currentTime()) + 20
|
expiry = (await currentTime()) + 80
|
||||||
maximum = expiry + 10
|
maximum = expiry + 20
|
||||||
await vault.lock(context, expiry, maximum)
|
await vault.lock(context, expiry, maximum)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -561,28 +561,25 @@ describe("Vault", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("rejects flow when insufficient available tokens", async function () {
|
it("rejects flow when insufficient available tokens", async function () {
|
||||||
const duration = maximum - (await currentTime())
|
|
||||||
const rate = Math.ceil(deposit / duration) + 1
|
|
||||||
await expect(
|
await expect(
|
||||||
vault.flow(context, sender, receiver, rate)
|
vault.flow(context, sender, receiver, 11)
|
||||||
).to.be.revertedWith("InsufficientBalance")
|
).to.be.revertedWith("InsufficientBalance")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("rejects total flows exceeding available tokens", async function () {
|
it("rejects total flows exceeding available tokens", async function () {
|
||||||
const duration = maximum - (await currentTime())
|
await vault.flow(context, sender, receiver, 10)
|
||||||
const rate = Math.round(((2 / 3) * deposit) / duration)
|
|
||||||
await vault.flow(context, sender, receiver, rate)
|
|
||||||
await expect(
|
await expect(
|
||||||
vault.flow(context, sender, receiver, rate)
|
vault.flow(context, sender, receiver, 1)
|
||||||
).to.be.revertedWith("InsufficientBalance")
|
).to.be.revertedWith("InsufficientBalance")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("cannot flow designated tokens", async function () {
|
it("cannot flow designated tokens", async function () {
|
||||||
await vault.designate(context, sender, deposit / 2)
|
await vault.designate(context, sender, 500)
|
||||||
const duration = maximum - (await currentTime())
|
|
||||||
const rate = Math.round(deposit / duration)
|
|
||||||
await expect(
|
await expect(
|
||||||
vault.flow(context, sender, receiver, rate)
|
vault.flow(context, sender, receiver, 5)
|
||||||
|
).not.to.be.reverted
|
||||||
|
await expect(
|
||||||
|
vault.flow(context, sender, receiver, 1)
|
||||||
).to.be.revertedWith("InsufficientBalance")
|
).to.be.revertedWith("InsufficientBalance")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user