Clean up & fixes for Hardhat PR (#569)

pull/548/head
cgewecke 4 years ago committed by GitHub
parent 1dd95010e4
commit e106076ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      HARDHAT_README.md
  2. 7
      lib/api.js
  3. 5
      lib/collector.js
  4. 1
      plugins/hardhat.plugin.js
  5. 2
      plugins/resources/nomiclabs.ui.js
  6. 2
      plugins/resources/nomiclabs.utils.js
  7. 2
      test/integration/projects/bad-solcoverjs/hardhat.config.js
  8. 2
      test/integration/projects/ganache-solcoverjs/hardhat.config.js
  9. 2
      test/integration/projects/import-paths/hardhat.config.js
  10. 2
      test/integration/projects/libraries/hardhat.config.js
  11. 2
      test/units/hardhat/errors.js
  12. 12
      test/units/hardhat/standard.js

@ -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

@ -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

@ -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.

@ -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);

@ -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]}`,

@ -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;
}

@ -3,4 +3,4 @@ require(__dirname + "/../plugins/nomiclabs.plugin");
module.exports={
logger: process.env.SILENT ? { log: () => {} } : console,
};
};

@ -11,4 +11,4 @@ module.exports = {
}
}.
logger: process.env.SILENT ? { log: () => {} } : console,
};
};

@ -6,4 +6,4 @@ module.exports = {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
};

@ -6,4 +6,4 @@ module.exports = {
version: "0.5.15"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};
};

@ -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}`
)

@ -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(){

Loading…
Cancel
Save