From 1fbe96e82153a4a494928380675725529ea33509 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 7b61add83f6072ab3b3e550062bb4e25bfc3a124 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 371a02b8fada9545af3d5cbc13e3fec3f1eb3e5a 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 3d7ec276b1ced1f7ff00cb5ed6cb629cdfa00541 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 5abadd62c7c8729bb57661c0cca61a76765cb565 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 25398fe531bc754d36774ef0b8bd3b9273b7f03e 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 34f5d7163c9aeab7b9f6bce08029739e95a910e9 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' ] } }