From 64d37b0ffe65ee6d0ffbbf0e1387787961be8e58 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 26 Mar 2020 18:53:55 +0530 Subject: [PATCH] test function with params will throw error --- remix-tests/src/testRunner.ts | 8 +++----- remix-tests/src/types.ts | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/remix-tests/src/testRunner.ts b/remix-tests/src/testRunner.ts index 089def3999..a8d81b094c 100644 --- a/remix-tests/src/testRunner.ts +++ b/remix-tests/src/testRunner.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 | 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', diff --git a/remix-tests/src/types.ts b/remix-tests/src/types.ts index 66b9335e48..195f4ea802 100644 --- a/remix-tests/src/types.ts +++ b/remix-tests/src/types.ts @@ -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,