Skip to content

Commit 2b14380

Browse files
authored
Auto disable buidler-gas-reporter (sc-forks#504)
1 parent 7bdcac1 commit 2b14380

File tree

7 files changed

+719
-19
lines changed

7 files changed

+719
-19
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@nomiclabs/buidler-truffle5": "^1.1.2",
4848
"@nomiclabs/buidler-web3": "^1.1.2",
4949
"@truffle/contract": "^4.0.36",
50+
"buidler-gas-reporter": "^0.1.3",
5051
"decache": "^4.5.1",
5152
"ganache-core-sc": "^2.7.0-sc.0",
5253
"mocha": "5.2.0",

plugins/resources/buidler.utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function normalizeConfig(config, args={}){
2323
config.artifactsDir = config.paths.artifacts;
2424
config.logger = config.logger ? config.logger : {log: null};
2525
config.solcoverjs = args.solcoverjs
26+
config.gasReporter = { enabled: false }
2627

2728
return config;
2829
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { loadPluginFile } = require("@nomiclabs/buidler/plugins-testing");
2+
loadPluginFile(__dirname + "/../plugins/buidler.plugin");
3+
usePlugin("@nomiclabs/buidler-truffle5");
4+
usePlugin("buidler-gas-reporter");
5+
6+
module.exports={
7+
defaultNetwork: "buidlerevm",
8+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pragma solidity ^0.5.0;
2+
3+
4+
contract ContractA {
5+
uint x;
6+
constructor() public {
7+
}
8+
9+
function sendFn() public {
10+
x = 5;
11+
}
12+
13+
function callFn() public pure returns (uint){
14+
uint y = 5;
15+
return y;
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const ContractA = artifacts.require("ContractA");
2+
3+
contract("contracta", function(accounts) {
4+
let instance;
5+
6+
before(async () => instance = await ContractA.new())
7+
8+
it('sends', async function(){
9+
await instance.sendFn();
10+
});
11+
12+
it('calls', async function(){
13+
await instance.callFn();
14+
})
15+
});

test/units/buidler/standard.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,12 @@ describe('Buidler Plugin: standard use cases', function() {
294294

295295
verify.lineCoverage(expected);
296296
})
297-
})
297+
298+
// This test freezes when gas-reporter is not disabled
299+
it('disables buidler-gas-reporter', async function() {
300+
mock.installFullProject('buidler-gas-reporter');
301+
mock.buidlerSetupEnv(this);
302+
303+
await this.env.run("coverage");
304+
});
305+
})

0 commit comments

Comments
 (0)