Эх сурвалжийг харах

Re-enable coverage analysis (#2291)

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
Igor Yalovoy 5 жил өмнө
parent
commit
c7d99531a7

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 381 - 308
package-lock.json


+ 4 - 4
package.json

@@ -11,7 +11,7 @@
   ],
   "scripts": {
     "compile": "scripts/compile.sh",
-    "coverage": "scripts/coverage.sh",
+    "coverage": "scripts/coverage.js",
     "docs": "oz-docs",
     "docs:watch": "npm run docs watch contracts 'docs/*.hbs'",
     "prepare-docs": "scripts/prepare-docs.sh",
@@ -50,7 +50,7 @@
     "@openzeppelin/docs-utils": "^0.1.0",
     "@openzeppelin/gsn-helpers": "^0.2.3",
     "@openzeppelin/gsn-provider": "^0.1.10",
-    "@openzeppelin/test-environment": "^0.1.4",
+    "@openzeppelin/test-environment": "^0.1.5",
     "@openzeppelin/test-helpers": "^0.5.6",
     "chai": "^4.2.0",
     "eslint": "^6.5.1",
@@ -61,14 +61,14 @@
     "eslint-plugin-promise": "^4.2.1",
     "eslint-plugin-standard": "^4.0.1",
     "ethereumjs-util": "^7.0.1",
-    "ganache-core-coverage": "https://github.com/OpenZeppelin/ganache-core-coverage/releases/download/2.5.3-coverage/ganache-core-coverage-2.5.3.tgz",
+    "ganache-cli": "^6.9.1",
     "lodash.startcase": "^4.4.0",
     "lodash.zip": "^4.2.0",
     "micromatch": "^4.0.2",
     "mocha": "^8.0.1",
     "rimraf": "^3.0.2",
     "solhint": "^3.2.0",
-    "solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
+    "solidity-coverage": "^0.7.8",
     "solidity-docgen": "^0.5.3"
   },
   "dependencies": {}

+ 21 - 0
scripts/coverage.js

@@ -0,0 +1,21 @@
+#!/usr/bin/env node
+
+const { execSync } = require('child_process');
+const { runCoverage } = require('@openzeppelin/test-environment');
+
+async function main () {
+  await runCoverage(
+    ['mocks'],
+    'npm run compile',
+    './node_modules/.bin/mocha --exit --timeout 10000 --recursive'.split(' '),
+  );
+
+  if (process.env.CI) {
+    execSync('curl -s https://codecov.io/bash | bash -s -- -C "$CIRCLE_SHA1"', { stdio: 'inherit' });
+  }
+}
+
+main().catch(e => {
+  console.error(e);
+  process.exit(1);
+});

+ 0 - 25
scripts/coverage.sh

@@ -1,25 +0,0 @@
-#!/usr/bin/env bash
-
-set -o errexit -o pipefail
-
-# Executes cleanup function at script exit.
-trap cleanup EXIT
-
-cleanup() {
-  # Delete the symlink created to the allFiredEvents file solidity-coverage creates
-  rm -f allFiredEvents
-}
-
-log() {
-  echo "$*" >&2
-}
-
-# The allFiredEvents file is created inside coverageEnv, but solidity-coverage
-# expects it to be at the top level. We create a symlink to fix this
-ln -s coverageEnv/allFiredEvents allFiredEvents
-
-OZ_TEST_ENV_COVERAGE=true npx solidity-coverage || log "Test run failed"
-
-if [ "$CI" = true ]; then
-  curl -s https://codecov.io/bash | bash -s -- -C "$CIRCLE_SHA1"
-fi

+ 7 - 1
test/utils/Address.test.js

@@ -1,4 +1,4 @@
-const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
+const { accounts, contract, web3, config } = require('@openzeppelin/test-environment');
 
 const { balance, ether, expectRevert, send, expectEvent } = require('@openzeppelin/test-helpers');
 const { expect } = require('chai');
@@ -7,6 +7,8 @@ const AddressImpl = contract.fromArtifact('AddressImpl');
 const EtherReceiver = contract.fromArtifact('EtherReceiverMock');
 const CallReceiverMock = contract.fromArtifact('CallReceiverMock');
 
+const coverage = config.coverage;
+
 describe('Address', function () {
   const [ recipient, other ] = accounts;
 
@@ -137,7 +139,11 @@ describe('Address', function () {
         );
       });
 
+      // Skipped in a coverage mode due to coverage mode setting a block gas limit to 0xffffffffff
+      // which cause a mockFunctionOutOfGas function to crash Ganache and the
+      // subsequent tests before running out of gas.
       it('reverts when the called function runs out of gas', async function () {
+        if (coverage) { return this.skip(); }
         const abiEncodedCall = web3.eth.abi.encodeFunctionCall({
           name: 'mockFunctionOutOfGas',
           type: 'function',

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно