diff --git a/remix-tests/src/compiler.ts b/remix-tests/src/compiler.ts index 7ec33d4a6f..3b247ff5c4 100644 --- a/remix-tests/src/compiler.ts +++ b/remix-tests/src/compiler.ts @@ -2,7 +2,7 @@ import fs from './fileSystem' import async from 'async' import path from 'path' let RemixCompiler = require('remix-solidity').Compiler -import { SrcIfc } from './types' +import { SrcIfc, CompilerConfiguration } from './types' function regexIndexOf (inputString: string, regex: RegExp, startpos: number = 0) { const indexOf = inputString.substring(startpos).search(regex) @@ -143,12 +143,12 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts: * @dev Compile contract source before running tests (used for IDE tests execution) * @param sources sources * @param versionUrl url of selected compiler version to load - * @param usingWorker if true, load compiler using web worker + * @param compilerConfig current compiler configuration * @param importFileCb Import file callback * @param opts Options * @param cb Callback */ -export function compileContractSources(sources: SrcIfc, versionUrl: any, usingWorker: boolean, importFileCb: any, opts: any, cb: Function) { +export function compileContractSources(sources: SrcIfc, compilerConfig: CompilerConfiguration, importFileCb: any, opts: any, cb: Function) { let compiler, filepath: string const accounts: string[] = opts.accounts || [] // Iterate over sources keys. Inject test libraries. Inject test library import statements. @@ -169,8 +169,11 @@ export function compileContractSources(sources: SrcIfc, versionUrl: any, usingWo async.waterfall([ function loadCompiler (next: Function) { + const {currentCompilerUrl, evmVersion, optimize, usingWorker} = compilerConfig compiler = new RemixCompiler(importFileCb) - compiler.loadVersion(usingWorker, versionUrl) + compiler.set('evmVersion', evmVersion) + compiler.set('optimize', optimize) + compiler.loadVersion(usingWorker, currentCompilerUrl) // @ts-ignore compiler.event.register('compilerLoaded', this, (version) => { next() diff --git a/remix-tests/src/runTestSources.ts b/remix-tests/src/runTestSources.ts index 6c88c4008e..1d1d6f853f 100644 --- a/remix-tests/src/runTestSources.ts +++ b/remix-tests/src/runTestSources.ts @@ -7,7 +7,8 @@ import { runTest } from './testRunner' import Web3 from 'web3'; import { Provider } from 'remix-simulator' -import { FinalResult, SrcIfc, compilationInterface, ASTInterface, Options, TestResultInterface, AstNode } from './types' +import { FinalResult, SrcIfc, compilationInterface, ASTInterface, Options, + TestResultInterface, AstNode, CompilerConfiguration } from './types' const createWeb3Provider = async function () { let web3 = new Web3() @@ -20,15 +21,14 @@ const createWeb3Provider = async function () { /** * @dev Run tests from source of a test contract file (used for IDE) * @param contractSources Sources of contract - * @param versionUrl url of selected compiler version to load - * @param usingWorker if true, load compiler using web worker + * @param compilerConfig current compiler configuration * @param testCallback Test callback * @param resultCallback Result Callback * @param finalCallback Final Callback * @param importFileCb Import file callback * @param opts Options */ -export async function runTestSources(contractSources: SrcIfc, versionUrl: string, usingWorker: boolean, testCallback: Function, resultCallback: Function, finalCallback: any, importFileCb: Function, opts: Options) { +export async function runTestSources(contractSources: SrcIfc, compilerConfig: CompilerConfiguration, testCallback: Function, resultCallback: Function, finalCallback: any, importFileCb: Function, opts: Options) { opts = opts || {} const sourceASTs: any = {} let web3 = opts.web3 || await createWeb3Provider() @@ -42,7 +42,7 @@ export async function runTestSources(contractSources: SrcIfc, versionUrl: string }) }, function compile (next) { - compileContractSources(contractSources, versionUrl, usingWorker, importFileCb, { accounts }, next) + compileContractSources(contractSources, compilerConfig, importFileCb, { accounts }, next) }, function deployAllContracts (compilationResult: compilationInterface, asts: ASTInterface, next) { for(const filename in asts) { diff --git a/remix-tests/src/types.ts b/remix-tests/src/types.ts index 89e56d3fe4..8a791cf46f 100644 --- a/remix-tests/src/types.ts +++ b/remix-tests/src/types.ts @@ -44,6 +44,13 @@ export interface Options { web3?: any } +export interface CompilerConfiguration { + currentCompilerUrl: string, + evmVersion: string, + optimize: boolean, + usingWorker: boolean +} + /** sources object with name of the file and content **/ ////////////