From 8854d2a610350be8ecbb5c7a6ad1178568bfdc23 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 14 Jan 2022 13:55:17 +0530 Subject: [PATCH 1/6] root test file creation --- .../solidity-unit-testing/src/lib/solidity-unit-testing.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 6cb5bc3820..a69883d9dd 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -672,6 +672,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d value={inputPathValue} title="Press 'Enter' to change the path for test files." style={{ backgroundImage: "var(--primary)" }} + onKeyDown={() => { if (inputPathValue === '/') setInputPathValue('')} } onKeyUp={handleTestDirInput} onChange={handleEnter} onClick = {() => { if (inputPathValue === '/') setInputPathValue('')} } From f4ae5a1465f8092267652e316ba6146267243313 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 14 Jan 2022 14:25:03 +0530 Subject: [PATCH 2/6] show toaster on test folder creation --- .../solidity-unit-testing/src/lib/logic/testTabLogic.ts | 9 +++------ .../src/lib/solidity-unit-testing.tsx | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts b/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts index 6e1af409a4..87a6f33d80 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts +++ b/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts @@ -21,23 +21,20 @@ export class TestTabLogic { this.currentPath = this.helper.removeMultipleSlashes(this.helper.removeTrailingSlashes(path)) } - generateTestFolder (path:string) { + async generateTestFolder (path:string) { // Todo move this check to File Manager after refactoring // Checking to ignore the value which contains only whitespaces if (!path || !(/\S/.test(path))) return path = this.helper.removeMultipleSlashes(path) const fileProvider = this.fileManager.fileProviderOf(path.split('/')[0]) - fileProvider.exists(path).then((res: boolean) => { - if (!res) fileProvider.createDir(path) - }) + if(!await fileProvider.exists(path)) fileProvider.createDir(path) } async pathExists (path: string) { // Checking to ignore the value which contains only whitespaces if (!path || !(/\S/.test(path))) return const fileProvider = this.fileManager.fileProviderOf(path.split('/')[0]) - const res = await fileProvider.exists(path, (e: Error, res: boolean) => { return res }) - return res + return await fileProvider.exists(path) } // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index a69883d9dd..2acb1ee4e4 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -222,7 +222,8 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d if (path !== '/') path = helper.removeTrailingSlashes(path) if (inputPath === '') inputPath = defaultPath setInputPathValue(path) - testTabLogic.generateTestFolder(inputPath) + await testTabLogic.generateTestFolder(inputPath) + setToasterMsg('Folder created successfully') setDisableCreateButton(true) setDisableGenerateButton(false) testTabLogic.setCurrentPath(inputPath) From d8f2db030e8a8b7fdddb6a055f679c7c86d46884 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 12 Jan 2022 19:14:34 +0530 Subject: [PATCH 3/6] move compiler events in one file --- libs/remix-tests/src/compiler.ts | 27 ++++++++++++++++++++++++-- libs/remix-tests/src/runTestSources.ts | 22 ++------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index c287ca3677..05852c5b3d 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -1,6 +1,7 @@ import fs from './fileSystem' import async from 'async' import path from 'path' +import deepequal from 'deep-equal' import Log from './logger' import { Compiler as RemixCompiler } from '@remix-project/remix-solidity' import { SrcIfc, CompilerConfiguration, CompilationErrors } from './types' @@ -170,7 +171,8 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts * @param opts Options * @param cb Callback */ -export function compileContractSources (sources: SrcIfc, compiler: any, opts: any, cb): void { +export function compileContractSources (sources: SrcIfc, newCompConfig: any, importFileCb, UTRunner, opts: any, cb): void { + let compiler const filepath = opts.testFilePath || '' const testFileImportRegEx = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm @@ -183,8 +185,29 @@ export function compileContractSources (sources: SrcIfc, compiler: any, opts: an } async.waterfall([ - function doCompilation (next) { + (next) => { + if (!deepequal(UTRunner.compilerConfig, newCompConfig)) { + UTRunner.compilerConfig = newCompConfig + const { currentCompilerUrl, evmVersion, optimize, runs, usingWorker } = newCompConfig + 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) => { + console.log('Inside compiler loaded') + next() + }) + } else { + compiler = UTRunner.compiler + next() + } + }, + (next) => { + console.log('compiler before compilation', compiler) const compilationFinishedCb = (success, data, source) => { + UTRunner.compiler = compiler if (opts && opts.event) opts.event.emit('compilationFinished', success, data, source) next(null, data) } diff --git a/libs/remix-tests/src/runTestSources.ts b/libs/remix-tests/src/runTestSources.ts index 0f2a72cea5..40f0d87788 100644 --- a/libs/remix-tests/src/runTestSources.ts +++ b/libs/remix-tests/src/runTestSources.ts @@ -1,6 +1,4 @@ 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' @@ -50,29 +48,13 @@ export class UnitTestRunner { * @param importFileCb Import file callback * @param opts Options */ - async runTestSources (contractSources: SrcIfc, compilerConfig: CompilerConfiguration, testCallback, resultCallback, deployCb:any, finalCallback: any, importFileCb, opts: Options) { + async runTestSources (contractSources: SrcIfc, newCompilerConfig: CompilerConfiguration, testCallback, resultCallback, deployCb:any, finalCallback: any, importFileCb, opts: Options) { opts = opts || {} const sourceASTs: any = {} if (opts.web3 || opts.accounts) this.init(opts.web3, opts.accounts) - async.waterfall([ (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) + compileContractSources(contractSources, newCompilerConfig, importFileCb, this, { accounts: this.testsAccounts, testFilePath: opts.testFilePath, event: this.event }, next) }, (compilationResult: compilationInterface, asts: ASTInterface, next) => { for (const filename in asts) { From 0f5920a672b58debc4a72c703b81714e45ce6a84 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 12 Jan 2022 19:30:21 +0530 Subject: [PATCH 4/6] do not preserve compiler state on worker error on load --- libs/remix-tests/src/compiler.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index 05852c5b3d..740a306931 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -196,7 +196,6 @@ export function compileContractSources (sources: SrcIfc, newCompConfig: any, imp compiler.loadVersion(usingWorker, currentCompilerUrl) // @ts-ignore compiler.event.register('compilerLoaded', this, (version) => { - console.log('Inside compiler loaded') next() }) } else { @@ -205,9 +204,9 @@ export function compileContractSources (sources: SrcIfc, newCompConfig: any, imp } }, (next) => { - console.log('compiler before compilation', compiler) const compilationFinishedCb = (success, data, source) => { - UTRunner.compiler = compiler + // data.error usually exists for exceptions like worker error etc. + if (!data.error) UTRunner.compiler = compiler if (opts && opts.event) opts.event.emit('compilationFinished', success, data, source) next(null, data) } From 72b16c7eb8d17c4d086e988278295ece1fc6e5e3 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 17 Jan 2022 10:34:39 +0100 Subject: [PATCH 5/6] new file, open file fixed --- .../home-tab/src/lib/remix-ui-home-tab.css | 1 + .../home-tab/src/lib/remix-ui-home-tab.tsx | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.css b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.css index 6644f4988e..b4f82c18d5 100644 --- a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.css +++ b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.css @@ -1,5 +1,6 @@ .remixui_text { cursor: pointer; + font-size: 0.8rem; font-weight: normal; max-width: 300px; } diff --git a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx index c130d35a64..c222e3fa06 100644 --- a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx +++ b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx @@ -125,6 +125,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { } const createNewFile = async () => { + plugin.verticalIcons.select('filePanel') await plugin.call('filePanel', 'createNewFile') } @@ -261,21 +262,22 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {

File

- createNewFile()}>New File +

- + + + { + event.stopPropagation() + plugin.verticalIcons.select('filePanel') + uploadFile(event.target) + }} multiple />

- connectToLocalhost()}>Connect to Localhost +

@@ -301,7 +303,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {

- switchToPreviousVersion()}>Old experience +

From 0043885eaaba20489df0620e0443a5a3492bc49b Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 17 Jan 2022 10:40:27 +0100 Subject: [PATCH 6/6] Update remix-ui-home-tab.tsx --- libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx index 6464c9f6af..ecbca46eb7 100644 --- a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx +++ b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx @@ -262,7 +262,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {

File

- +