|
|
@ -122,7 +122,7 @@ function createRunList (jsonInterface: FunctionDescription[], fileAST: AstNode, |
|
|
|
if (availableFunctions.indexOf('beforeEach') >= 0) { |
|
|
|
if (availableFunctions.indexOf('beforeEach') >= 0) { |
|
|
|
runList.push({ name: 'beforeEach', type: 'internal', constant: false, payable: false }) |
|
|
|
runList.push({ name: 'beforeEach', type: 'internal', constant: false, payable: false }) |
|
|
|
} |
|
|
|
} |
|
|
|
if(func.name) runList.push({ name: func.name, signature: func.signature, type: 'test', constant: isConstant(func), payable: isPayable(func) }) |
|
|
|
if(func.name && func.inputs) runList.push({ name: func.name, inputs: func.inputs, signature: func.signature, type: 'test', constant: isConstant(func), payable: isPayable(func) }) |
|
|
|
if (availableFunctions.indexOf('afterEach') >= 0) { |
|
|
|
if (availableFunctions.indexOf('afterEach') >= 0) { |
|
|
|
runList.push({ name: 'afterEach', type: 'internal', constant: false, payable: false }) |
|
|
|
runList.push({ name: 'afterEach', type: 'internal', constant: false, payable: false }) |
|
|
|
} |
|
|
|
} |
|
|
@ -142,14 +142,12 @@ export function runTest (testName: string, testObject: any, contractDetails: Com |
|
|
|
const isJSONInterfaceAvailable = testObject && testObject.options && testObject.options.jsonInterface |
|
|
|
const isJSONInterfaceAvailable = testObject && testObject.options && testObject.options.jsonInterface |
|
|
|
if(!isJSONInterfaceAvailable) |
|
|
|
if(!isJSONInterfaceAvailable) |
|
|
|
return resultsCallback(new Error('Contract interface not available'), { passingNum, failureNum, timePassed }) |
|
|
|
return resultsCallback(new Error('Contract interface not available'), { passingNum, failureNum, timePassed }) |
|
|
|
|
|
|
|
|
|
|
|
const runList: RunListInterface[] = createRunList(testObject.options.jsonInterface, fileAST, testName) |
|
|
|
const runList: RunListInterface[] = createRunList(testObject.options.jsonInterface, fileAST, testName) |
|
|
|
const web3 = new Web3() |
|
|
|
const web3 = new Web3() |
|
|
|
const accts: TestResultInterface = { |
|
|
|
const accts: TestResultInterface = { |
|
|
|
type: 'accountList', |
|
|
|
type: 'accountList', |
|
|
|
value: opts.accounts |
|
|
|
value: opts.accounts |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
testCallback(undefined, accts) |
|
|
|
testCallback(undefined, accts) |
|
|
|
|
|
|
|
|
|
|
|
const resp: TestResultInterface = { |
|
|
|
const resp: TestResultInterface = { |
|
|
@ -157,7 +155,6 @@ export function runTest (testName: string, testObject: any, contractDetails: Com |
|
|
|
value: testName, |
|
|
|
value: testName, |
|
|
|
filename: testObject.filename |
|
|
|
filename: testObject.filename |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
testCallback(undefined, resp) |
|
|
|
testCallback(undefined, resp) |
|
|
|
async.eachOfLimit(runList, 1, function (func, index, next) { |
|
|
|
async.eachOfLimit(runList, 1, function (func, index, next) { |
|
|
|
let sender: string | null = null |
|
|
|
let sender: string | null = null |
|
|
@ -169,6 +166,8 @@ export function runTest (testName: string, testObject: any, contractDetails: Com |
|
|
|
} |
|
|
|
} |
|
|
|
let sendParams: Record<string, string> | null = null |
|
|
|
let sendParams: Record<string, string> | null = null |
|
|
|
if (sender) sendParams = { from: sender } |
|
|
|
if (sender) sendParams = { from: sender } |
|
|
|
|
|
|
|
if(func.inputs && func.inputs.length > 0) |
|
|
|
|
|
|
|
return resultsCallback(new Error('Method inside a test contract can not have parameters'), { passingNum, failureNum, timePassed }) |
|
|
|
const method = testObject.methods[func.name].apply(testObject.methods[func.name], []) |
|
|
|
const method = testObject.methods[func.name].apply(testObject.methods[func.name], []) |
|
|
|
const startTime = Date.now() |
|
|
|
const startTime = Date.now() |
|
|
|
if (func.constant) { |
|
|
|
if (func.constant) { |
|
|
@ -248,7 +247,6 @@ export function runTest (testName: string, testObject: any, contractDetails: Com |
|
|
|
return next(err) |
|
|
|
return next(err) |
|
|
|
} |
|
|
|
} |
|
|
|
}).on('error', function (err: Error) { |
|
|
|
}).on('error', function (err: Error) { |
|
|
|
console.error(err) |
|
|
|
|
|
|
|
const time: number = (Date.now() - startTime) / 1000.0 |
|
|
|
const time: number = (Date.now() - startTime) / 1000.0 |
|
|
|
const resp: TestResultInterface = { |
|
|
|
const resp: TestResultInterface = { |
|
|
|
type: 'testFailure', |
|
|
|
type: 'testFailure', |
|
|
|