Add more fixes, arrow functions

pull/7/head
Omkara 6 years ago
parent 206a65494e
commit 7fb7747b5a
  1. 8
      remix-tests/src/compiler.ts
  2. 15
      remix-tests/src/index.ts
  3. 8
      remix-tests/src/testRunner.ts
  4. 10
      remix-tests/tests/testRunner.ts

@ -67,7 +67,7 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
}, },
function doCompilation(next: Function) { function doCompilation(next: Function) {
// @ts-ignore // @ts-ignore
compiler.event.register('compilationFinished', this, function (success, data, source) { compiler.event.register('compilationFinished', this, (success, data, source) => {
next(null, data) next(null, data)
}) })
compiler.compile(sources, filepath) compiler.compile(sources, filepath)
@ -83,8 +83,8 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
} }
} }
export function compileContractSources(sources: SrcIfc, importFileCb, opts, cb) { export function compileContractSources(sources: SrcIfc, importFileCb: any, opts: any, cb: Function) {
let compiler, filepath let compiler, filepath: string
let accounts = opts.accounts || [] let accounts = opts.accounts || []
// Iterate over sources keys. Inject test libraries. Inject test library import statements. // Iterate over sources keys. Inject test libraries. Inject test library import statements.
if (!('remix_tests.sol' in sources) && !('tests.sol' in sources)) { if (!('remix_tests.sol' in sources) && !('tests.sol' in sources)) {
@ -110,7 +110,7 @@ export function compileContractSources(sources: SrcIfc, importFileCb, opts, cb)
}, },
function doCompilation (next: Function) { function doCompilation (next: Function) {
// @ts-ignore // @ts-ignore
compiler.event.register('compilationFinished', this, function (success, data, source) { compiler.event.register('compilationFinished', this, (success, data, source) => {
next(null, data) next(null, data)
}) })
compiler.compile(sources, filepath) compiler.compile(sources, filepath)

@ -1,10 +1,5 @@
import { runTestFiles } from './runTestFiles' export { runTestFiles } from './runTestFiles'
import { runTestSources } from './runTestSources' export { runTestSources } from './runTestSources'
import { runTest } from './testRunner' export { runTest } from './testRunner'
export * from './types'
module.exports = { export { assertLibCode } from '../sol/tests.sol.js'
runTestFiles: runTestFiles,
runTestSources: runTestSources,
runTest: runTest,
assertLibCode: require('../sol/tests.sol.js')
}

@ -3,7 +3,7 @@ import * as changeCase from 'change-case'
import Web3 from 'web3' import Web3 from 'web3'
import { RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface } from './types' import { RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface } from './types'
function getFunctionFullName (signature, methodIdentifiers) { function getFunctionFullName (signature: string, methodIdentifiers) {
for (var method in methodIdentifiers) { for (var method in methodIdentifiers) {
if (signature.replace('0x', '') === methodIdentifiers[method].replace('0x', '')) { if (signature.replace('0x', '') === methodIdentifiers[method].replace('0x', '')) {
return method return method
@ -12,7 +12,7 @@ function getFunctionFullName (signature, methodIdentifiers) {
return null return null
} }
function getOverridedSender (userdoc, signature, methodIdentifiers) { function getOverridedSender (userdoc, signature: string, methodIdentifiers) {
let fullName: any = getFunctionFullName(signature, methodIdentifiers) let fullName: any = getFunctionFullName(signature, methodIdentifiers)
let match = /sender: account-+(\d)/g let match = /sender: account-+(\d)/g
let accountIndex = userdoc.methods[fullName] ? match.exec(userdoc.methods[fullName].notice) : null let accountIndex = userdoc.methods[fullName] ? match.exec(userdoc.methods[fullName].notice) : null
@ -28,7 +28,7 @@ function getTestFunctions (jsonInterface) {
return jsonInterface.filter((x) => specialFunctions.indexOf(x.name) < 0 && x.type === 'function') return jsonInterface.filter((x) => specialFunctions.indexOf(x.name) < 0 && x.type === 'function')
} }
function createRunList(jsonInterface): RunListInterface[] { function createRunList (jsonInterface): RunListInterface[] {
let availableFunctions = getAvailableFunctions(jsonInterface) let availableFunctions = getAvailableFunctions(jsonInterface)
let testFunctions = getTestFunctions(jsonInterface) let testFunctions = getTestFunctions(jsonInterface)
let runList: RunListInterface[] = [] let runList: RunListInterface[] = []
@ -54,7 +54,7 @@ function createRunList(jsonInterface): RunListInterface[] {
return runList return runList
} }
export function runTest(testName, testObject: any, contractDetails: any, opts: any, testCallback: TestCbInterface, resultsCallback: ResultCbInterface) { export function runTest (testName, testObject: any, contractDetails: any, opts: any, testCallback: TestCbInterface, resultsCallback: ResultCbInterface) {
let runList = createRunList(testObject._jsonInterface) let runList = createRunList(testObject._jsonInterface)
let passingNum: number = 0 let passingNum: number = 0

@ -5,8 +5,8 @@ import { Provider } from 'remix-simulator'
import { compileFileOrFiles } from '../dist/compiler' import { compileFileOrFiles } from '../dist/compiler'
import { deployAll } from '../dist/deployer' import { deployAll } from '../dist/deployer'
import { runTest } from '../dist/testRunner' import { runTest } from '../dist/index'
import { ResultsInterface, TestCbInterface, ResultCbInterface } from '../dist/types' import { ResultsInterface, TestCbInterface, ResultCbInterface } from '../dist/index'
function compileAndDeploy(filename: string, callback: Function) { function compileAndDeploy(filename: string, callback: Function) {
let web3: Web3 = new Web3() let web3: Web3 = new Web3()
@ -119,7 +119,7 @@ describe('testRunner', () => {
let tests: any[] = [], results: ResultsInterface; let tests: any[] = [], results: ResultsInterface;
before(function (done) { before(function (done) {
compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) { compileAndDeploy(filename, (_err, compilationData, contracts, accounts) => {
var testCallback: TestCbInterface = (err, test) => { var testCallback: TestCbInterface = (err, test) => {
if (err) { throw err } if (err) { throw err }
tests.push(test) tests.push(test)
@ -158,7 +158,7 @@ describe('testRunner', () => {
let tests: any[] = [], results: ResultsInterface; let tests: any[] = [], results: ResultsInterface;
before(function (done) { before(function (done) {
compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) { compileAndDeploy(filename, (_err, compilationData, contracts, accounts) => {
var testCallback: TestCbInterface = (err, test) => { var testCallback: TestCbInterface = (err, test) => {
if (err) { throw err } if (err) { throw err }
tests.push(test) tests.push(test)
@ -186,7 +186,7 @@ describe('testRunner', () => {
let tests: any[] = [], results: ResultsInterface; let tests: any[] = [], results: ResultsInterface;
before(function (done) { before(function (done) {
compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) { compileAndDeploy(filename, (_err, compilationData, contracts, accounts) => {
var testCallback: TestCbInterface = (err, test) => { var testCallback: TestCbInterface = (err, test) => {
if (err) { throw err } if (err) { throw err }
tests.push(test) tests.push(test)

Loading…
Cancel
Save