test function with params will throw error

pull/7/head
aniket-engg 5 years ago committed by Aniket
parent 28e8c1f8b1
commit 64d37b0ffe
  1. 8
      remix-tests/src/testRunner.ts
  2. 1
      remix-tests/src/types.ts

@ -122,7 +122,7 @@ function createRunList (jsonInterface: FunctionDescription[], fileAST: AstNode,
if (availableFunctions.indexOf('beforeEach') >= 0) {
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) {
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
if(!isJSONInterfaceAvailable)
return resultsCallback(new Error('Contract interface not available'), { passingNum, failureNum, timePassed })
const runList: RunListInterface[] = createRunList(testObject.options.jsonInterface, fileAST, testName)
const web3 = new Web3()
const accts: TestResultInterface = {
type: 'accountList',
value: opts.accounts
}
testCallback(undefined, accts)
const resp: TestResultInterface = {
@ -157,7 +155,6 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
value: testName,
filename: testObject.filename
}
testCallback(undefined, resp)
async.eachOfLimit(runList, 1, function (func, index, next) {
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
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 startTime = Date.now()
if (func.constant) {
@ -248,7 +247,6 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
return next(err)
}
}).on('error', function (err: Error) {
console.error(err)
const time: number = (Date.now() - startTime) / 1000.0
const resp: TestResultInterface = {
type: 'testFailure',

@ -14,6 +14,7 @@ export interface FinalResult {
/** List of tests to run **/
export interface RunListInterface {
name: string,
inputs?: any[]
type: string,
constant: boolean,
payable: boolean,

Loading…
Cancel
Save