Merge branch 'master' into master

pull/116/head
c-g-e-w-e-k-e- 7 years ago committed by GitHub
commit bbb918d4f3
  1. 6
      CHANGELOG.md
  2. 2
      README.md
  3. 6
      docs/faq.md
  4. 27
      lib/app.js
  5. 2
      package-lock.json
  6. 4
      package.json
  7. 4
      test/app.js
  8. 8
      test/cli/command-options.js
  9. 3
      test/util/mockTestCommand.js

@ -1,4 +1,10 @@
# Changelog
0.2.5 / 2017-10-02
=================
* Revert vm stipend fix, it was corrupting balances. `send` & `transfer` to instrumented fallback
will fail now though.
0.2.4 / 2017-09-22
=================

@ -93,6 +93,7 @@ Solutions to common issues people run into using this tool:
+ [Using alongside HDWalletProvider](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#using-alongside-hdwalletprovider)
+ [Integrating into CI](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#continuous-integration-installing-metacoin-on-travisci-with-coveralls)
+ [Why are asserts and requires highlighted as branch points?](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#why-has-my-branch-coverage-decreased-why-is-assert-being-shown-as-a-branch-point)
+ [Why are `send` and `transfer` throwing in my tests?](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#why-are-send-and-transfer-throwing)
+ [Running testrpc-sc on its own](https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-testrpc-sc-on-its-own)
### Example reports
@ -113,3 +114,4 @@ also lint your submission with `npm run lint`. Bugs can be reported in the
+ [@adriamb](https://github.com/adriamb)
+ [@cag](https://github.com/cag)
+ [@maurelian](https://github.com/maurelian)
+ [@rudolfix](https://github.com/rudolfix)

@ -170,6 +170,12 @@ Clearly, the coverage should be the same in these situations, as the code is (fu
If an `assert` or `require` is marked with an `I` in the coverage report, then during your tests the conditional is never true. If it is marked with an `E`, then it is never false.
### Why are send and transfer throwing?
If you include contracts that have fallback function in the list of files to instrument and attempt to `send` or `transfer` to them,
the methods will throw because the instrumentation consumes more gas than these methods allow. See the `skipFiles` option in the
README to exclude these files and [issue 118](https://github.com/sc-forks/solidity-coverage/issues/118) for a more detailed discussion of
this problem.
### Running testrpc-sc on its own

@ -2,6 +2,7 @@ const shell = require('shelljs');
const fs = require('fs');
const path = require('path');
const childprocess = require('child_process');
const readline = require('readline');
const reqCwd = require('req-cwd');
const istanbul = require('istanbul');
const getInstrumentedVersion = require('./instrumentSolidity.js');
@ -188,14 +189,6 @@ class App {
shell.exec(command);
this.testsErrored = shell.error();
shell.cd('./..');
} catch (err) {
this.cleanUp(err);
}
// Get events fired during instrumented contracts execution.
try {
this.events = fs.readFileSync('./allFiredEvents').toString().split('\n');
this.events.pop();
} catch (err) {
const msg =
`
@ -216,14 +209,24 @@ class App {
const reporter = new istanbul.Reporter();
return new Promise((resolve, reject) => {
// Get events fired during instrumented contracts execution.
const stream = fs.createReadStream(`./allFiredEvents`);
stream.on('error', err => this.cleanUp('Event trace could not be read.\n' + err));
const reader = readline.createInterface({
input: stream,
});
this.events = [];
reader
.on('line', line => this.events.push(line))
.on('close', () => {
// Generate Istanbul report
try {
this.coverage.generate(this.events, `${this.workingDir}/contracts`);
const newCoverage = App.makeKeysRelative(this.coverage.coverage, this.workingDir);
const json = JSON.stringify(newCoverage);
const json = JSON.stringify(this.coverage.coverage);
fs.writeFileSync('./coverage.json', json);
collector.add(newCoverage);
collector.add(this.coverage.coverage);
reporter.add('html');
reporter.add('lcov');
reporter.add('text');
@ -234,9 +237,11 @@ class App {
});
} catch (err) {
const msg = 'There was a problem generating the coverage map / running Istanbul.\n';
console.log(err.stack);
this.cleanUp(msg + err);
}
});
});
}
// ------------------------------------------ Utils ----------------------------------------------

2
package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "solidity-coverage",
"version": "0.2.4",
"version": "0.2.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

@ -1,6 +1,6 @@
{
"name": "solidity-coverage",
"version": "0.2.4",
"version": "0.2.5",
"description": "",
"bin": {
"solidity-coverage": "./bin/exec.js"
@ -23,7 +23,7 @@
"dependencies": {
"commander": "^2.9.0",
"death": "^1.1.0",
"ethereumjs-testrpc-sc": "4.0.3",
"ethereumjs-testrpc-sc": "4.0.2",
"istanbul": "^0.4.5",
"keccakjs": "^0.2.1",
"mkdirp": "^0.5.1",

@ -78,7 +78,7 @@ describe('app', () => {
assert(pathExists('./allFiredEvents') === false, 'should start without: events log');
const testConfig = Object.assign({}, config);
testConfig.testCommand = 'mocha --timeout 5000 > /dev/null 2>&1';
testConfig.testCommand = 'mocha --timeout 5000';
testConfig.dir = './mock';
testConfig.norpc = false;
testConfig.port = 8888;
@ -281,7 +281,7 @@ describe('app', () => {
collectGarbage();
});
it('contract sends / transfers to instrumented fallback: coverage, cleanup & exit(0)', () => {
it.skip('contract sends / transfers to instrumented fallback: coverage, cleanup & exit(0)', () => {
// Validate ethereumjs-vm hack to remove gas constraints on transfer() and send()
assert(pathExists('./coverage') === false, 'should start without: coverage');
assert(pathExists('./coverage.json') === false, 'should start without: coverage.json');

@ -4,18 +4,20 @@ const assert = require('assert');
const fs = require('fs');
// Fake event for Simple.sol
const fakeEvent = {
const fakeEvent = {"address":"6d6cf716c2a7672047e15a255d4c9624db60f215","topics":["34b35f4b1a8c3eb2caa69f05fb5aadc827cedd2d8eb3bb3623b6c4bba3baec17"],"data":"00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000003a2f55736572732f757365722f53697465732f73632d666f726b732f6d657461636f696e2f636f6e7472616374732f4d657461436f696e2e736f6c000000000000"}
/* {
address: '7c548f8a5ba3a37774440587743bb50f58c7e91c',
topics: ['1accf53d733f86cbefdf38d52682bc905cf6715eb3d860be0b5b052e58b0741d'],
data: '0',
};
};*/
// Tests whether or not the testCommand option is invoked by exec.js
// Mocha's default timeout is 2000 - here we fake the creation of
// allFiredEvents at 4000.
describe('Test uses mocha', () => {
it('should run "mocha --timeout 5000" successfully', done => {
setTimeout(() => {
fs.writeFileSync('./../allFiredEvents', fakeEvent);
fs.writeFileSync('./../allFiredEvents', JSON.stringify(fakeEvent) + '\n');
done();
}, 4000);
});

@ -2,6 +2,7 @@
const fs = require('fs');
const request = require('request');
const fakeEvent = {"address":"6d6cf716c2a7672047e15a255d4c9624db60f215","topics":["34b35f4b1a8c3eb2caa69f05fb5aadc827cedd2d8eb3bb3623b6c4bba3baec17"],"data":"00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000003a2f55736572732f757365722f53697465732f73632d666f726b732f6d657461636f696e2f636f6e7472616374732f4d657461436f696e2e736f6c000000000000"}
request({
uri: 'http://localhost:8888',
@ -17,6 +18,6 @@ request({
console.error(error);
process.exit(1);
}
fs.writeFileSync('../allFiredEvents', 'foobar');
fs.writeFileSync('../allFiredEvents', JSON.stringify(fakeEvent) + '\n');
process.exit(0);
});

Loading…
Cancel
Save