Unverified Commit 491a3235 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #2898 from ethereum/fix#2864

Txlistener reads on the last compilation per file and not only the last one
parents 705b0da5 3c25b59a
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -55,13 +55,13 @@ ...@@ -55,13 +55,13 @@
"npm-merge-driver": "^2.3.5", "npm-merge-driver": "^2.3.5",
"npm-run-all": "^4.0.2", "npm-run-all": "^4.0.2",
"onchange": "^3.2.1", "onchange": "^3.2.1",
"remix-analyzer": "0.5.2", "remix-analyzer": "0.5.3",
"remix-debug": "0.4.4", "remix-debug": "0.4.5",
"remix-lib": "0.4.29", "remix-lib": "0.4.30",
"remix-simulator": "0.1.9-beta.5", "remix-simulator": "0.1.9-beta.6",
"remix-solidity": "0.3.30", "remix-solidity": "0.3.31",
"remix-tabs": "1.0.48", "remix-tabs": "1.0.48",
"remix-tests": "0.1.33", "remix-tests": "0.1.34",
"remixd": "0.1.8-alpha.16", "remixd": "0.1.8-alpha.16",
"request": "^2.83.0", "request": "^2.83.0",
"rimraf": "^2.6.1", "rimraf": "^2.6.1",
...@@ -186,6 +186,7 @@ ...@@ -186,6 +186,7 @@
"nightwatch_local_debugger": "nightwatch ./test-browser/tests/debugger.test.js --config nightwatch.js --env chrome ", "nightwatch_local_debugger": "nightwatch ./test-browser/tests/debugger.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_editor": "nightwatch ./test-browser/tests/editor.test.js --config nightwatch.js --env chrome ", "nightwatch_local_editor": "nightwatch ./test-browser/tests/editor.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_compiler": "nightwatch ./test-browser/tests/compiler_api.test.js --config nightwatch.js --env chrome ", "nightwatch_local_compiler": "nightwatch ./test-browser/tests/compiler_api.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_txListener": "nightwatch ./test-browser/tests/txListener.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_runAndDeploy": "nightwatch ./test-browser/tests/runAndDeploy.js --config nightwatch.js --env chrome-runAndDeploy ", "nightwatch_local_runAndDeploy": "nightwatch ./test-browser/tests/runAndDeploy.js --config nightwatch.js --env chrome-runAndDeploy ",
"onchange": "onchange build/app.js -- npm-run-all lint", "onchange": "onchange build/app.js -- npm-run-all lint",
"prepublish": "mkdirp build; npm-run-all -ls downloadsolc_root build", "prepublish": "mkdirp build; npm-run-all -ls downloadsolc_root build",
......
...@@ -14,28 +14,52 @@ module.exports = class CompilerArtefacts extends Plugin { ...@@ -14,28 +14,52 @@ module.exports = class CompilerArtefacts extends Plugin {
constructor () { constructor () {
super(profile) super(profile)
this.compilersArtefacts = {} this.compilersArtefacts = {}
this.compilersArtefactsPerFile = {}
} }
clear () { clear () {
this.compilersArtefacts = {} this.compilersArtefacts = {}
this.compilersArtefactsPerFile = {}
} }
onActivation () { onActivation () {
const saveCompilationPerFileResult = (file, source, languageVersion, data) => {
this.compilersArtefactsPerFile[file] = new CompilerAbstract(languageVersion, data, source)
}
this.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => { this.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
}) })
this.on('vyper', 'compilationFinished', (file, source, languageVersion, data) => { this.on('vyper', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
}) })
this.on('lexon', 'compilationFinished', (file, source, languageVersion, data) => { this.on('lexon', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
}) })
this.on('yulp', 'compilationFinished', (file, source, languageVersion, data) => { this.on('yulp', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
})
}
getAllContractDatas () {
const contractsData = {}
Object.keys(this.compilersArtefactsPerFile).map((targetFile) => {
const contracts = this.compilersArtefactsPerFile[targetFile].getContracts()
Object.keys(contracts).map((file) => { contractsData[file] = contracts[file] })
}) })
// making sure we save last compilation result in there
if (this.compilersArtefacts['__last']) {
const contracts = this.compilersArtefacts['__last'].getContracts()
Object.keys(contracts).map((file) => { contractsData[file] = contracts[file] })
}
return contractsData
} }
addResolvedContract (address, compilerData) { addResolvedContract (address, compilerData) {
......
...@@ -72,7 +72,7 @@ export default class FetchAndCompile extends Plugin { ...@@ -72,7 +72,7 @@ export default class FetchAndCompile extends Plugin {
name === 'main' ? 'mainnet' : name // source-verifier api expect "mainnet" and not "main" name === 'main' ? 'mainnet' : name // source-verifier api expect "mainnet" and not "main"
let data let data
try { try {
data = await this.call('source-verification', 'fetchByNetwork', contractAddress, name.toLowerCase()) data = await this.call('sourcify', 'fetchByNetwork', contractAddress, name.toLowerCase())
} catch (e) { } catch (e) {
setTimeout(_ => this.emit('notFound', contractAddress), 0) // plugin framework returns a time out error although it actually didn't find the source... setTimeout(_ => this.emit('notFound', contractAddress), 0) // plugin framework returns a time out error although it actually didn't find the source...
this.unresolvedAddresses.push(contractAddress) this.unresolvedAddresses.push(contractAddress)
......
...@@ -64,7 +64,7 @@ class DebuggerTab extends ViewPlugin { ...@@ -64,7 +64,7 @@ class DebuggerTab extends ViewPlugin {
} }
) )
this.call('manager', 'activatePlugin', 'source-verification') this.call('manager', 'activatePlugin', 'sourcify')
// this.call('manager', 'activatePlugin', 'udapp') // this.call('manager', 'activatePlugin', 'udapp')
return this.el return this.el
......
...@@ -32,7 +32,7 @@ export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) { ...@@ -32,7 +32,7 @@ export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) {
const txlistener = blockchain.getTxListener({ const txlistener = blockchain.getTxListener({
api: { api: {
contracts: function () { contracts: function () {
if (compilersArtefacts['__last']) return compilersArtefacts['__last'].getContracts() if (compilersArtefacts['__last']) return compilersArtefacts.getAllContractDatas()
return null return null
}, },
resolveReceipt: function (tx, cb) { resolveReceipt: function (tx, cb) {
......
...@@ -163,8 +163,8 @@ export class LandingPage extends ViewPlugin { ...@@ -163,8 +163,8 @@ export class LandingPage extends ViewPlugin {
} }
const startSourceVerify = () => { const startSourceVerify = () => {
this.appManager.ensureActivated('solidity') this.appManager.ensureActivated('solidity')
this.appManager.ensureActivated('source-verification') this.appManager.ensureActivated('sourcify')
this.verticalIcons.select('source-verification') this.verticalIcons.select('sourcify')
} }
const startPluginManager = () => { const startPluginManager = () => {
this.appManager.ensureActivated('pluginManager') this.appManager.ensureActivated('pluginManager')
...@@ -208,7 +208,7 @@ export class LandingPage extends ViewPlugin { ...@@ -208,7 +208,7 @@ export class LandingPage extends ViewPlugin {
const pipelineEnv = createEnvButton('assets/img/pipelineLogo.webp', 'pipelineLogo', 'Pipeline', startPipeline) const pipelineEnv = createEnvButton('assets/img/pipelineLogo.webp', 'pipelineLogo', 'Pipeline', startPipeline)
const debuggerEnv = createEnvButton('assets/img/debuggerLogo.webp', 'debuggerLogo', 'Debugger', startDebugger) const debuggerEnv = createEnvButton('assets/img/debuggerLogo.webp', 'debuggerLogo', 'Debugger', startDebugger)
const mythXEnv = createEnvButton('assets/img/mythxLogo.webp', 'mythxLogo', 'MythX', startMythX) const mythXEnv = createEnvButton('assets/img/mythxLogo.webp', 'mythxLogo', 'MythX', startMythX)
const sourceVerifyEnv = createEnvButton('assets/img/sourceVerifyLogo.webp', 'sourceVerifyLogo', 'Source Verify', startSourceVerify) const sourceVerifyEnv = createEnvButton('assets/img/sourceVerifyLogo.webp', 'sourceVerifyLogo', 'Sourcify', startSourceVerify)
const moreEnv = createEnvButton('assets/img/moreLogo.webp', 'moreLogo', 'More', startPluginManager) const moreEnv = createEnvButton('assets/img/moreLogo.webp', 'moreLogo', 'More', startPluginManager)
const invertNum = (globalRegistry.get('themeModule').api.currentTheme().quality === 'dark') ? 1 : 0 const invertNum = (globalRegistry.get('themeModule').api.currentTheme().quality === 'dark') ? 1 : 0
......
...@@ -70,8 +70,8 @@ module.exports = { ...@@ -70,8 +70,8 @@ module.exports = {
.assert.containsText('*[data-id="stepdetail"]', 'execution step: 0') .assert.containsText('*[data-id="stepdetail"]', 'execution step: 0')
.click('*[data-id="buttonNavigatorJumpNextBreakpoint"]') .click('*[data-id="buttonNavigatorJumpNextBreakpoint"]')
.pause(2000) .pause(2000)
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 140') .assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 184')
.assert.containsText('*[data-id="stepdetail"]', 'execution step: 140') .assert.containsText('*[data-id="stepdetail"]', 'execution step: 184')
.end() .end()
}, },
......
...@@ -156,7 +156,7 @@ module.exports = { ...@@ -156,7 +156,7 @@ module.exports = {
* - Source Verifier service for fetching the contract code * - Source Verifier service for fetching the contract code
* - Ropsten node for retrieving the trace and storage * - Ropsten node for retrieving the trace and storage
* *
*/ */
'Should debug Ropsten transaction with source highlighting using the source verifier service and MetaMask': function (browser) { 'Should debug Ropsten transaction with source highlighting using the source verifier service and MetaMask': function (browser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]') browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
......
...@@ -4,6 +4,12 @@ var sauce = require('./sauce') ...@@ -4,6 +4,12 @@ var sauce = require('./sauce')
module.exports = { module.exports = {
before: function (browser, done) { before: function (browser, done) {
// this test suite also contribute testing https://github.com/ethereum/remix/pull/1497 and https://github.com/ethereum/remix-ide/pull/2898
// quick explanation:
// the goal of https://github.com/ethereum/remix-ide/pull/2898 is to keep track of all the compiled contracts an not only the last one.
// this introduce an issue: if 2 compiled contracts have the same name, the second one override the first which is not wanted.
// fix's delivered by https://github.com/ethereum/remix/pull/1497: instead of getting contract by name,
// which result in name clashing we process the whole contract object (which contain bytecode, deployedbytecode, ...)
init(browser, done) init(browser, done)
}, },
'@sources': function () { '@sources': function () {
......
...@@ -41,7 +41,7 @@ function runTests (browser) { ...@@ -41,7 +41,7 @@ function runTests (browser) {
.waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () {
listSelectorContains(['Use of tx.origin', listSelectorContains(['Use of tx.origin',
'Fallback function of contract TooMuchGas requires too much gas', 'Fallback function of contract TooMuchGas requires too much gas',
'TooMuchGas.() : Variables have very similar names test and test1.'], 'TooMuchGas.() : Variables have very similar names "test" and "test1".'],
'#staticanalysisresult .warning', '#staticanalysisresult .warning',
browser, function () { browser, function () {
browser.end() browser.end()
......
'use strict'
var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var sources = [
{'browser/Untitled.sol': {content: examples.ballot.content}},
{'browser/Untitled1.sol': {content: `contract test {}`}}
]
module.exports = {
before: function (browser, done) {
init(browser, done)
},
'@sources': function () {
return sources
},
'The sequence: Compiling / Deploying / Compiling another contract / calling the first contract - should display in the log the transaction with all the decoded information': function (browser) {
// https://github.com/ethereum/remix-ide/issues/2864
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('solidity')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp')
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c')
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
.click('*[data-id="Deploy - transact (not payable)"]')
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
.click('*[data-id="universalDappUiTitleExpander"]')
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
.testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
{
status: '0x1 Transaction mined and execution succeed',
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
.clickLaunchIcon('solidity')
.testContracts('Untitled1.sol', sources[1]['browser/Untitled1.sol'], ['test'])
.clickLaunchIcon('udapp')
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: ''})
.pause(5000)
.testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
{
status: '0x0 Transaction mined but execution failed',
'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
.end()
},
tearDown: sauce
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment