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