Merge pull request #336 from sc-forks/misc/prerelease

Misc prep for 6.0 release
update/parser
cgewecke 5 years ago committed by GitHub
commit b54b8edee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      .circleci/config.yml
  2. 3
      .gitmodules
  3. 44
      README.md
  4. 5
      lib/truffleConfig.js
  5. 11
      package.json
  6. 3
      scripts/run-zeppelin.sh
  7. 56
      test/zeppelin.js
  8. 625
      yarn.lock

@ -13,10 +13,6 @@ jobs:
name: Install dependencies
command: |
yarn
- run:
name: Get submodules
command: |
git submodule update --init
- run:
name: Run tests
command: |
@ -42,15 +38,27 @@ jobs:
# command: |
# ./scripts/run-colony.sh
# It would be nice if all this could be a shell script but Circle is
# extremely annoying about
# a) cacheing
# b) sudo
# c) scripts
# d) being in a docker container.
e2e-zeppelin:
docker:
- image: circleci/node:10.12-stretch
steps:
- checkout
- run:
name: OpenZeppelin E2E
command: |
sudo URL=$CIRCLE_REPOSITORY_URL BRANCH=$CIRCLE_BRANCH ./scripts/run-zeppelin.sh
- run: >
sudo rm -rf node_modules &&
PR_PATH=$(echo "$CIRCLE_REPOSITORY_URL#$CIRCLE_BRANCH" | sudo sed 's/git@github.com:/https:\/\/github.com\//') &&
sudo git clone https://github.com/OpenZeppelin/openzeppelin-solidity.git &&
cd openzeppelin-solidity &&
sudo sed -i 's/cat coverage\/lcov.info | npx coveralls/echo "No coveralls"/g' scripts/test.sh &&
sudo yarn &&
sudo yarn remove solidity-coverage --dev &&
sudo yarn add "$PR_PATH" --dev &&
sudo npm run coverage
workflows:
version: 2

3
.gitmodules vendored

@ -1,3 +0,0 @@
[submodule "test/sources/openzeppelin-solidity"]
path = test/sources/zeppelin
url = https://github.com/OpenZeppelin/openzeppelin-solidity

