Merge pull request #14 from ethereum/fixLinting

Fix linting
pull/3094/head
yann300 7 years ago committed by GitHub
commit 8cbc8dfc70
  1. 2
      sol/tests.sol.js
  2. 6
      src/compiler.js
  3. 4
      src/deployer.js
  4. 25
      src/index.js
  5. 12
      src/testRunner.js

@ -100,4 +100,4 @@ library Assert {
//}
}
`;
`

@ -10,8 +10,8 @@ function compileFileOrFiles (filename, isDirectory, cb) {
let compiler, filepath
const sources = {
'tests.sol': {content: require('../sol/tests.sol.js') },
'remix_tests.sol': {content: require('../sol/tests.sol.js') }
'tests.sol': { content: require('../sol/tests.sol.js') },
'remix_tests.sol': { content: require('../sol/tests.sol.js') }
}
// TODO: for now assumes filepath dir contains all tests, later all this
@ -49,7 +49,7 @@ function compileFileOrFiles (filename, isDirectory, cb) {
function compileContractSources (sources, importFileCb, cb) {
let compiler, filepath
if(!sources['remix_tests.sol']) {
if (!sources['remix_tests.sol']) {
sources['remix_tests.sol'] = {content: require('../sol/tests.sol.js')}
}

@ -56,8 +56,8 @@ function deployAll (compileResult, web3, callback) {
async.eachOfLimit(contractsToDeploy, 1, function (contractName, index, nextEach) {
let contract = compiledObject[contractName]
if (!contract) {
console.error("Contract not found: " + contractName);
return nextEach(new Error("Contract not found: " + contractName));
console.error('Contract not found: ' + contractName)
return nextEach(new Error('Contract not found: ' + contractName))
}
let contractObject = new web3.eth.Contract(contract.abi)

@ -10,7 +10,7 @@ let TestRunner = require('./testRunner.js')
const Web3 = require('web3')
const Provider = require('remix-simulator').Provider
var createWeb3Provider = function() {
var createWeb3Provider = function () {
let web3 = new Web3()
web3.setProvider(new Provider())
return web3
@ -22,7 +22,7 @@ var runTestSources = function (contractSources, testCallback, resultCallback, fi
Compiler.compileContractSources(contractSources, importFileCb, next)
},
function deployAllContracts (compilationResult, next) {
let web3 = createWeb3Provider();
let web3 = createWeb3Provider()
Deployer.deployAll(compilationResult, web3, function (err, contracts) {
if (err) {
next(err)
@ -35,7 +35,6 @@ var runTestSources = function (contractSources, testCallback, resultCallback, fi
let contractsToTest = []
for (let filename in compilationResult) {
let contract = compilationResult[filename];
if (filename.indexOf('_test.sol') < 0) {
continue
}
@ -56,11 +55,11 @@ var runTestSources = function (contractSources, testCallback, resultCallback, fi
if (result.type === 'testFailure') {
errors.push(result)
}
testCallback(result);
testCallback(result)
}
var _resultsCallback = function (_err, result, cb) {
resultCallback(_err, result, () => {});
resultCallback(_err, result, () => {})
totalPassing += result.passingNum
totalFailing += result.failureNum
totalTime += result.timePassed
@ -79,21 +78,21 @@ var runTestSources = function (contractSources, testCallback, resultCallback, fi
return next(err)
}
let finalResults = {};
let finalResults = {}
finalResults.totalPassing = totalPassing || 0;
finalResults.totalFailing = totalFailing || 0;
finalResults.totalTime = totalTime || 0;
finalResults.errors = [];
finalResults.totalPassing = totalPassing || 0
finalResults.totalFailing = totalFailing || 0
finalResults.totalTime = totalTime || 0
finalResults.errors = []
errors.forEach((error, _index) => {
finalResults.errors.push({context: error.context, value: error.value, message: error.errMsg});
finalResults.errors.push({context: error.context, value: error.value, message: error.errMsg})
})
next(null, finalResults);
next(null, finalResults)
})
}
], finalCallback);
], finalCallback)
}
var runTestFiles = function (filepath, isDirectory, web3) {

@ -36,7 +36,7 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
let passingNum = 0
let failureNum = 0
let timePassed = 0
let web3 = new Web3();
let web3 = new Web3()
testCallback({type: 'contract', value: testName})
async.eachOfLimit(runList, 1, function (func, index, next) {
@ -59,7 +59,7 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
method.send().on('receipt', function (receipt) {
try {
let time = Math.ceil((Date.now() - startTime) / 1000.0)
//if (func.type === 'test') {
// if (func.type === 'test') {
let topic = Web3.utils.sha3('AssertionEvent(bool,string)')
let matchingEvents = []
@ -83,10 +83,10 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
testCallback({type: 'testFailure', value: changeCase.sentenceCase(func.name), time: time, errMsg: result[1], context: testName})
failureNum += 1
}
//}
} catch(err) {
console.log("error!");
console.dir(err);
// }
} catch (err) {
console.log('error!')
console.dir(err)
return next(err)
}
next()

Loading…
Cancel
Save