From 942a2288278dfb76e4cda5530d949e611b40c49b Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 21 Jun 2018 11:28:28 +0200 Subject: [PATCH] fix linting --- sol/tests.sol.js | 2 +- src/compiler.js | 6 +++--- src/deployer.js | 4 ++-- src/index.js | 25 ++++++++++++------------- src/testRunner.js | 12 ++++++------ 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/sol/tests.sol.js b/sol/tests.sol.js index 2356f09100..2fa6821bbe 100644 --- a/sol/tests.sol.js +++ b/sol/tests.sol.js @@ -100,4 +100,4 @@ library Assert { //} } -`; +` diff --git a/src/compiler.js b/src/compiler.js index 6be9bc1002..f6fc4698a9 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -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')} } diff --git a/src/deployer.js b/src/deployer.js index 3b51e1e48a..969f529610 100644 --- a/src/deployer.js +++ b/src/deployer.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) diff --git a/src/index.js b/src/index.js index 92cdb87637..f8019f1dfa 100644 --- a/src/index.js +++ b/src/index.js @@ -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) { diff --git a/src/testRunner.js b/src/testRunner.js index 070d99122d..c83c989697 100644 --- a/src/testRunner.js +++ b/src/testRunner.js @@ -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()