Add complex compilation test case (#563)

pull/564/head
cgewecke 4 years ago committed by GitHub
parent fefeff609d
commit 587a1f3e91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      plugins/hardhat.plugin.js
  2. 3
      plugins/resources/nomiclabs.ui.js
  3. 4
      test/integration/projects/hardhat-compile-config/.solcover.js
  4. 17
      test/integration/projects/hardhat-compile-config/contracts/ContractA1.sol
  5. 17
      test/integration/projects/hardhat-compile-config/contracts/ContractB1.sol
  6. 17
      test/integration/projects/hardhat-compile-config/contracts/ContractC1.sol
  7. 37
      test/integration/projects/hardhat-compile-config/hardhat.config.js
  8. 11
      test/integration/projects/hardhat-compile-config/test/contracta1.js
  9. 15
      test/integration/projects/hardhat-compile-config/test/contractb1.js
  10. 20
      test/integration/projects/hardhat-compile-config/test/contractc1.js
  11. 26
      test/units/hardhat/standard.js

@ -117,6 +117,8 @@ async function plugin(args, env) {
// ==============
// Compilation
// ==============
ui.report('compilation', []);
config.temp = args.temp;
const {

@ -36,6 +36,9 @@ class PluginUI extends UI {
'instr-skip': `\n${c.bold('Coverage skipped for:')}` +
`\n${c.bold('=====================')}\n`,
'compilation': `\n${c.bold('Compilation:')}` +
`\n${c.bold('============')}\n`,
'instr-skipped': `${ds} ${c.grey(args[0])}`,
'versions': `${ct} ${c.bold('ganache-core')}: ${args[0]}\n` +

@ -0,0 +1,4 @@
module.exports = {
"silent": false,
"istanbulReporter": [ "json-summary", "text"]
}

@ -0,0 +1,17 @@
pragma solidity ^0.5.0;
contract ContractA {
uint x;
constructor() public {
}
function sendFn() public {
x = 5;
}
function callFn() public pure returns (uint){
uint y = 5;
return y;
}
}

@ -0,0 +1,17 @@
pragma solidity ^0.5.0;
contract ContractB {
uint x;
constructor() public {
}
function sendFn() public {
x = 5;
}
function callFn() public pure returns (uint){
uint y = 5;
return y;
}
}

@ -0,0 +1,17 @@
pragma solidity ^0.6.0;
contract ContractC {
uint x;
constructor() public {
}
function sendFn() public {
x = 5;
}
function callFn() public pure returns (uint){
uint y = 5;
return y;
}
}

@ -0,0 +1,37 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../hardhat");
module.exports={
solidity: {
compilers: [
{
version: "0.5.5"
},
{
version: "0.5.7"
},
// Make sure optimizer gets disabled
{
version: "0.6.7",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
],
overrides: {
"contracts/ContractA.sol": {
version: "0.5.5",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
}
},
logger: process.env.SILENT ? { log: () => {} } : console,
};

@ -0,0 +1,11 @@
const ContractA = artifacts.require("ContractA");
contract("contracta", function(accounts) {
let instance;
before(async () => instance = await ContractA.new())
it('sends', async function(){
await instance.sendFn();
});
});

@ -0,0 +1,15 @@
const ContractB = artifacts.require("ContractB");
contract("contractB", function(accounts) {
let instance;
before(async () => instance = await ContractB.new())
it('sends', async function(){
await instance.sendFn();
});
it('calls', async function(){
await instance.callFn();
})
});

@ -0,0 +1,20 @@
const ContractC = artifacts.require("ContractC");
contract("contractc", function(accounts) {
let instance;
before(async () => instance = await ContractC.new())
it('sends', async function(){
await instance.sendFn();
});
it('calls', async function(){
await instance.callFn();
})
it('sends', async function(){
await instance.sendFn();
});
});

@ -395,4 +395,30 @@ describe('Hardhat Plugin: standard use cases', function() {
verify.lineCoverage(expected);
})
it('complex compiler configs', async function(){
mock.installFullProject('hardhat-compile-config');
mock.hardhatSetupEnv(this);
await this.env.run("coverage");
const expected = [
{
file: mock.pathToContract(hardhatConfig, 'ContractA1.sol'),
pct: 33.33
},
{
file: mock.pathToContract(hardhatConfig, 'ContractB1.sol'),
pct: 100,
},
{
file: mock.pathToContract(hardhatConfig, 'ContractC1.sol'),
pct: 100,
},
];
verify.lineCoverage(expected);
})
})

Loading…
Cancel
Save