remove web3 param from runTest params, simply use Web3 directly

pull/7/head
Iuri Matias 7 years ago
parent 0379528f64
commit 4e97e98c43
  1. 2
      index.js
  2. 7
      src/testRunner.js
  3. 10
      tests/testRunner.js

@ -62,7 +62,7 @@ var runTestFiles = function (filepath, isDirectory, web3) {
}
async.eachOfLimit(contractsToTest, 1, (contractName, index, cb) => {
TestRunner.runTest(web3, contractName, contracts[contractName], testCallback, (err, result) => {
TestRunner.runTest(contractName, contracts[contractName], testCallback, (err, result) => {
if (err) {
return cb(err)
}

@ -1,5 +1,6 @@
var async = require('async')
var changeCase = require('change-case')
var Web3 = require('web3')
function getAvailableFunctions (jsonInterface) {
return jsonInterface.reverse().filter((x) => x.type === 'function').map((x) => x.name)
@ -29,7 +30,7 @@ function createRunList (jsonInterface) {
return runList
}
function runTest (web3, testName, testObject, testCallback, resultsCallback) {
function runTest (testName, testObject, testCallback, resultsCallback) {
let runList = createRunList(testObject._jsonInterface)
let passingNum = 0
@ -57,13 +58,13 @@ function runTest (web3, testName, testObject, testCallback, resultsCallback) {
method.send().on('receipt', function (receipt) {
let time = Math.ceil((Date.now() - startTime) / 1000.0)
if (func.type === 'test') {
let topic = web3.utils.sha3('AssertionEvent(bool,string)')
let topic = Web3.utils.sha3('AssertionEvent(bool,string)')
let matchingEvents = []
for (let i in receipt.events) {
let event = receipt.events[i]
if (event.raw.topics.indexOf(topic) >= 0) {
matchingEvents.push(web3.eth.abi.decodeParameters(['bool', 'string'], event.raw.data))
matchingEvents.push(Web3.eth.abi.decodeParameters(['bool', 'string'], event.raw.data))
}
}

@ -18,20 +18,18 @@ function compileAndDeploy (filename, callback) {
Deployer.deployAll(compilationResult, web3, next)
}
], function (_err, contracts) {
callback(null, contracts, web3)
callback(null, contracts)
})
}
describe('testRunner', function () {
let web3;
describe('#runTest', function() {
describe('test with beforeAll', function () {
let filename = 'tests/examples_1/simple_storage_test.sol'
let tests = [], results = {}
before(function (done) {
compileAndDeploy(filename, function (_err, contracts, _web3) {
web3 = _web3;
compileAndDeploy(filename, function (_err, contracts) {
var testCallback = function (test) {
tests.push(test)
}
@ -39,7 +37,7 @@ describe('testRunner', function () {
results = _results
done()
}
TestRunner.runTest(web3, 'MyTest', contracts.MyTest, testCallback, resultsCallback)
TestRunner.runTest('MyTest', contracts.MyTest, testCallback, resultsCallback)
})
})
@ -73,7 +71,7 @@ describe('testRunner', function () {
results = _results
done()
}
TestRunner.runTest(web3, 'MyTest', contracts.MyTest, testCallback, resultsCallback)
TestRunner.runTest('MyTest', contracts.MyTest, testCallback, resultsCallback)
})
})

Loading…
Cancel
Save