From 7a7394e2e6f3c4cf3ac79b9ae2745e100b385fac Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 8 Oct 2020 14:19:20 +0200 Subject: [PATCH] Make sure contents accessed by their external URL is properly handled --- apps/remix-ide-e2e/src/tests/debugger.test.ts | 28 ++++++++++++++++++- apps/remix-ide/src/app/files/fileProvider.js | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/debugger.test.ts b/apps/remix-ide-e2e/src/tests/debugger.test.ts index 7da6d8db7c..242ec06d49 100644 --- a/apps/remix-ide-e2e/src/tests/debugger.test.ts +++ b/apps/remix-ide-e2e/src/tests/debugger.test.ts @@ -72,7 +72,28 @@ module.exports = { .click('*[data-id="buttonNavigatorJumpNextBreakpoint"]') .pause(2000) .assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n184') - .assert.containsText('*[data-id="stepdetail"]', 'execution step:\n184') + .assert.containsText('*[data-id="stepdetail"]', 'execution step:\n184') + }, + + 'Should display solidity imported code while debugging github import': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('solidity') + .setSolidityCompilerVersion('soljson-v0.6.12+commit.27d51765.js') + .clickLaunchIcon('udapp') + .testContracts('externalImport.sol', sources[1]['browser/externalImport.sol'], ['ERC20']) + .selectContract('ERC20') + .createContract('"tokenName", "symbol"') + .debugTransaction(2) + .pause(2000) + .goToVMTraceStep(10) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`constructor (string memory name, string memory symbol) public { + _name = name; + _symbol = symbol; + _decimals = 18; + }`) != -1, + 'current displayed content is not from the ERC20 source code') + }) .end() }, @@ -112,5 +133,10 @@ const sources = [ } ` } + }, + { + 'browser/externalImport.sol': {content: 'import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; contract test7 {}'} } ] + + diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index 4fd00db6d4..1e05587bd9 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -70,6 +70,7 @@ class FileProvider { } _exists (path) { + path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here var unprefixedpath = this.removePrefix(path) return path === this.type ? true : window.remixFileSystem.existsSync(unprefixedpath) } @@ -148,6 +149,7 @@ class FileProvider { } isFile (path) { + path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here path = this.removePrefix(path) return window.remixFileSystem.statSync(path).isFile() }