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. 14
      remix-tests/src/testRunner.ts
  3. 1
      remix-tests/src/types.ts

@ -4,11 +4,10 @@ require('colors')
import { compileContractSources } from './compiler' import { compileContractSources } from './compiler'
import { deployAll } from './deployer' import { deployAll } from './deployer'
import { runTest } from './testRunner' import { runTest } from './testRunner'
import { TestResultInterface, AstNode } from './types'
import Web3 = require('web3') import Web3 = require('web3')
import { Provider } from 'remix-simulator' 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 () { const createWeb3Provider = async function () {
let web3 = new Web3() let web3 = new Web3()

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

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

Loading…
Cancel
Save