2022-09-21 19:57:26 +10:00
|
|
|
const { advanceTimeTo } = require("./evm")
|
|
|
|
const { slotId } = require("./ids")
|
2022-09-07 15:25:01 +10:00
|
|
|
|
2022-09-21 19:57:26 +10:00
|
|
|
async function waitUntilCancelled(expiry) {
|
|
|
|
await advanceTimeTo(expiry + 1)
|
2022-08-04 12:14:36 +10:00
|
|
|
}
|
|
|
|
|
2022-09-21 19:57:26 +10:00
|
|
|
async function waitUntilStarted(contract, numSlots, requestId, proof) {
|
|
|
|
const lastSlot = numSlots - 1
|
|
|
|
for (let i = 0; i <= lastSlot; i++) {
|
2022-09-13 17:20:07 +10:00
|
|
|
await contract.fillSlot(requestId, i, proof)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-21 19:57:26 +10:00
|
|
|
async function waitUntilFinished(contract, slotId) {
|
|
|
|
const end = (await contract.proofEnd(slotId)).toNumber()
|
|
|
|
await advanceTimeTo(end + 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function waitUntilFailed(contract, slot, maxSlotLoss) {
|
|
|
|
for (let i = 0; i <= maxSlotLoss; i++) {
|
|
|
|
slot.index = i
|
|
|
|
let id = slotId(slot)
|
|
|
|
await contract.freeSlot(id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
waitUntilCancelled,
|
|
|
|
waitUntilStarted,
|
|
|
|
waitUntilFinished,
|
|
|
|
waitUntilFailed,
|
|
|
|
}
|