From acd3c5d1fb3724ed9d520041ced516385640fd78 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Sat, 28 Aug 2021 08:36:07 -0700 Subject: [PATCH] Add test fixture for solc-8 --- test/integration/projects/solc-8/.solcover.js | 6 ++++++ .../solc-8/contracts/Contract_solc8.sol | 20 +++++++++++++++++++ .../projects/solc-8/hardhat.config.js | 9 +++++++++ .../projects/solc-8/test/test_solc8.js | 13 ++++++++++++ test/units/hardhat/standard.js | 16 +++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 test/integration/projects/solc-8/.solcover.js create mode 100644 test/integration/projects/solc-8/contracts/Contract_solc8.sol create mode 100644 test/integration/projects/solc-8/hardhat.config.js create mode 100644 test/integration/projects/solc-8/test/test_solc8.js diff --git a/test/integration/projects/solc-8/.solcover.js b/test/integration/projects/solc-8/.solcover.js new file mode 100644 index 00000000..fc5a56be --- /dev/null +++ b/test/integration/projects/solc-8/.solcover.js @@ -0,0 +1,6 @@ +module.exports = { + silent: process.env.SILENT ? true : false, + skipFiles: ['skipped-folder'], + istanbulReporter: ['json-summary', 'text'], + configureYulOptimizer: true +} diff --git a/test/integration/projects/solc-8/contracts/Contract_solc8.sol b/test/integration/projects/solc-8/contracts/Contract_solc8.sol new file mode 100644 index 00000000..90e83931 --- /dev/null +++ b/test/integration/projects/solc-8/contracts/Contract_solc8.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0 <0.9.0; +pragma abicoder v2; + +error InvalidSomeAddress(address someAddress); + +contract ContractA { + + address public someAddress; + + function throwError(address _add) external { + this; + + if (_add == address(0)) { + revert InvalidSomeAddress(_add); + } + + someAddress = _add; + } +} diff --git a/test/integration/projects/solc-8/hardhat.config.js b/test/integration/projects/solc-8/hardhat.config.js new file mode 100644 index 00000000..de7e94cf --- /dev/null +++ b/test/integration/projects/solc-8/hardhat.config.js @@ -0,0 +1,9 @@ +require("@nomiclabs/hardhat-truffle5"); +require(__dirname + "/../plugins/nomiclabs.plugin"); + +module.exports = { + solidity: { + version: "0.8.5" + }, + logger: process.env.SILENT ? { log: () => {} } : console, +}; diff --git a/test/integration/projects/solc-8/test/test_solc8.js b/test/integration/projects/solc-8/test/test_solc8.js new file mode 100644 index 00000000..617c2bd9 --- /dev/null +++ b/test/integration/projects/solc-8/test/test_solc8.js @@ -0,0 +1,13 @@ +const ContractA = artifacts.require("ContractA"); + +contract("contracta", function(accounts) { + let a,b; + + before(async () => { + a = await ContractA.new(); + }) + + it('a:throwError', async function(){ + await a.throwError(a.address); + }); +}); diff --git a/test/units/hardhat/standard.js b/test/units/hardhat/standard.js index 24931551..faf3d3aa 100644 --- a/test/units/hardhat/standard.js +++ b/test/units/hardhat/standard.js @@ -326,6 +326,22 @@ describe('Hardhat Plugin: standard use cases', function() { verify.lineCoverage(expected); }) + it('solc 0.8.x', async function(){ + mock.installFullProject('solc-8'); + mock.hardhatSetupEnv(this); + + await this.env.run("coverage"); + + const expectedLine = [ + { + file: mock.pathToContract(hardhatConfig, 'Contract_solc8.sol'), + pct: 75 + }, + ]; + + verify.lineCoverage(expectedLine); + }); + // This test freezes when gas-reporter is not disabled it('disables hardhat-gas-reporter', async function() { mock.installFullProject('hardhat-gas-reporter');