Skip to content

Commit b1ee826

Browse files
authored
Add test for transaction price errors with hardhat_mine (#845)
1 parent 66082b3 commit b1ee826

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

test/integration/standard.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,22 @@ describe('Hardhat Plugin: standard use cases', function() {
304304
verify.lineCoverage(expected);
305305
})
306306

307+
it('can use hardhat_mine without erroring', async function(){
308+
mock.installFullProject('hardhat-mine');
309+
mock.hardhatSetupEnv(this);
310+
311+
await this.env.run("coverage");
312+
313+
const expected = [
314+
{
315+
file: mock.pathToContract(hardhatConfig, 'Setter.sol'),
316+
pct: 100
317+
}
318+
];
319+
320+
verify.lineCoverage(expected);
321+
})
322+
307323
// This test freezes when gas-reporter is not disabled
308324
it('disables hardhat-gas-reporter', async function() {
309325
mock.installFullProject('hardhat-gas-reporter');
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Testing hooks
2+
const fn = (msg, config) => config.logger.log(msg);
3+
4+
module.exports = {
5+
silent: process.env.SILENT ? true : false,
6+
istanbulReporter: ['json-summary', 'text'],
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pragma solidity >=0.8.0 <0.9.0;
2+
3+
4+
contract Setter {
5+
uint x;
6+
constructor() public {
7+
}
8+
9+
function set() public {
10+
x = 1;
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require("@nomiclabs/hardhat-waffle");
2+
require("@nomiclabs/hardhat-ethers");
3+
require(__dirname + "/../plugins/nomiclabs.plugin");
4+
5+
module.exports = {
6+
solidity: {
7+
version: "0.8.17"
8+
},
9+
logger: process.env.SILENT ? { log: () => {} } : console,
10+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { expect } = require("chai");
2+
const { ethers } = require("hardhat");
3+
4+
describe("Setter", function() {
5+
let instance;
6+
7+
before(async () => {
8+
const factory = await ethers.getContractFactory("Setter");
9+
instance = await factory.deploy();
10+
});
11+
12+
it('sets at the beginning', async function(){
13+
await instance.set();
14+
});
15+
16+
it('sets at the end', async function(){
17+
// Mine about 50K blocks
18+
await hre.network.provider.send('hardhat_mine', ['0xCCCC'])
19+
await instance.set();
20+
});
21+
});
22+

0 commit comments

Comments
 (0)