suggested changes

pull/5370/head
aniket-engg 5 years ago committed by Aniket
parent 5bcc01ea8c
commit 7b7a0e4111
  1. 3
      remix-tests/src/runTestSources.ts
  2. 12
      remix-tests/src/testRunner.ts
  3. 1
      remix-tests/src/types.ts

@ -4,11 +4,10 @@ require('colors')
import { compileContractSources } from './compiler'
import { deployAll } from './deployer'
import { runTest } from './testRunner'
import { TestResultInterface, AstNode } from './types'
import Web3 = require('web3')
import { Provider } from 'remix-simulator'
import { FinalResult, SrcIfc, compilationInterface, ASTInterface, Options } from './types'
import { FinalResult, SrcIfc, compilationInterface, ASTInterface, Options, TestResultInterface, AstNode } from './types'
const createWeb3Provider = async function () {
let web3 = new Web3()

@ -4,7 +4,7 @@ import Web3 = require('web3')
import { RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface,
CompiledContract, AstNode, Options, FunctionDescription, UserDocumentation } from './types'
function getFunctionFullName (signature: string, methodIdentifiers: any) {
function getFunctionFullName (signature: string, methodIdentifiers: Record <string, string>) {
for (const method in methodIdentifiers) {
if (signature.replace('0x', '') === methodIdentifiers[method].replace('0x', '')) {
return method
@ -13,7 +13,7 @@ function getFunctionFullName (signature: string, methodIdentifiers: any) {
return null
}
function getOverridedSender (userdoc: UserDocumentation, signature: string, methodIdentifiers: any) {
function getOverridedSender (userdoc: UserDocumentation, signature: string, methodIdentifiers: Record <string, string>) {
let fullName: any = getFunctionFullName(signature, methodIdentifiers)
let match: RegExp = /sender: account-+(\d)/g
let accountIndex: any = userdoc.methods[fullName] ? match.exec(userdoc.methods[fullName].notice) : null
@ -27,12 +27,14 @@ function getOverridedSender (userdoc: UserDocumentation, signature: string, meth
*/
function getAvailableFunctions (fileAST: AstNode, testContractName: string) {
var funcList: string[] = []
let funcList: string[] = []
if(fileAST.nodes && fileAST.nodes.length > 0) {
const contractAST: any[] = fileAST.nodes.filter(node => node.name === testContractName && node.nodeType === 'ContractDefinition')
const funcNodes: any[] = contractAST[0].nodes.filter(node => node.kind === 'function' && node.nodeType === "FunctionDefinition")
const contractAST: AstNode[] = fileAST.nodes.filter(node => node.name === testContractName && node.nodeType === 'ContractDefinition')
if(contractAST.length > 0 && contractAST[0].nodes) {
const funcNodes: AstNode[] = contractAST[0].nodes.filter(node => node.kind === 'function' && node.nodeType === "FunctionDefinition")
funcList = funcNodes.map(node => node.name)
}
}
return funcList;
}

@ -163,6 +163,7 @@ export interface FunctionDescription {
payable?: boolean
/** true if function is either pure or view, false otherwise. Default is false */
constant?: boolean
signature?: string
}
export interface EventDescription {

Loading…
Cancel
Save