|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
import async, { ErrorCallback } from 'async' |
|
|
|
|
import deepequal from 'deep-equal' |
|
|
|
|
import { Compiler as RemixCompiler } from '@remix-project/remix-solidity' |
|
|
|
|
import { compileContractSources, writeTestAccountsContract } from './compiler' |
|
|
|
|
import { deployAll } from './deployer' |
|
|
|
|
import { runTest } from './testRunner' |
|
|
|
@ -16,6 +18,8 @@ export class UnitTestRunner { |
|
|
|
|
accountsLibCode |
|
|
|
|
testsAccounts: string[] | null |
|
|
|
|
web3 |
|
|
|
|
compiler |
|
|
|
|
compilerConfig |
|
|
|
|
|
|
|
|
|
constructor () { |
|
|
|
|
this.event = new EventEmitter() |
|
|
|
@ -53,7 +57,22 @@ export class UnitTestRunner { |
|
|
|
|
|
|
|
|
|
async.waterfall([ |
|
|
|
|
(next) => { |
|
|
|
|
compileContractSources(contractSources, compilerConfig, importFileCb, { accounts: this.testsAccounts, testFilePath: opts.testFilePath, event: this.event }, next) |
|
|
|
|
if (!deepequal(this.compilerConfig, compilerConfig)) { |
|
|
|
|
this.compilerConfig = compilerConfig |
|
|
|
|
const { currentCompilerUrl, evmVersion, optimize, runs, usingWorker } = compilerConfig |
|
|
|
|
this.compiler = new RemixCompiler(importFileCb) |
|
|
|
|
this.compiler.set('evmVersion', evmVersion) |
|
|
|
|
this.compiler.set('optimize', optimize) |
|
|
|
|
this.compiler.set('runs', runs) |
|
|
|
|
this.compiler.loadVersion(usingWorker, currentCompilerUrl) |
|
|
|
|
// @ts-ignore
|
|
|
|
|
this.compiler.event.register('compilerLoaded', this, (version) => { |
|
|
|
|
next() |
|
|
|
|
}) |
|
|
|
|
} else next() |
|
|
|
|
}, |
|
|
|
|
(next) => { |
|
|
|
|
compileContractSources(contractSources, this.compiler, { accounts: this.testsAccounts, testFilePath: opts.testFilePath, event: this.event }, next) |
|
|
|
|
}, |
|
|
|
|
(compilationResult: compilationInterface, asts: ASTInterface, next) => { |
|
|
|
|
for (const filename in asts) { |
|
|
|
|