diff --git a/HARDHAT_README.md b/HARDHAT_README.md index 5af8efb..383634f 100644 --- a/HARDHAT_README.md +++ b/HARDHAT_README.md @@ -46,7 +46,7 @@ npx hardhat coverage [options] |--------------|------------------------------------|--------------------------------| | testfiles | `--testfiles "test/registry/*.ts"` | Test file(s) to run. (Globs must be enclosed by quotes.)| | solcoverjs | `--solcoverjs ./../.solcover.js` | Relative path from working directory to config. Useful for monorepo packages that share settings. (Path must be "./" prefixed) | -| network | `--network development` | Run with a ganache client over http using network settings defined in the Hardhat config. (Hardhat is the default network) | +| network | `--network development` | Run with a ganache client over http using network settings defined in `hardhat.config.js`. (Hardhat is the default network) | ## Configuration diff --git a/lib/api.js b/lib/api.js index b0cac00..cbc83c4 100644 --- a/lib/api.js +++ b/lib/api.js @@ -49,8 +49,9 @@ class API { this.skipFiles = config.skipFiles || []; this.log = config.log || console.log; - this.gasLimit = 0x1fffffffffffff; // default "gas sent" with transactions + this.gasLimit = 0xffffffffff // default "gas sent" with transactions this.gasLimitString = "0x1fffffffffffff"; // block gas limit for ganache (higher than "gas sent") + this.gasLimitNumber = 0x1fffffffffffff; // block gas limit for Hardhat this.gasPrice = 0x01; this.istanbulFolder = config.istanbulFolder || false; @@ -283,14 +284,14 @@ class API { // Temporarily disabled because some relevant traces aren't available // (maybe bytecode cannot be found) - hardhatTraceHandler(trace, isTraceFromCall){ + /*hardhatTraceHandler(trace, isTraceFromCall){ for (const step of trace.steps){ if (trace.bytecode && trace.bytecode._pcToInstruction){ const instruction = trace.bytecode._pcToInstruction.get(step.pc) this.collector.trackHardhatEVMInstruction(instruction) } } - } + }*/ // ======== // File I/O diff --git a/lib/collector.js b/lib/collector.js index 7c4f201..077e492 100644 --- a/lib/collector.js +++ b/lib/collector.js @@ -28,16 +28,17 @@ class DataCollector { } catch (err) { /*Ignore*/ }; } + // Temporarily disabled because some relevant traces aren't available /** * Converts pushData value to string and registers in instrumentation map. * @param {HardhatEVMTraceInstruction} instruction */ - trackHardhatEVMInstruction(instruction){ + /*trackHardhatEVMInstruction(instruction){ if (instruction && instruction.pushData){ let hash = `0x` + instruction.pushData.toString('hex'); this._registerHash(hash) } - } + }*/ /** * Normalizes has string and marks hit. diff --git a/plugins/hardhat.plugin.js b/plugins/hardhat.plugin.js index 99c8fba..7c7e351 100644 --- a/plugins/hardhat.plugin.js +++ b/plugins/hardhat.plugin.js @@ -138,7 +138,6 @@ task("coverage", "Generates a code coverage report for tests") config.paths.artifacts = tempArtifactsDir; config.paths.cache = nomiclabsUtils.tempCacheDir(config); - measureCoverage = true; await env.run(TASK_COMPILE); await api.onCompileComplete(config); diff --git a/plugins/resources/nomiclabs.ui.js b/plugins/resources/nomiclabs.ui.js index 01ce0af..770fcba 100644 --- a/plugins/resources/nomiclabs.ui.js +++ b/plugins/resources/nomiclabs.ui.js @@ -81,7 +81,7 @@ class PluginUI extends UI { const kinds = { 'network-fail': `${c.red('--network argument: ')}${args[0]}` + - `${c.red(' is not a defined network in hardhat.js.')}`, + `${c.red(' is not a defined network in hardhat.config.js.')}`, 'sources-fail': `${c.red('Cannot locate expected contract sources folder: ')} ${args[0]}`, diff --git a/plugins/resources/nomiclabs.utils.js b/plugins/resources/nomiclabs.utils.js index 1100edd..6ca79bf 100644 --- a/plugins/resources/nomiclabs.utils.js +++ b/plugins/resources/nomiclabs.utils.js @@ -116,7 +116,7 @@ function configureNetworkGas(networkConfig, api){ function configureHardhatEVMGas(networkConfig, api){ networkConfig.allowUnlimitedContractSize = true; - networkConfig.blockGasLimit = api.gasLimit + networkConfig.blockGasLimit = api.gasLimitNumber; networkConfig.gas = api.gasLimit; networkConfig.gasPrice = api.gasPrice; } diff --git a/test/integration/projects/bad-solcoverjs/hardhat.config.js b/test/integration/projects/bad-solcoverjs/hardhat.config.js index 74767fd..0fb7fb0 100644 --- a/test/integration/projects/bad-solcoverjs/hardhat.config.js +++ b/test/integration/projects/bad-solcoverjs/hardhat.config.js @@ -3,4 +3,4 @@ require(__dirname + "/../plugins/nomiclabs.plugin"); module.exports={ logger: process.env.SILENT ? { log: () => {} } : console, -}; \ No newline at end of file +}; diff --git a/test/integration/projects/ganache-solcoverjs/hardhat.config.js b/test/integration/projects/ganache-solcoverjs/hardhat.config.js index ef2201e..532e386 100644 --- a/test/integration/projects/ganache-solcoverjs/hardhat.config.js +++ b/test/integration/projects/ganache-solcoverjs/hardhat.config.js @@ -11,4 +11,4 @@ module.exports = { } }. logger: process.env.SILENT ? { log: () => {} } : console, -}; \ No newline at end of file +}; diff --git a/test/integration/projects/import-paths/hardhat.config.js b/test/integration/projects/import-paths/hardhat.config.js index ff014c9..99b5f1c 100644 --- a/test/integration/projects/import-paths/hardhat.config.js +++ b/test/integration/projects/import-paths/hardhat.config.js @@ -6,4 +6,4 @@ module.exports = { version: "0.5.15" }, logger: process.env.SILENT ? { log: () => {} } : console, -}; \ No newline at end of file +}; diff --git a/test/integration/projects/libraries/hardhat.config.js b/test/integration/projects/libraries/hardhat.config.js index ff014c9..99b5f1c 100644 --- a/test/integration/projects/libraries/hardhat.config.js +++ b/test/integration/projects/libraries/hardhat.config.js @@ -6,4 +6,4 @@ module.exports = { version: "0.5.15" }, logger: process.env.SILENT ? { log: () => {} } : console, -}; \ No newline at end of file +}; diff --git a/test/units/hardhat/errors.js b/test/units/hardhat/errors.js index 5e268d3..43d8d0b 100644 --- a/test/units/hardhat/errors.js +++ b/test/units/hardhat/errors.js @@ -125,7 +125,7 @@ describe('Hardhat Plugin: error cases', function() { assert.fail(); } catch(err){ assert( - err.message.includes('is not a defined network in hardhat.js') && + err.message.includes('is not a defined network in hardhat.config.js') && err.message.includes('does-not-exist'), `Should error missing network error: ${err.message}` ) diff --git a/test/units/hardhat/standard.js b/test/units/hardhat/standard.js index f0121ce..c069fd6 100644 --- a/test/units/hardhat/standard.js +++ b/test/units/hardhat/standard.js @@ -113,14 +113,12 @@ describe('Hardhat Plugin: standard use cases', function() { await this.env.run("coverage"); - verify.coverageGenerated(hardhatConfig); + const expected = [{ + file: mock.pathToContract(hardhatConfig, 'OnlyCall.sol'), + pct: 100 + }]; - const output = mock.getOutput(hardhatConfig); - const path = Object.keys(output)[0]; - assert( - output[path].fnMap['1'].name === 'addTwo', - 'cov should map "addTwo"' - ); + verify.lineCoverage(expected); }); it('sends / transfers to instrumented fallback', async function(){