Run ESLint over everything

uport
Alex Rea 8 years ago
parent 5ee149775f
commit 2c3a2248c8
  1. 14
      parse.js
  2. 2
      preprocessor.js
  3. 86
      runCoveredTests.js
  4. 125
      test/conditional.js
  5. 33
      test/expressions.js
  6. 53
      test/function.js
  7. 164
      test/if.js
  8. 63
      test/loops.js
  9. 33
      test/return.js
  10. 84
      test/statements.js
  11. 291
      test/zeppelin.js

@ -16,7 +16,7 @@ function instrumentAssignmentExpression(contract, expression, instrument) {
if (expression.left.type === 'DeclarativeExpression' || expression.left.type === 'Identifier') {
// Then we need to go from bytes32 varname = (conditional expression)
// to bytes32 varname; (,varname) = (conditional expression)
if (instrument){
if (instrument) {
createOrAppendInjectionPoint(contract, expression.left.end, {
type: 'literal', string: '; (,' + expression.left.name + ')',
});
@ -66,7 +66,7 @@ function instrumentConditionalExpression(contract, expression, instrument) {
// Wrap the consequent
if (instrument){
if (instrument) {
createOrAppendInjectionPoint(contract, expression.consequent.start, {
type: 'openParen',
});
@ -112,7 +112,7 @@ function instrumentStatement(contract, expression, instrument) {
line: endline, column: endcol,
},
};
if (instrument){
if (instrument) {
createOrAppendInjectionPoint(contract, expression.start, {
type: 'statement', statementId: contract.statementId,
});
@ -127,7 +127,7 @@ function instrumentLine(contract, expression, instrument) {
const nextNewLine = startchar + contract.instrumented.slice(startchar).indexOf('\n');
const contractSnipped = contract.instrumented.slice(lastNewLine, nextNewLine);
if (instrument){
if (instrument) {
if (contract.instrumented.slice(lastNewLine, startchar).trim().length === 0 &&
contract.instrumented.slice(endchar, nextNewLine).replace(';', '').trim().length === 0) {
createOrAppendInjectionPoint(contract, lastNewLine + 1, {
@ -165,7 +165,7 @@ function instrumentFunctionDeclaration(contract, expression, instrument) {
},
},
};
if (instrument){
if (instrument) {
if (lastChar === '}') {
createOrAppendInjectionPoint(contract, expression.start + endlineDelta, {
type: 'callFunctionEvent', fnId: contract.fnId,
@ -175,7 +175,7 @@ function instrumentFunctionDeclaration(contract, expression, instrument) {
type: 'callFunctionEvent', fnId: contract.fnId,
});
}
}
}
}
function instrumentIfStatement(contract, expression, instrument) {
@ -202,7 +202,7 @@ function instrumentIfStatement(contract, expression, instrument) {
},
}],
};
if (instrument){
if (instrument) {
if (expression.consequent.type === 'BlockStatement') {
createOrAppendInjectionPoint(contract, expression.consequent.start + 1, {
type: 'callBranchEvent', branchId: contract.branchId, locationIdx: 0,

@ -26,7 +26,7 @@ module.exports.run = function r(contract) {
const ast = SolidityParser.parse(contract);
keepRunning = false;
SolExplore.traverse(ast, {
enter(node, parent) {
enter(node, parent) { // eslint-disable-line no-loop-func
// If consequents
if (node.type === 'IfStatement' && node.consequent.type !== 'BlockStatement') {
contract = blockWrap(contract, node.consequent);

@ -1,59 +1,61 @@
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var shell = require('shelljs');
var SolidityCoder = require("web3/lib/solidity/coder.js");
var fs = require('fs');
var path = require('path');
var getInstrumentedVersion = require('./instrumentSolidity.js');
var CoverageMap = require('./coverageMap.js');
var coverage = new CoverageMap();
var mkdirp = require('mkdirp');
var childprocess = require('child_process');
//PAtch our local testrpc if necessary
if (!shell.test('-e','./node_modules/ethereumjs-vm/lib/opFns.js.orig')){
console.log('patch local testrpc...')
shell.exec('patch -b ./node_modules/ethereumjs-vm/lib/opFns.js ./hookIntoEvents.patch')
const Web3 = require('web3');
const shell = require('shelljs');
const SolidityCoder = require('web3/lib/solidity/coder.js');
const getInstrumentedVersion = require('./instrumentSolidity.js');
const fs = require('fs');
const path = require('path');
const CoverageMap = require('./coverageMap.js');
const mkdirp = require('mkdirp');
const childprocess = require('child_process');
const coverage = new CoverageMap();
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
// Patch our local testrpc if necessary
if (!shell.test('-e', './node_modules/ethereumjs-vm/lib/opFns.js.orig')) {
console.log('patch local testrpc...');
shell.exec('patch -b ./node_modules/ethereumjs-vm/lib/opFns.js ./hookIntoEvents.patch');
}
//Run the modified testrpc with large block limit
var testrpcProcess = childprocess.exec('./node_modules/ethereumjs-testrpc/bin/testrpc --gasLimit 0xfffffffffffff --gasPrice 0x1')
if (shell.test('-d','../originalContracts')){
console.log("There is already an 'originalContracts' directory in your truffle directory.\nThis is probably due to a previous solcover failure.\nPlease make sure the ./contracts/ directory contains your contracts (perhaps by copying them from originalContracts), and then delete the originalContracts directory.")
process.exit(1);
// Run the modified testrpc with large block limit
const testrpcProcess = childprocess.exec('./node_modules/ethereumjs-testrpc/bin/testrpc --gasLimit 0xfffffffffffff --gasPrice 0x1');
if (shell.test('-d', '../originalContracts')) {
console.log('There is already an "originalContracts" directory in your truffle directory.\n' +
'This is probably due to a previous solcover failure.\n' +
'Please make sure the ./contracts/ directory contains your contracts (perhaps by copying them from originalContracts), ' +
'and then delete the originalContracts directory.');
process.exit(1);
}
shell.mv('./../contracts/', './../originalContracts/');
shell.mkdir('./../contracts/');
//For each contract in originalContracts, get the instrumented version
shell.ls('./../originalContracts/**/*.sol').forEach(function(file) {
if (file !== 'originalContracts/Migrations.sol') {
var canonicalContractPath = path.resolve(file);
console.log("instrumenting ", canonicalContractPath);
var contract = fs.readFileSync(canonicalContractPath).toString();
var instrumentedContractInfo = getInstrumentedVersion(contract, canonicalContractPath, true);
mkdirp.sync(path.dirname(canonicalContractPath.replace('originalContracts', 'contracts')));
fs.writeFileSync(canonicalContractPath.replace('originalContracts','contracts'), instrumentedContractInfo.contract);
coverage.addContract(instrumentedContractInfo, canonicalContractPath);
}
// For each contract in originalContracts, get the instrumented version
shell.ls('./../originalContracts/**/*.sol').forEach(file => {
if (file !== 'originalContracts/Migrations.sol') {
const canonicalContractPath = path.resolve(file);
console.log('instrumenting ', canonicalContractPath);
const contract = fs.readFileSync(canonicalContractPath).toString();
const instrumentedContractInfo = getInstrumentedVersion(contract, canonicalContractPath, true);
mkdirp.sync(path.dirname(canonicalContractPath.replace('originalContracts', 'contracts')));
fs.writeFileSync(canonicalContractPath.replace('originalContracts', 'contracts'), instrumentedContractInfo.contract);
coverage.addContract(instrumentedContractInfo, canonicalContractPath);
}
});
shell.cp("./../originalContracts/Migrations.sol", "./../contracts/Migrations.sol");
shell.cp('./../originalContracts/Migrations.sol', './../contracts/Migrations.sol');
shell.rm('./allFiredEvents'); //Delete previous results
shell.rm('./allFiredEvents'); // Delete previous results
shell.exec('truffle test --network test');
events = fs.readFileSync('./allFiredEvents').toString().split('\n')
const events = fs.readFileSync('./allFiredEvents').toString().split('\n');
events.pop();
//The pop here isn't a bug - there is an empty line at the end of this file, so we
//don't want to include it as an event.
// The pop here isn't a bug - there is an empty line at the end of this file, so we
// don't want to include it as an event.
coverage.generate(events, './../originalContracts/');
fs.writeFileSync('./coverage.json', JSON.stringify(coverage.coverage));
shell.exec("./node_modules/istanbul/lib/cli.js report lcov")
shell.exec('./node_modules/istanbul/lib/cli.js report lcov');
testrpcProcess.kill();
shell.rm('-rf', './../contracts');
shell.mv('./../originalContracts', './../contracts');

@ -1,3 +1,5 @@
/* eslint-env node, mocha */
const solc = require('solc');
const path = require('path');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
@ -6,28 +8,35 @@ const CoverageMap = require('./../coverageMap');
const vm = require('./util/vm');
const assert = require('assert');
describe('conditional statements', function(){
describe('conditional statements', () => {
const filePath = path.resolve('./test.sol');
const pathPrefix = './';
it('should cover a conditional that reaches the consequent (same-line)', (done) => {
it('should cover a conditional that reaches the consequent (same-line)', done => {
const contract = util.getCode('conditional/sameline-consequent.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
coverage.addContract(info, filePath);
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1, 7: 1});
assert.deepEqual(mapping[filePath].b, {'1': [1, 0]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 7: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [1, 0],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover a conditional that reaches the alternate (same-line)', (done) => {
it('should cover a conditional that reaches the alternate (same-line)', done => {
const contract = util.getCode('conditional/sameline-alternate.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -35,15 +44,23 @@ describe('conditional statements', function(){
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1, 7: 1});
assert.deepEqual(mapping[filePath].b, {'1': [0, 1]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 7: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover a conditional that reaches the consequent (multi-line)', (done) => {
it('should cover a conditional that reaches the consequent (multi-line)', done => {
const contract = util.getCode('conditional/multiline-consequent.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -51,15 +68,23 @@ describe('conditional statements', function(){
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1, 7: 1});
assert.deepEqual(mapping[filePath].b, {'1': [1, 0]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 7: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [1, 0],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover a conditional that reaches the alternate (multi-line)', (done) => {
it('should cover a conditional that reaches the alternate (multi-line)', done => {
const contract = util.getCode('conditional/multiline-alternate.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -67,15 +92,23 @@ describe('conditional statements', function(){
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1, 7: 1});
assert.deepEqual(mapping[filePath].b, {'1': [0, 1]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 7: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover a DeclarativeExpression assignment by conditional that reaches the alternate', (done) => {
it('should cover a DeclarativeExpression assignment by conditional that reaches the alternate', done => {
const contract = util.getCode('conditional/declarative-exp-assignment-alternate.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -84,15 +117,23 @@ describe('conditional statements', function(){
// Runs bool z = (x) ? false : true;
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1, 7: 1});
assert.deepEqual(mapping[filePath].b, {'1': [0, 1]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 7: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover an Identifier assignment by conditional that reaches the alternate', (done) => {
it('should cover an Identifier assignment by conditional that reaches the alternate', done => {
const contract = util.getCode('conditional/identifier-assignment-alternate.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -101,18 +142,26 @@ describe('conditional statements', function(){
// Runs z = (x) ? false : true;
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1, 7: 1, 8: 1});
assert.deepEqual(mapping[filePath].b, {'1': [0, 1]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1, 4: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 7: 1, 8: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1, 4: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
// Solcover has trouble with this case. The conditional coverage strategy relies on being able to
// reference the left-hand variable before its value is assigned. Solidity doesn't allow this for 'var'.
/*it('should cover a variable delcaration assignment by conditional that reaches the alternate', (done) => {
// Solcover has trouble with this case. The conditional coverage strategy relies on being able to
// reference the left-hand variable before its value is assigned. Solidity doesn't allow this for 'var'.
/* it('should cover a variable delcaration assignment by conditional that reaches the alternate', (done) => {
const contract = util.getCode('conditional/variable-decl-assignment-alternate.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -127,4 +176,4 @@ describe('conditional statements', function(){
done();
}).catch(done);
});*/
})
});

@ -1,6 +1,8 @@
var solc = require('solc');
var getInstrumentedVersion = require('./../instrumentSolidity.js');
var util = require('./util/util.js');
/* eslint-env node, mocha */
const solc = require('solc');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
const util = require('./util/util.js');
const CoverageMap = require('./../coverageMap');
const path = require('path');
const vm = require('./util/vm');
@ -11,22 +13,21 @@ const assert = require('assert');
* NB: solc will throw if there is a compilation error, causing the test to fail
* and passing the error to mocha.
*/
describe('generic expressions', function(){
describe('generic expressions', () => {
const filePath = path.resolve('./test.sol');
const pathPrefix = './';
it('should compile after instrumenting a single binary expression', function(){
var contract = util.getCode('expressions/single-binary-expression.sol');
var info = getInstrumentedVersion(contract, filePath, true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting a single binary expression', () => {
const contract = util.getCode('expressions/single-binary-expression.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting a new expression', function(){
var contract = util.getCode('expressions/new-expression.sol');
var info = getInstrumentedVersion(contract, filePath, true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting a new expression', () => {
const contract = util.getCode('expressions/new-expression.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
})
});
});

@ -1,39 +1,40 @@
var solc = require('solc');
var getInstrumentedVersion = require('./../instrumentSolidity.js');
var util = require('./util/util.js');
/* eslint-env node, mocha */
const solc = require('solc');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
const util = require('./util/util.js');
/**
* NB: passing '1' to solc as an option activates the optimiser
* NB: solc will throw if there is a compilation error, causing the test to fail
* and passing the error to mocha.
*/
describe('function declarations', function(){
it('should compile after instrumenting an ordinary function declaration', function(){
var contract = util.getCode('function/function.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
describe('function declarations', () => {
it('should compile after instrumenting an ordinary function declaration', () => {
const contract = util.getCode('function/function.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting an abstract function declaration', function(){
var contract = util.getCode('function/abstract.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting an abstract function declaration', () => {
const contract = util.getCode('function/abstract.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting a function declaration with an empty body', function(){
var contract = util.getCode('function/empty-body.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting a function declaration with an empty body', () => {
const contract = util.getCode('function/empty-body.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting lots of declarations in row', function(){
var contract = util.getCode('function/multiple.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting lots of declarations in row', () => {
const contract = util.getCode('function/multiple.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
})
});
});

@ -1,3 +1,5 @@
/* eslint-env node, mocha */
const solc = require('solc');
const path = require('path');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
@ -6,12 +8,11 @@ const CoverageMap = require('./../coverageMap');
const vm = require('./util/vm');
const assert = require('assert');
describe('if, else, and else if statements', function(){
describe('if, else, and else if statements', () => {
const filePath = path.resolve('./test.sol');
const pathPrefix = './';
it('should cover an if statement with a bracketed consequent', (done) => {
it('should cover an if statement with a bracketed consequent', done => {
const contract = util.getCode('if/if-with-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -20,16 +21,24 @@ describe('if, else, and else if statements', function(){
// Runs: a(1) => if (x == 1) { x = 3; }
vm.execute(info.contract, 'a', [1]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1});
assert.deepEqual(mapping[filePath].b, {1: [1, 0]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [1, 0],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
// Runs: a(1) => if (x == 1) x = 2;
it('should cover an unbracketed if consequent (single line)',function(done){
it('should cover an unbracketed if consequent (single line)', done => {
const contract = util.getCode('if/if-no-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -38,15 +47,23 @@ describe('if, else, and else if statements', function(){
// Same results as previous test
vm.execute(info.contract, 'a', [1]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1});
assert.deepEqual(mapping[filePath].b, {1: [1, 0]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [1, 0],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done)
})
}).catch(done);
});
it('should cover an if statement with multiline bracketed consequent', (done) => {
it('should cover an if statement with multiline bracketed consequent', done => {
const contract = util.getCode('if/if-with-brackets-multiline.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -55,16 +72,24 @@ describe('if, else, and else if statements', function(){
// Runs: a(1) => if (x == 1){\n x = 3; }
vm.execute(info.contract, 'a', [1]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1});
assert.deepEqual(mapping[filePath].b, {1: [1, 0]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [1, 0],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
// Runs: a(1) => if (x == 1)\n x = 3;
it('should cover an unbracketed if consequent (multi-line)', function(done){
it('should cover an unbracketed if consequent (multi-line)', done => {
const contract = util.getCode('if/if-no-brackets-multiline.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -72,15 +97,23 @@ describe('if, else, and else if statements', function(){
// Same results as previous test
vm.execute(info.contract, 'a', [1]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1});
assert.deepEqual(mapping[filePath].b, {1: [1, 0]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [1, 0],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
})
});
it('should cover a simple if statement with a failing condition', (done) => {
it('should cover a simple if statement with a failing condition', done => {
const contract = util.getCode('if/if-with-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -89,16 +122,24 @@ describe('if, else, and else if statements', function(){
// Runs: a(2) => if (x == 1) { x = 3; }
vm.execute(info.contract, 'a', [2]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1});
assert.deepEqual(mapping[filePath].b, {1: [0, 1]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 0});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 0,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
// Runs: a(2) => if (x == 1){\n throw;\n }else{\n x = 5; \n}
it('should cover an if statement with a bracketed alternate', (done) => {
it('should cover an if statement with a bracketed alternate', done => {
const contract = util.getCode('if/else-with-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -106,15 +147,23 @@ describe('if, else, and else if statements', function(){
vm.execute(info.contract, 'a', [2]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 0, 8: 1});
assert.deepEqual(mapping[filePath].b, {1: [0, 1]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 0, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 0, 8: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 0, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover an if statement with an unbracketed alternate',function(done){
it('should cover an if statement with an unbracketed alternate', done => {
const contract = util.getCode('if/else-without-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -122,27 +171,42 @@ describe('if, else, and else if statements', function(){
vm.execute(info.contract, 'a', [2]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 0, 8: 1});
assert.deepEqual(mapping[filePath].b, {1: [0, 1]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 0, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 0, 8: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 0, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
})
});
it('should cover nested if statements with missing else statements',function(done){
it('should cover nested if statements with missing else statements', done => {
const contract = util.getCode('if/nested-if-missing-else.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
coverage.addContract(info, filePath);
vm.execute(info.contract, 'a', [2, 3, 3]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 7: 1});
assert.deepEqual(mapping[filePath].b, { '1': [ 0, 1 ], '2': [ 1, 0 ], '3': [ 1, 0 ] });
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3:1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 7: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1], 2: [1, 0], 3: [1, 0],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done)
})
})
}).catch(done);
});
});

@ -1,3 +1,5 @@
/* eslint-env node, mocha */
const solc = require('solc');
const path = require('path');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
@ -6,12 +8,11 @@ const CoverageMap = require('./../coverageMap');
const vm = require('./util/vm');
const assert = require('assert');
describe('for and while statements', function(){
describe('for and while statements', () => {
const filePath = path.resolve('./test.sol');
const pathPrefix = './';
it('should cover a for statement with a bracketed body (multiline)', (done) => {
it('should cover a for statement with a bracketed body (multiline)', done => {
const contract = util.getCode('loops/for-with-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -20,15 +21,21 @@ describe('for and while statements', function(){
// Runs: a() => for(var x = 1; x < 10; x++){\n sha3(x);\n }
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 10});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 10,
});
assert.deepEqual(mapping[filePath].b, {});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 10});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 10,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover a for statement with an unbracketed body', (done) => {
it('should cover a for statement with an unbracketed body', done => {
const contract = util.getCode('loops/for-no-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -37,15 +44,21 @@ describe('for and while statements', function(){
// Runs: a() => for(var x = 1; x < 10; x++)\n sha3(x);\n
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 10});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 10,
});
assert.deepEqual(mapping[filePath].b, {});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 10});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 10,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover a while statement with an bracketed body (multiline)', (done) => {
it('should cover a while statement with an bracketed body (multiline)', done => {
const contract = util.getCode('loops/while-with-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -54,15 +67,21 @@ describe('for and while statements', function(){
// Runs: a() => var t = true;\n while(t){\n t = false;\n }
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1, 7: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 7: 1,
});
assert.deepEqual(mapping[filePath].b, {});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover a while statement with an unbracketed body (multiline)', (done) => {
it('should cover a while statement with an unbracketed body (multiline)', done => {
const contract = util.getCode('loops/while-no-brackets.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -71,11 +90,17 @@ describe('for and while statements', function(){
// Runs: a() => var t = true;\n while(t)\n t = false;\n
vm.execute(info.contract, 'a', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 1, 7: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 1, 7: 1,
});
assert.deepEqual(mapping[filePath].b, {});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
})
});

@ -1,20 +1,21 @@
var solc = require('solc');
var getInstrumentedVersion = require('./../instrumentSolidity.js');
var util = require('./util/util.js');
/* eslint-env node, mocha */
describe('return statements', function(){
const solc = require('solc');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
const util = require('./util/util.js');
it('should compile after instrumenting function that returns true',function(){
var contract = util.getCode('return/return.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
util.report(output.errors);
})
describe('return statements', () => {
it('should compile after instrumenting function that returns true', () => {
const contract = util.getCode('return/return.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting function that returns without specifying val (null)',function(){
var contract = util.getCode('return/return-null.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting function that returns without specifying val (null)', () => {
const contract = util.getCode('return/return-null.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
})
});
});

@ -1,6 +1,8 @@
var solc = require('solc');
var getInstrumentedVersion = require('./../instrumentSolidity.js');
var util = require('./util/util.js');
/* eslint-env node, mocha */
const solc = require('solc');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
const util = require('./util/util.js');
const CoverageMap = require('./../coverageMap');
const path = require('path');
const vm = require('./util/vm');
@ -11,39 +13,39 @@ const assert = require('assert');
* NB: solc will throw if there is a compilation error, causing the test to fail
* and passing the error to mocha.
*/
describe('generic statements', function(){
describe('generic statements', () => {
const filePath = path.resolve('./test.sol');
const pathPrefix = './';
it('should compile after instrumenting a single statement (first line of function)', function(){
var contract = util.getCode('statements/single.sol');
var info = getInstrumentedVersion(contract, filePath, true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting a single statement (first line of function)', () => {
const contract = util.getCode('statements/single.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting multiple statements', function(){
var contract = util.getCode('statements/multiple.sol');
var info = getInstrumentedVersion(contract, filePath, true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting multiple statements', () => {
const contract = util.getCode('statements/multiple.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting a statement that is a function argument (single line)', function(){
var contract = util.getCode('statements/fn-argument.sol');
var info = getInstrumentedVersion(contract, filePath, true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting a statement that is a function argument (single line)', () => {
const contract = util.getCode('statements/fn-argument.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting a statement that is a function argument (multi-line)', function(){
var contract = util.getCode('statements/fn-argument-multiline.sol');
var info = getInstrumentedVersion(contract, filePath, true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting a statement that is a function argument (multi-line)', () => {
const contract = util.getCode('statements/fn-argument-multiline.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
it('should cover a statement following a close brace', (done) => {
});
it('should cover a statement following a close brace', done => {
const contract = util.getCode('statements/post-close-brace.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -51,15 +53,23 @@ describe('generic statements', function(){
vm.execute(info.contract, 'a', [1]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {5: 1, 6: 0, 8: 1});
assert.deepEqual(mapping[filePath].b, {1: [0, 1]});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 0, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1});
assert.deepEqual(mapping[filePath].l, {
5: 1, 6: 0, 8: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 0, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
it('should cover a library statement and an invoked library method', (done) => {
it('should cover a library statement and an invoked library method', done => {
const contract = util.getCode('statements/library.sol');
const info = getInstrumentedVersion(contract, filePath, true);
const coverage = new CoverageMap();
@ -67,11 +77,17 @@ describe('generic statements', function(){
vm.execute(info.contract, 'not', []).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {9: 1, 10: 1, 19: 1});
assert.deepEqual(mapping[filePath].l, {
9: 1, 10: 1, 19: 1,
});
assert.deepEqual(mapping[filePath].b, {});
assert.deepEqual(mapping[filePath].s, {1: 1, 2: 1, 3: 1});
assert.deepEqual(mapping[filePath].f, {1: 1, 2: 1});
assert.deepEqual(mapping[filePath].s, {
1: 1, 2: 1, 3: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1, 2: 1,
});
done();
}).catch(done);
});
})
});

@ -1,188 +1,189 @@
var solc = require('solc');
var getInstrumentedVersion = require('./../instrumentSolidity.js');
var util = require('./util/util.js');
/* eslint-env node, mocha */
describe('Battery test of production contracts: OpenZeppelin', function(){
const solc = require('solc');
const getInstrumentedVersion = require('./../instrumentSolidity.js');
const util = require('./util/util.js');
it('should compile after instrumenting zeppelin-solidity/Bounty.sol',function(){
var contract = util.getCode('zeppelin/Bounty.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
describe('Battery test of production contracts: OpenZeppelin', () => {
it('should compile after instrumenting zeppelin-solidity/Bounty.sol', () => {
const contract = util.getCode('zeppelin/Bounty.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'PullPayment.sol': util.getCode('zeppelin/PullPayment.sol'),
'Killable.sol': util.getCode('zeppelin/Killable.sol'),
'Bounty.sol': info.contract
'Bounty.sol': info.contract,
};
var output = solc.compile(inputs, 1);
const output = solc.compile(inputs, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting zeppelin-solidity/Claimable.sol',function(){
var contract = util.getCode('zeppelin/Claimable.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
it('should compile after instrumenting zeppelin-solidity/Claimable.sol', () => {
const contract = util.getCode('zeppelin/Claimable.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'Ownable.sol': util.getCode('zeppelin/Ownable.sol'),
'Claimable.sol': info.contract
'Claimable.sol': info.contract,
};
var output = solc.compile(inputs, 1);
const output = solc.compile(inputs, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting zeppelin-solidity/DayLimit.sol',function(){
var contract = util.getCode('zeppelin/DayLimit.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
it('should compile after instrumenting zeppelin-solidity/DayLimit.sol', () => {
const contract = util.getCode('zeppelin/DayLimit.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'Ownable.sol': util.getCode('zeppelin/Shareable.sol'),
'DayLimit.sol': info.contract
'DayLimit.sol': info.contract,
};
var output = solc.compile(inputs, 1);
const output = solc.compile(inputs, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting zeppelin-solidity/Killable.sol',function(){
var contract = util.getCode('zeppelin/Killable.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
it('should compile after instrumenting zeppelin-solidity/Killable.sol', () => {
const contract = util.getCode('zeppelin/Killable.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'Ownable.sol': util.getCode('zeppelin/Ownable.sol'),
'Killable.sol': info.contract
'Killable.sol': info.contract,
};
var output = solc.compile(inputs, 1);
util.report(output.errors);
})
const output = solc.compile(inputs, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/LimitBalance.sol',function(){
var contract = util.getCode('zeppelin/LimitBalance.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting zeppelin-solidity/LimitBalance.sol', () => {
const contract = util.getCode('zeppelin/LimitBalance.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting zeppelin-solidity/Migrations.sol',function(){
var contract = util.getCode('zeppelin/Migrations.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
it('should compile after instrumenting zeppelin-solidity/Migrations.sol', () => {
const contract = util.getCode('zeppelin/Migrations.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'Ownable.sol': util.getCode('zeppelin/Ownable.sol'),
'Migrations.sol': info.contract
'Migrations.sol': info.contract,
};
var output = solc.compile(inputs, 1);
const output = solc.compile(inputs, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting zeppelin-solidity/Multisig.sol',function(){
var contract = util.getCode('zeppelin/Multisig.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
it('should compile after instrumenting zeppelin-solidity/Multisig.sol', () => {
const contract = util.getCode('zeppelin/Multisig.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting zeppelin-solidity/MultisigWallet.sol',function(){
var contract = util.getCode('zeppelin/MultisigWallet.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
it('should compile after instrumenting zeppelin-solidity/MultisigWallet.sol', () => {
const contract = util.getCode('zeppelin/MultisigWallet.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'Multisig.sol': util.getCode('zeppelin/Multisig.sol'),
'Shareable.sol': util.getCode('zeppelin/Shareable.sol'),
'DayLimit.sol': util.getCode('zeppelin/DayLimit.sol'),
'MultisigWallet.sol': info.contract
'MultisigWallet.sol': info.contract,
};
var output = solc.compile(inputs, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/Ownable.sol',function(){
var contract = util.getCode('zeppelin/Ownable.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/PullPayment.sol',function(){
var contract = util.getCode('zeppelin/PullPayment.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/SafeMath.sol',function(){
var contract = util.getCode('zeppelin/SafeMath.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/Shareable.sol',function(){
var contract = util.getCode('zeppelin/Shareable.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/Stoppable.sol',function(){
var contract = util.getCode('zeppelin/Stoppable.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
const output = solc.compile(inputs, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Ownable.sol', () => {
const contract = util.getCode('zeppelin/Ownable.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/PullPayment.sol', () => {
const contract = util.getCode('zeppelin/PullPayment.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/SafeMath.sol', () => {
const contract = util.getCode('zeppelin/SafeMath.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Shareable.sol', () => {
const contract = util.getCode('zeppelin/Shareable.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Stoppable.sol', () => {
const contract = util.getCode('zeppelin/Stoppable.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'Ownable.sol': util.getCode('zeppelin/Ownable.sol'),
'Stoppable.sol': info.contract
'Stoppable.sol': info.contract,
};
var output = solc.compile(inputs, 1);
util.report(output.errors);
})
//--- Tokens ---
it('should compile after instrumenting zeppelin-solidity/BasicToken.sol',function(){
var contract = util.getCode('zeppelin/token/BasicToken.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
const output = solc.compile(inputs, 1);
util.report(output.errors);
});
// --- Tokens ---
it('should compile after instrumenting zeppelin-solidity/BasicToken.sol', () => {
const contract = util.getCode('zeppelin/token/BasicToken.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'ERC20Basic.sol': util.getCode('zeppelin/token/ERC20Basic.sol'),
'SafeMath.sol': util.getCode('zeppelin/SafeMath.sol'),
'BasicToken.sol': info.contract
'BasicToken.sol': info.contract,
};
var output = solc.compile(inputs, 1);
const output = solc.compile(inputs, 1);
util.report(output.errors);
})
});
it('should compile after instrumenting zeppelin-solidity/CrowdsaleToken.sol',function(){
var contract = util.getCode('zeppelin/token/CrowdsaleToken.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
it('should compile after instrumenting zeppelin-solidity/CrowdsaleToken.sol', () => {
const contract = util.getCode('zeppelin/token/CrowdsaleToken.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'StandardToken.sol': util.getCode('zeppelin/token/StandardToken.sol'),
'CrowdsaleToken.sol': info.contract
};
var output = solc.compile(inputs, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/ERC20.sol',function(){
var contract = util.getCode('zeppelin/token/ERC20.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/ERC20Basic.sol',function(){
var contract = util.getCode('zeppelin/token/ERC20Basic.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var output = solc.compile(info.contract, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/SimpleToken.sol',function(){
var contract = util.getCode('zeppelin/token/SimpleToken.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
'CrowdsaleToken.sol': info.contract,
};
const output = solc.compile(inputs, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/ERC20.sol', () => {
const contract = util.getCode('zeppelin/token/ERC20.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/ERC20Basic.sol', () => {
const contract = util.getCode('zeppelin/token/ERC20Basic.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/SimpleToken.sol', () => {
const contract = util.getCode('zeppelin/token/SimpleToken.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'StandardToken.sol': util.getCode('zeppelin/token/StandardToken.sol'),
'SimpleToken.sol': info.contract
};
var output = solc.compile(inputs, 1);
util.report(output.errors);
})
it('should compile after instrumenting zeppelin-solidity/StandardToken.sol',function(){
var contract = util.getCode('zeppelin/token/StandardToken.sol');
var info = getInstrumentedVersion(contract, "test.sol", true);
var inputs = {
'SimpleToken.sol': info.contract,
};
const output = solc.compile(inputs, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/StandardToken.sol', () => {
const contract = util.getCode('zeppelin/token/StandardToken.sol');
const info = getInstrumentedVersion(contract, 'test.sol', true);
const inputs = {
'ERC20Basic.sol': util.getCode('zeppelin/token/ERC20Basic.sol'),
'SafeMath.sol': util.getCode('zeppelin/SafeMath.sol'),
'StandardToken.sol': info.contract
'StandardToken.sol': info.contract,
};
var output = solc.compile(inputs, 1);
const output = solc.compile(inputs, 1);
util.report(output.errors);
})
})
});
});

Loading…
Cancel
Save