Require a block height of at least 256
This commit is contained in:
parent
fd06bc00b3
commit
6d726fc2cc
|
@ -6,6 +6,7 @@ contract Proofs {
|
|||
uint256 private immutable timeout;
|
||||
|
||||
constructor(uint256 __period, uint256 __timeout) {
|
||||
require(block.number > 256, "Insufficient block height");
|
||||
period = __period;
|
||||
timeout = __timeout;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const { expect } = require("chai")
|
||||
const { ethers } = require("hardhat")
|
||||
const { mineBlock, minedBlockNumber } = require("./evm")
|
||||
const {
|
||||
snapshot,
|
||||
revert,
|
||||
ensureMinimumBlockHeight,
|
||||
currentTime,
|
||||
advanceTime,
|
||||
advanceTimeTo,
|
||||
|
@ -19,15 +19,9 @@ describe("Proofs", function () {
|
|||
|
||||
let proofs
|
||||
|
||||
async function ensureEnoughBlockHistory() {
|
||||
while ((await minedBlockNumber()) < 256) {
|
||||
await mineBlock()
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(async function () {
|
||||
await snapshot()
|
||||
await ensureEnoughBlockHistory()
|
||||
await ensureMinimumBlockHeight(256)
|
||||
const Proofs = await ethers.getContractFactory("TestProofs")
|
||||
proofs = await Proofs.deploy(period, timeout)
|
||||
})
|
||||
|
|
|
@ -2,8 +2,7 @@ const { expect } = require("chai")
|
|||
const { ethers, deployments } = require("hardhat")
|
||||
const { exampleRequest, exampleOffer } = require("./examples")
|
||||
const {
|
||||
mineBlock,
|
||||
minedBlockNumber,
|
||||
ensureMinimumBlockHeight,
|
||||
advanceTime,
|
||||
advanceTimeTo,
|
||||
currentTime,
|
||||
|
@ -24,15 +23,10 @@ describe("Storage", function () {
|
|||
storage = storage.connect(account)
|
||||
}
|
||||
|
||||
async function ensureEnoughBlockHistory() {
|
||||
while ((await minedBlockNumber()) < 256) {
|
||||
await mineBlock()
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(async function () {
|
||||
;[client, host] = await ethers.getSigners()
|
||||
|
||||
await ensureMinimumBlockHeight(256)
|
||||
await deployments.fixture(["TestToken", "Storage"])
|
||||
token = await ethers.getContract("TestToken")
|
||||
storage = await ethers.getContract("Storage")
|
||||
|
@ -61,8 +55,6 @@ describe("Storage", function () {
|
|||
switchAccount(client)
|
||||
await storage.selectOffer(offerId(offer))
|
||||
id = offerId(offer)
|
||||
|
||||
await ensureEnoughBlockHistory()
|
||||
})
|
||||
|
||||
describe("starting the contract", function () {
|
||||
|
|
|
@ -22,6 +22,12 @@ async function minedBlockNumber() {
|
|||
return await ethers.provider.getBlockNumber()
|
||||
}
|
||||
|
||||
async function ensureMinimumBlockHeight(height) {
|
||||
while ((await minedBlockNumber()) < height) {
|
||||
await mineBlock()
|
||||
}
|
||||
}
|
||||
|
||||
async function currentTime() {
|
||||
let block = await ethers.provider.getBlock("latest")
|
||||
return block.timestamp
|
||||
|
@ -44,6 +50,7 @@ module.exports = {
|
|||
revert,
|
||||
mineBlock,
|
||||
minedBlockNumber,
|
||||
ensureMinimumBlockHeight,
|
||||
currentTime,
|
||||
advanceTime,
|
||||
advanceTimeTo,
|
||||
|
|
Loading…
Reference in New Issue