@ -4,7 +4,6 @@
[![npm version](https://badge.fury.io/js/solidity-coverage.svg)](https://badge.fury.io/js/solidity-coverage)
[![CircleCI](https://circleci.com/gh/sc-forks/solidity-coverage.svg?style=svg)](https://circleci.com/gh/sc-forks/solidity-coverage)
[![codecov](https://codecov.io/gh/sc-forks/solidity-coverage/branch/master/graph/badge.svg)](https://codecov.io/gh/sc-forks/solidity-coverage)
[![Stories in Ready](https://badge.waffle.io/sc-forks/solidity-coverage.png?label=ready&title=Ready)](https://waffle.io/sc-forks/solidity-coverage?utm_source=badge)
### Code coverage for Solidity testing
![coverage example](https://cdn-images-1.medium.com/max/800/1*uum8t-31bUaa6dTRVVhj6w.png)
@ -18,46 +17,35 @@ find discrepancies between the coverage report and your suite's behavior, please
### Install
```
$ npm install --save-dev solidity-coverage
$ npm install --save-dev solidity-coverage@beta
```
### Run
#### Option 1
```
$ ./node_modules/.bin/solidity-coverage
```
#### Option 2
```
$ $(npm bin)/solidity-coverage
$ npx solidity-coverage
```
Tests run significantly slower while coverage is being generated. Your contracts are double-compiled
and a 1 to 2 minute delay between the end of the second compilation and the beginning of test execution
is possible if your test suite is large. Large Solidity files can also take a while to instrument.
**Important: breaking change for versions >= `0.5.0`**
+ `solidity-coverage` requires compilation with `solc` >= `0.4.21`. We're prefixing our own
instrumentation events with the `emit` keyword to reduce warnings volume when running the tool.
+ Ternary conditionals (ex: `(x) ? y : z;`) no longer receive branch coverage. There's more info about
why this isn't currently possible at [solidity 3887](https://github.com/ethereum/solidity/issues/3887).
**NB:** for most projects you'll also need to configure a 'coverage' network in
truffle-config.js. See the Network Configuration guide below.
**Important: breaking change for versions >= `0.4.3`**
+ solidity-coverage now expects a globally installed truffle in your environment / on CI. If you
### Usage notes:
+ Requires Solidity pragmas >= `0.5.0`.
+ Tests run more slowly while coverage is being generated.
+ Your contracts will be double-compiled and a delay between compilation and
the beginning of test execution is possible if your contracts are large.
+ solidity-coverage expects a globally installed truffle in your environment / on CI. If you
prefer to control which Truffle version your tests are run with, please see the FAQ for
[running truffle as a local dependency](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-truffle-as-a-local-dependency).
+ Solidity fixtures / mocks / tests stored in the `tests/` directory are no longer supported. If your suite uses native Solidity testing or accesses contracts via mocks stored in `tests/` (a la Zeppelin), coverage will trigger test errors because it's unable to rewrite your contract ABIs appropriately. Mocks should be relocated to the root folder's `contracts` directory. More on why this is necessary at issue [146](https://github.com/sc-forks/solidity-coverage/issues/146)
+ Solidity fixtures / mocks stored in the `tests/` directory are no longer supported. If your suite uses native Solidity testing or accesses contracts via mocks stored in `tests/` (a la Zeppelin), coverage will trigger test errors because it's unable to rewrite your contract ABIs appropriately. Mocks should be relocated to the root folder's `contracts` directory. More on why this is necessary at issue [146](https://github.com/sc-forks/solidity-coverage/issues/146)
### Network Configuration
By default, solidity-coverage generates a stub `truffle.js` that accommodates its special gas needs and
connects to a coverage-enabled fork of the ganache-cli client called **testrpc-sc** on port 8555. This special client ships with `solidity-coverage` - there's nothing extra to download. If your tests will run on truffle's development network
using a standard `truffle.js` and ganache-cli instance, you shouldn't have to do any configuration or launch the coverage client separately. If your tests depend on logic or special options added to `truffle.js` you should declare a coverage
network there following the example below.
By default, solidity-coverage connects to a coverage-enabled fork of the ganache-cli client
called **testrpc-sc** on port 8555. (It ships with `solidity-coverage` -
there's nothing extra to download.)
In `truffle-config.js`, add a coverage network following the example below.
**Example**
```javascript

@ -9,11 +9,6 @@ module.exports = function truffleConfig(port, gasLimit, gasPrice) {
gas: ${gasLimit},
gasPrice: ${gasPrice}
}
},
compilers: {
solc: {
version: "0.5.3",
}
}
};`;
};

@ -1,6 +1,6 @@
{
"name": "solidity-coverage",
"version": "0.6.0-beta.5",
"version": "0.5.12",
"description": "",
"bin": {
"solidity-coverage": "./bin/exec.js"
@ -10,8 +10,7 @@
},
"scripts": {
"test": "mocha --timeout 60000",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --timeout 60000 --exit",
"lint": "./node_modules/.bin/eslint --fix ./"
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --timeout 60000 --exit"
},
"homepage": "https://github.com/sc-forks/solidity-coverage",
"repository": {
@ -26,7 +25,7 @@
"istanbul": "^0.4.5",
"keccakjs": "^0.2.1",
"req-cwd": "^1.0.1",
"shelljs": "^0.7.4",
"shelljs": "https://github.com/sc-forks/shelljs.git",
"sol-explore": "^1.6.2",
"solidity-parser-antlr": "^0.4.1",
"tree-kill": "^1.2.0",
@ -35,10 +34,6 @@
},
"devDependencies": {
"crypto-js": "^3.1.9-1",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-mocha": "^4.8.0",
"ethereumjs-account": "~2.0.4",
"ethereumjs-tx": "^1.2.2",
"ethereumjs-util": "^5.0.1",

@ -8,8 +8,11 @@ set -o errexit
PR_PATH=$(echo "$URL#$BRANCH" | sed 's/git@github.com:/https:\/\/github.com\//')
echo "Installing $PR_PATH"
# Circle caches really agressively?
sudo rm -rf node_modules
sudo git clone https://github.com/OpenZeppelin/openzeppelin-solidity.git
cd openzeppelin-solidity || exit
sudo rm -rf node_modules
# EDITS
# Use testrpc-sc ...

@ -1,56 +0,0 @@
/* eslint-env node, mocha */
const solc = require('solc');
const getInstrumentedVersion = require('./../lib/instrumentSolidity.js');
const util = require('./util/util.js');
describe('Battery test of production contracts: OpenZeppelin', () => {
it('should compile after instrumenting ConditionalEscrow.sol', () => {
const conditionalEscrow = getInstrumentedVersion(util.getCode('zeppelin/contracts/payment/escrow/ConditionalEscrow.sol'), 'ConditionalEscrow.sol');
const escrow = getInstrumentedVersion(util.getCode('zeppelin/contracts/payment/escrow/Escrow.sol'), 'Escrow.sol');
const safeMath = getInstrumentedVersion(util.getCode('zeppelin/contracts/math/SafeMath.sol'), 'SafeMath.sol');
const secondary = getInstrumentedVersion(util.getCode('zeppelin/contracts/ownership/Secondary.sol'), 'Secondary.sol');
const input = JSON.stringify({
language: 'Solidity',
sources: {
'ConditionalEscrow.sol': { content: conditionalEscrow.contract },
'Escrow.sol': { content: escrow.contract},
'SafeMath.sol': { content: safeMath.contract},
'Secondary.sol': { content: secondary.contract},
},
settings: {
remappings: ["math/=", "ownership/=" ]
}
});
const output = JSON.parse(solc.compile(input));
util.report(output.errors);
});
it('should compile after instrumenting FinalizableCrowdsale', () => {
const finalizableCrowdsale = getInstrumentedVersion(util.getCode('zeppelin/contracts/crowdsale/distribution/FinalizableCrowdsale.sol'), 'FinalizableCrowdsale.sol');
const timedCrowdsale = getInstrumentedVersion(util.getCode('zeppelin/contracts/crowdsale/validation/TimedCrowdsale.sol'), 'TimedCrowdsale.sol');
const safeMath = getInstrumentedVersion(util.getCode('zeppelin/contracts/math/SafeMath.sol'), 'SafeMath.sol');
const crowdsale = getInstrumentedVersion(util.getCode('zeppelin/contracts/crowdsale/Crowdsale.sol'), 'Crowdsale.sol');
const ierc20 = getInstrumentedVersion(util.getCode('zeppelin/contracts/token/ERC20/IERC20.sol'), 'IERC20.sol');
const safeErc20 = getInstrumentedVersion(util.getCode('zeppelin/contracts/token/ERC20/SafeERC20.sol'), 'SafeERC20.sol');
const reentrancyGuard = getInstrumentedVersion(util.getCode('zeppelin/contracts/utils/ReentrancyGuard.sol'), 'ReentrancyGuard.sol');
const input = JSON.stringify({
language: 'Solidity',
sources: {
'FinalizableCrowdsale.sol': { content: finalizableCrowdsale.contract },
'TimedCrowdsale.sol': { content: timedCrowdsale.contract},
'SafeMath.sol': { content: safeMath.contract},
'Crowdsale.sol': { content: crowdsale.contract},
'IERC20.sol': { content: ierc20.contract},
'SafeERC20.sol': { content: safeErc20.contract},
'ReentrancyGuard.sol': { content: reentrancyGuard.contract},
},
settings: {
remappings: ["math/=", "token/ERC20/=", "utils/=", "crowdsale/=", "validation/="]
}
});
const output = JSON.parse(solc.compile(input));
util.report(output.errors);
});
});

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save