Add test for transaction price errors with hardhat_mine (#845)

pull/846/head
cgewecke 10 months ago committed by GitHub
parent 66082b3e56
commit b1ee826ae5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      test/integration/standard.js
  2. 7
      test/sources/projects/hardhat-mine/.solcover.js
  3. 12
      test/sources/projects/hardhat-mine/contracts/Setter.sol
  4. 10
      test/sources/projects/hardhat-mine/hardhat.config.js
  5. 22
      test/sources/projects/hardhat-mine/test/testMine.js

@ -304,6 +304,22 @@ describe('Hardhat Plugin: standard use cases', function() {
verify.lineCoverage(expected); verify.lineCoverage(expected);
}) })
it('can use hardhat_mine without erroring', async function(){
mock.installFullProject('hardhat-mine');
mock.hardhatSetupEnv(this);
await this.env.run("coverage");
const expected = [
{
file: mock.pathToContract(hardhatConfig, 'Setter.sol'),
pct: 100
}
];
verify.lineCoverage(expected);
})
// This test freezes when gas-reporter is not disabled // This test freezes when gas-reporter is not disabled
it('disables hardhat-gas-reporter', async function() { it('disables hardhat-gas-reporter', async function() {
mock.installFullProject('hardhat-gas-reporter'); mock.installFullProject('hardhat-gas-reporter');

@ -0,0 +1,7 @@
// Testing hooks
const fn = (msg, config) => config.logger.log(msg);
module.exports = {
silent: process.env.SILENT ? true : false,
istanbulReporter: ['json-summary', 'text'],
}

@ -0,0 +1,12 @@
pragma solidity >=0.8.0 <0.9.0;
contract Setter {
uint x;
constructor() public {
}
function set() public {
x = 1;
}
}

@ -0,0 +1,10 @@
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-ethers");
require(__dirname + "/../plugins/nomiclabs.plugin");
module.exports = {
solidity: {
version: "0.8.17"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};

@ -0,0 +1,22 @@
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("Setter", function() {
let instance;
before(async () => {
const factory = await ethers.getContractFactory("Setter");
instance = await factory.deploy();
});
it('sets at the beginning', async function(){
await instance.set();
});
it('sets at the end', async function(){
// Mine about 50K blocks
await hre.network.provider.send('hardhat_mine', ['0xCCCC'])
await instance.set();
});
});
Loading…
Cancel
Save