Add types file

pull/7/head
Omkara 6 years ago
parent 0400854e8c
commit 206a65494e
  1. 14
      remix-tests/src/compiler.ts
  2. 4
      remix-tests/src/deployer.ts
  3. 3
      remix-tests/src/runTestFiles.ts
  4. 8
      remix-tests/src/runTestSources.ts
  5. 27
      remix-tests/src/testRunner.ts
  6. 39
      remix-tests/src/types.ts
  7. 7
      remix-tests/tests/testRunner.ts

@ -1,15 +1,15 @@
/* eslint no-extend-native: "warn" */
import fs from './fileSystem'
var async = require('async')
import async from 'async'
var path = require('path')
let RemixCompiler = require('remix-solidity').Compiler
import { SrcIfc } from './types'
function regexIndexOf (inputString, regex, startpos = 0) {
function regexIndexOf (inputString: string, regex: RegExp, startpos: number = 0) {
var indexOf = inputString.substring(startpos).search(regex)
return (indexOf >= 0) ? (indexOf + (startpos)) : indexOf
}
function writeTestAccountsContract (accounts) {
function writeTestAccountsContract (accounts: string[]) {
var testAccountContract = require('../sol/tests_accounts.sol.js')
var body = 'address[' + accounts.length + '] memory accounts;'
if (!accounts.length) body += ';'
@ -72,7 +72,7 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
})
compiler.compile(sources, filepath)
}
], function (err: Error | null | undefined, result) {
], function (err: Error | null | undefined, result: any) {
let errors = (result.errors || []).filter((e) => e.type === 'Error' || e.severity === 'error')
if (errors.length > 0) {
if (!isBrowser) require('signale').fatal(errors)
@ -83,7 +83,7 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
}
}
export function compileContractSources(sources, importFileCb, opts, cb) {
export function compileContractSources(sources: SrcIfc, importFileCb, opts, cb) {
let compiler, filepath
let accounts = opts.accounts || []
// Iterate over sources keys. Inject test libraries. Inject test library import statements.
@ -115,7 +115,7 @@ export function compileContractSources(sources, importFileCb, opts, cb) {
})
compiler.compile(sources, filepath)
}
], function (err: Error | null | undefined , result) {
], function (err: Error | null | undefined , result: any) {
let errors = (result.errors || []).filter((e) => e.type === 'Error' || e.severity === 'error')
if (errors.length > 0) {
if (!isBrowser) require('signale').fatal(errors)

@ -1,8 +1,8 @@
var async = require('async')
import async from 'async'
var remixLib = require('remix-lib')
import Web3 from 'web3'
export function deployAll(compileResult: object, web3: Web3, callback: Function) {
export function deployAll(compileResult: object, web3: Web3, callback) {
let compiledObject = {}
let contracts = {}
let accounts: string[] = []

@ -1,6 +1,7 @@
import async from 'async'
import fs from './fileSystem'
import { runTest, TestResultInterface, ResultsInterface } from './testRunner'
import { runTest } from './testRunner'
import { TestResultInterface, ResultsInterface } from './types'
import colors from 'colors'
import Web3 from 'web3'

@ -7,13 +7,7 @@ import { runTest } from './testRunner'
import Web3 = require('web3')
import Provider from 'remix-simulator'
interface FinalResult {
totalPassing: number,
totalFailing: number,
totalTime: number,
errors: any[],
}
import { FinalResult } from './types'
var createWeb3Provider = function () {
let web3 = new Web3()

@ -1,32 +1,7 @@
import async from 'async'
import * as changeCase from 'change-case'
import Web3 from 'web3'
export interface TestResultInterface {
type: string,
value: any,
time?: number,
context?: string,
errMsg?: string
filename?: string
}
interface RunListInterface {
name: string,
type: string,
constant: boolean,
signature?: any
}
export interface ResultsInterface {
passingNum: number,
failureNum: number,
timePassed: number
}
export interface TestCbInterface {
(error: Error | null | undefined, result: TestResultInterface) : void;
}
export interface ResultCbInterface {
(error: Error | null | undefined, result: ResultsInterface) : void;
}
import { RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface } from './types'
function getFunctionFullName (signature, methodIdentifiers) {
for (var method in methodIdentifiers) {

@ -0,0 +1,39 @@
/** sources object with name of the file and content **/
export interface SrcIfc {
[key: string]: {
content: string
}
}
/** An object with final results of test **/
export interface FinalResult {
totalPassing: number,
totalFailing: number,
totalTime: number,
errors: any[],
}
/** List of tests to run **/
export interface RunListInterface {
name: string,
type: string,
constant: boolean,
signature?: any
}
export interface ResultsInterface {
passingNum: number,
failureNum: number,
timePassed: number
}
export interface TestResultInterface {
type: string,
value: any,
time?: number,
context?: string,
errMsg?: string
filename?: string
}
export interface TestCbInterface {
(error: Error | null | undefined, result: TestResultInterface) : void;
}
export interface ResultCbInterface {
(error: Error | null | undefined, result: ResultsInterface) : void;
}

@ -5,16 +5,17 @@ import { Provider } from 'remix-simulator'
import { compileFileOrFiles } from '../dist/compiler'
import { deployAll } from '../dist/deployer'
import { runTest, ResultsInterface, TestCbInterface, ResultCbInterface } from '../dist/testRunner'
import { runTest } from '../dist/testRunner'
import { ResultsInterface, TestCbInterface, ResultCbInterface } from '../dist/types'
function compileAndDeploy(filename: string, callback: Function) {
let web3: Web3 = new Web3()
web3.setProvider(new Provider())
let compilationData: object
let accounts: object
let accounts: string[]
async.waterfall([
function getAccountList(next: Function): void {
web3.eth.getAccounts((_err: Error | null | undefined, _accounts: object) => {
web3.eth.getAccounts((_err: Error | null | undefined, _accounts: string[]) => {
accounts = _accounts
next(_err)
})

Loading…
Cancel
Save