From f53a4ef6093a797131d49943d03042f1b6485d99 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 3 Jan 2022 14:37:46 +0530 Subject: [PATCH 1/7] do not reload compiler for same config --- libs/remix-tests/package.json | 1 + libs/remix-tests/src/compiler.ts | 15 +-------------- libs/remix-tests/src/runTestSources.ts | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/libs/remix-tests/package.json b/libs/remix-tests/package.json index e193dfa42f..2055922334 100644 --- a/libs/remix-tests/package.json +++ b/libs/remix-tests/package.json @@ -49,6 +49,7 @@ "color-support": "^1.1.3", "colors": "^1.1.2", "commander": "^2.13.0", + "deep-equal": "^1.0.1", "ethereumjs-util": "^7.0.10", "ethers": "^5.4.2", "ethjs-util": "^0.1.6", diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index f4b9250ecf..bf18f7fd98 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -170,8 +170,7 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts * @param opts Options * @param cb Callback */ -export function compileContractSources (sources: SrcIfc, compilerConfig: CompilerConfiguration, importFileCb: any, opts: any, cb): void { - let compiler +export function compileContractSources (sources: SrcIfc, compiler: any, opts: any, cb): void { const filepath = opts.testFilePath || '' const testFileImportRegEx = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm @@ -184,18 +183,6 @@ export function compileContractSources (sources: SrcIfc, compilerConfig: Compile } async.waterfall([ - function loadCompiler (next) { - const { currentCompilerUrl, evmVersion, optimize, runs, usingWorker } = compilerConfig - compiler = new RemixCompiler(importFileCb) - compiler.set('evmVersion', evmVersion) - compiler.set('optimize', optimize) - compiler.set('runs', runs) - compiler.loadVersion(usingWorker, currentCompilerUrl) - // @ts-ignore - compiler.event.register('compilerLoaded', this, (version) => { - next() - }) - }, function doCompilation (next) { // @ts-ignore compiler.event.register('compilationFinished', this, (success, data, source) => { diff --git a/libs/remix-tests/src/runTestSources.ts b/libs/remix-tests/src/runTestSources.ts index 9d8b8ba400..0f2a72cea5 100644 --- a/libs/remix-tests/src/runTestSources.ts +++ b/libs/remix-tests/src/runTestSources.ts @@ -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) { From b399303a91fbde79be74a1d40c392d55fa4ef83d Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 3 Jan 2022 13:36:49 +0100 Subject: [PATCH 2/7] fix listening to event --- libs/remix-solidity/src/lib/eventManager.ts | 2 +- libs/remix-tests/src/compiler.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/remix-solidity/src/lib/eventManager.ts b/libs/remix-solidity/src/lib/eventManager.ts index 8282e09b6c..c8c1002430 100644 --- a/libs/remix-solidity/src/lib/eventManager.ts +++ b/libs/remix-solidity/src/lib/eventManager.ts @@ -21,7 +21,7 @@ export default class EventManager { obj = this.anonymous } for (const reg in this.registered[eventName]) { - if (this.registered[eventName][reg].obj === obj && this.registered[eventName][reg].func === func) { + if (this.registered[eventName][reg].obj === obj && this.registered[eventName][reg].func.toString() === func.toString()) { this.registered[eventName].splice(reg, 1) } } diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index bf18f7fd98..5abcb15c6e 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -184,11 +184,13 @@ export function compileContractSources (sources: SrcIfc, compiler: any, opts: an async.waterfall([ function doCompilation (next) { - // @ts-ignore - compiler.event.register('compilationFinished', this, (success, data, source) => { + const compilationFinishedCb = (success, data, source) => { if (opts && opts.event) opts.event.emit('compilationFinished', success, data, source) next(null, data) - }) + } + compiler.event.unregister('compilationFinished', compilationFinishedCb) + // @ts-ignore + compiler.event.register('compilationFinished', compilationFinishedCb) compiler.compile(sources, filepath) } ], function (err: Error | null | undefined, result: any) { From f90e4d3f638994d611a75beed4444c212f402372 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 3 Jan 2022 18:26:32 +0530 Subject: [PATCH 3/7] linting fix --- libs/remix-tests/src/compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index 5abcb15c6e..c287ca3677 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -190,7 +190,7 @@ export function compileContractSources (sources: SrcIfc, compiler: any, opts: an } compiler.event.unregister('compilationFinished', compilationFinishedCb) // @ts-ignore - compiler.event.register('compilationFinished', compilationFinishedCb) + compiler.event.register('compilationFinished', compilationFinishedCb) compiler.compile(sources, filepath) } ], function (err: Error | null | undefined, result: any) { From 9b56fc5e32b761e5eadb5d25b15210954afb68de Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 3 Jan 2022 15:03:01 +0100 Subject: [PATCH 4/7] fix firefox options --- apps/remix-ide-e2e/nightwatch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/nightwatch.ts b/apps/remix-ide-e2e/nightwatch.ts index b982fc0e77..f123a80a9b 100644 --- a/apps/remix-ide-e2e/nightwatch.ts +++ b/apps/remix-ide-e2e/nightwatch.ts @@ -79,9 +79,9 @@ module.exports = { acceptSslCerts: true, 'moz:firefoxOptions': { args: [ - '--headless', - '--width=2560', - '--height=1440' + '-headless', + '-width=2560', + '-height=1440' ] } } From e589c1785fb865ca9132b733211576339d93a504 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 3 Jan 2022 15:42:36 +0100 Subject: [PATCH 5/7] remove uneeded param --- apps/remix-ide/src/app.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index b4eb1dfdfe..22776e657d 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -272,8 +272,7 @@ class AppComponent { filePanel, Registry.getInstance().get('compilersartefacts').api, networkModule, - self.mainview, - Registry.getInstance().get('fileproviders/browser').api + egistry.getInstance().get('fileproviders/browser').api ) const analysis = new AnalysisTab() const debug = new DebuggerTab() From 7f481283b8fa3132fb55954e4bcd599718fe2412 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 3 Jan 2022 16:08:10 +0100 Subject: [PATCH 6/7] fix typo --- apps/remix-ide/src/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 22776e657d..d6e420b786 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -272,7 +272,7 @@ class AppComponent { filePanel, Registry.getInstance().get('compilersartefacts').api, networkModule, - egistry.getInstance().get('fileproviders/browser').api + Registry.getInstance().get('fileproviders/browser').api ) const analysis = new AnalysisTab() const debug = new DebuggerTab() From 4e6363a64cfa4c7ae374a0f2af42c298f547a05e Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 3 Jan 2022 18:04:26 +0100 Subject: [PATCH 7/7] Update nightwatch.ts --- apps/remix-ide-e2e/nightwatch.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/nightwatch.ts b/apps/remix-ide-e2e/nightwatch.ts index f123a80a9b..7925b01e7c 100644 --- a/apps/remix-ide-e2e/nightwatch.ts +++ b/apps/remix-ide-e2e/nightwatch.ts @@ -81,7 +81,8 @@ module.exports = { args: [ '-headless', '-width=2560', - '-height=1440' + '-height=1440', + '-window-size=2560x1440' ] } }