Ensure local ethereum node has at least 256 blocks

Storage contract cannot be deployed when block height
is less than 256 blocks.
This commit is contained in:
Mark Spanbroek 2022-03-15 16:45:35 +01:00 committed by markspanbroek
parent 29698fee71
commit 438fb605c0
3 changed files with 20 additions and 10 deletions

View File

@ -1,4 +1,4 @@
module.exports = async ({ deployments, getNamedAccounts }) => { async function deployStorage({ deployments, getNamedAccounts }) {
const token = await deployments.get("TestToken") const token = await deployments.get("TestToken")
const proofPeriod = 10 const proofPeriod = 10
const proofTimeout = 5 const proofTimeout = 5
@ -19,5 +19,16 @@ module.exports = async ({ deployments, getNamedAccounts }) => {
await deployments.deploy("Storage", { args, from: deployer }) await deployments.deploy("Storage", { args, from: deployer })
} }
async function mine256blocks({ network, ethers }) {
if (network.tags.local) {
await ethers.provider.send("hardhat_mine", ["0x100"])
}
}
module.exports = async (environment) => {
await mine256blocks(environment)
await deployStorage(environment)
}
module.exports.tags = ["Storage"] module.exports.tags = ["Storage"]
module.exports.dependencies = ["TestToken"] module.exports.dependencies = ["TestToken"]

View File

@ -5,6 +5,11 @@ require("hardhat-deploy-ethers")
module.exports = { module.exports = {
solidity: "0.8.4", solidity: "0.8.4",
namedAccounts: { namedAccounts: {
deployer: { default: 0 } deployer: { default: 0 },
} },
networks: {
hardhat: {
tags: ["local"],
},
},
} }

View File

@ -1,12 +1,7 @@
const { expect } = require("chai") 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 { advanceTime, advanceTimeTo, currentTime } = require("./evm")
ensureMinimumBlockHeight,
advanceTime,
advanceTimeTo,
currentTime,
} = require("./evm")
const { requestId, offerId } = require("./ids") const { requestId, offerId } = require("./ids")
const { periodic } = require("./time") const { periodic } = require("./time")
@ -26,7 +21,6 @@ describe("Storage", function () {
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")