mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-29 07:45:53 +00:00
Fix flaky test
Ensure that when we check whether a proof is required, the pointer isn't about to wrap.
This commit is contained in:
parent
438fb605c0
commit
2a745d7abe
@ -121,21 +121,25 @@ describe("Storage", function () {
|
|||||||
;({ periodOf, periodEnd } = periodic(period))
|
;({ periodOf, periodEnd } = periodic(period))
|
||||||
})
|
})
|
||||||
|
|
||||||
async function ensureProofIsMissing() {
|
async function waitUntilProofIsRequired() {
|
||||||
let currentPeriod = periodOf(await currentTime())
|
await advanceTimeTo(periodEnd(periodOf(await currentTime())))
|
||||||
await advanceTimeTo(periodEnd(currentPeriod))
|
while (
|
||||||
while (!(await storage.isProofRequired(id))) {
|
!(
|
||||||
|
(await storage.isProofRequired(id)) &&
|
||||||
|
(await storage.getPointer(id)) < 250
|
||||||
|
)
|
||||||
|
) {
|
||||||
await advanceTime(period)
|
await advanceTime(period)
|
||||||
}
|
}
|
||||||
let missedPeriod = periodOf(await currentTime())
|
|
||||||
await advanceTime(period)
|
|
||||||
await storage.markProofAsMissing(id, missedPeriod)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it("reduces collateral when too many proofs are missing", async function () {
|
it("reduces collateral when too many proofs are missing", async function () {
|
||||||
await storage.connect(host).startContract(id)
|
await storage.connect(host).startContract(id)
|
||||||
for (let i = 0; i < slashMisses; i++) {
|
for (let i = 0; i < slashMisses; i++) {
|
||||||
await ensureProofIsMissing()
|
await waitUntilProofIsRequired()
|
||||||
|
let missedPeriod = periodOf(await currentTime())
|
||||||
|
await advanceTime(period)
|
||||||
|
await storage.markProofAsMissing(id, missedPeriod)
|
||||||
}
|
}
|
||||||
const expectedBalance = (collateralAmount * (100 - slashPercentage)) / 100
|
const expectedBalance = (collateralAmount * (100 - slashPercentage)) / 100
|
||||||
expect(await storage.balanceOf(host.address)).to.equal(expectedBalance)
|
expect(await storage.balanceOf(host.address)).to.equal(expectedBalance)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user