From 2e642cce20218c1f7bb58d07436f23c20e598a01 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Fri, 20 Mar 2020 16:09:56 +0000 Subject: [PATCH 1/4] Debugger e2e tests --- package.json | 1 + src/app/ui/multiParamManager.js | 6 +-- src/app/ui/txLogger.js | 2 +- src/app/ui/universal-dapp-ui.js | 2 +- test-browser/tests/debugger.js | 73 +++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 test-browser/tests/debugger.js diff --git a/package.json b/package.json index 791de96a81..3fcd8992cf 100644 --- a/package.json +++ b/package.json @@ -182,6 +182,7 @@ "nightwatch_local_publishContract": "nightwatch ./test-browser/tests/publishContract.js --config nightwatch.js --env chrome ", "nightwatch_local_generalSettings": "nightwatch ./test-browser/tests/generalSettings.js --config nightwatch.js --env chrome ", "nightwatch_local_fileExplorer": "nightwatch ./test-browser/tests/fileExplorer.js --config nightwatch.js --env chrome ", + "nightwatch_local_debugger": "nightwatch ./test-browser/tests/debugger.js --config nightwatch.js --env chrome ", "onchange": "onchange build/app.js -- npm-run-all lint", "prepublish": "mkdirp build; npm-run-all -ls downloadsolc_root build", "remixd": "remixd -s ./contracts --remix-ide http://127.0.0.1:8080", diff --git a/src/app/ui/multiParamManager.js b/src/app/ui/multiParamManager.js index bf6795674a..1f5211bc86 100644 --- a/src/app/ui/multiParamManager.js +++ b/src/app/ui/multiParamManager.js @@ -116,14 +116,14 @@ class MultiParamManager { title = this.funABI.type === 'receive' ? '(receive)' : '(fallback)' } - this.basicInputField = yo`` + this.basicInputField = yo`` this.basicInputField.setAttribute('placeholder', this.inputs) this.basicInputField.setAttribute('title', this.inputs) var onClick = () => { this.clickCallBack(this.funABI.inputs, this.basicInputField.value) } - let funcButton = yo`` + let funcButton = yo`` this.contractActionsContainerSingle = yo`
${funcButton} @@ -142,7 +142,7 @@ class MultiParamManager { } } - var expandedButton = yo`` + var expandedButton = yo`` this.contractActionsContainerMulti = yo`
diff --git a/src/app/ui/txLogger.js b/src/app/ui/txLogger.js index 2301ccbc06..4ab75bdc34 100644 --- a/src/app/ui/txLogger.js +++ b/src/app/ui/txLogger.js @@ -215,7 +215,7 @@ function renderKnownTransaction (self, data, blockchain) { ${checkTxStatus(data.receipt, txType)} ${context(self, {from, to, data}, blockchain)}
-
+
diff --git a/src/app/ui/universal-dapp-ui.js b/src/app/ui/universal-dapp-ui.js index 59381cbd23..975a6a46fd 100644 --- a/src/app/ui/universal-dapp-ui.js +++ b/src/app/ui/universal-dapp-ui.js @@ -60,7 +60,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address var shortAddress = helper.shortenAddress(address) var title = yo`
-
diff --git a/test-browser/tests/debugger.js b/test-browser/tests/debugger.js new file mode 100644 index 0000000000..e09fb36aee --- /dev/null +++ b/test-browser/tests/debugger.js @@ -0,0 +1,73 @@ +'use strict' +var init = require('../helpers/init') +var sauce = require('./sauce') + +module.exports = { + + before: function (browser, done) { + init(browser, done) + }, + + '@sources': function () { + return sources + }, + + 'Should launch debugger': function (browser) { + browser.addFile('blah.sol', sources[0]['browser/blah.sol']) + .clickLaunchIcon('udapp') + .waitForElementPresent('*[title="Deploy - transact (not payable)"]') + .click('*[title="Deploy - transact (not payable)"]') + .waitForElementPresent('*[data-shared="txLoggerDebugButton"]:nth-of-type(1)') + .click('*[data-shared="txLoggerDebugButton"]:nth-of-type(1)') + .assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEBUGGER') + }, + + 'Should debug failing transaction': function (browser) { + browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]') + .clickLaunchIcon('udapp') + .waitForElementPresent('*[data-id="universalDappUiTitleExpander"]') + .click('*[data-id="universalDappUiTitleExpander"]') + .waitForElementPresent('*[data-shared="multiParamManagerBasicInputField"]:nth-of-type(1)') + .sendKeys('*[data-shared="multiParamManagerBasicInputField"]:nth-of-type(1)', '"toast", 999') + .pause(100000) + .end() + }, + + tearDown: sauce +} + +var sources = [ + { + 'browser/blah.sol': { + content: ` + pragma solidity >=0.4.22 <0.6.0; + + contract Kickstarter { + + enum State { Started, Completed } + + struct Project { + address owner; + string name; + uint goal; + State state; + } + + Project[] public projects; + + constructor() public { + + } + + function createProject(string memory name, uint goal) public { + Project storage project = projects[projects.length]; + project.name = name; + project.owner = msg.sender; + project.state = State.Started; + project.goal = goal; + } + } + ` + } + } +] From 8e91078d76df0e0b015e56348153bcf59717797d Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Sat, 21 Mar 2020 16:12:29 +0000 Subject: [PATCH 2/4] Debug Transaction Command --- src/app/ui/multiParamManager.js | 11 +++++++--- src/app/ui/txLogger.js | 2 +- test-browser/commands/debugTransaction.js | 25 +++++++++++++++++++++++ test-browser/tests/debugger.js | 10 ++++----- 4 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 test-browser/commands/debugTransaction.js diff --git a/src/app/ui/multiParamManager.js b/src/app/ui/multiParamManager.js index 1f5211bc86..cc8b7007c5 100644 --- a/src/app/ui/multiParamManager.js +++ b/src/app/ui/multiParamManager.js @@ -116,14 +116,15 @@ class MultiParamManager { title = this.funABI.type === 'receive' ? '(receive)' : '(fallback)' } - this.basicInputField = yo`` + this.basicInputField = yo`` this.basicInputField.setAttribute('placeholder', this.inputs) this.basicInputField.setAttribute('title', this.inputs) + this.basicInputField.setAttribute('data-id', this.inputs) var onClick = () => { this.clickCallBack(this.funABI.inputs, this.basicInputField.value) } - let funcButton = yo`` + let funcButton = yo`` this.contractActionsContainerSingle = yo`
${funcButton} @@ -142,7 +143,7 @@ class MultiParamManager { } } - var expandedButton = yo`` + var expandedButton = yo`` this.contractActionsContainerMulti = yo`
@@ -185,6 +186,7 @@ class MultiParamManager { expandedButton.classList.add('btn-info') funcButton.setAttribute('title', (title + ' - call')) funcButton.classList.add('btn-info') + funcButton.setAttribute('data-id', (title + ' - call')) } else if (this.funABI.stateMutability === 'payable' || this.funABI.payable) { // transact. stateMutability = payable expandedButton.setAttribute('title', (title + ' - transact (payable)')) @@ -192,6 +194,7 @@ class MultiParamManager { expandedButton.classList.add('btn-danger') funcButton.setAttribute('title', (title + ' - transact (payable)')) funcButton.classList.add('btn-danger') + funcButton.setAttribute('data-id', (title + ' - transact (payable)')) } else { // transact. stateMutability = nonpayable expandedButton.setAttribute('title', (title + ' - transact (not payable)')) @@ -199,6 +202,7 @@ class MultiParamManager { expandedButton.classList.add('btn-warning') funcButton.classList.add('btn-warning') funcButton.setAttribute('title', (title + ' - transact (not payable)')) + funcButton.setAttribute('data-id', (title + ' - transact (not payable)')) } if (this.funABI.inputs && this.funABI.inputs.length > 0) { @@ -207,6 +211,7 @@ class MultiParamManager { contractProperty.classList.add(css.hasArgs) this.basicInputField.setAttribute('title', `'(${this.funABI.type}')`) // probably should pass name instead this.contractActionsContainerSingle.querySelector('i').style.visibility = 'hidden' + this.basicInputField.setAttribute('data-id', `'(${this.funABI.type}')`) } else { this.contractActionsContainerSingle.querySelector('i').style.visibility = 'hidden' this.basicInputField.style.visibility = 'hidden' diff --git a/src/app/ui/txLogger.js b/src/app/ui/txLogger.js index 4ab75bdc34..dee59fad1f 100644 --- a/src/app/ui/txLogger.js +++ b/src/app/ui/txLogger.js @@ -205,7 +205,7 @@ function log (self, tx, receipt) { } function renderKnownTransaction (self, data, blockchain) { - var from = data.tx.from + var from = data.tx.from var to = data.resolvedData.contractName + '.' + data.resolvedData.fn var obj = {from, to} var txType = 'knownTx' diff --git a/test-browser/commands/debugTransaction.js b/test-browser/commands/debugTransaction.js new file mode 100644 index 0000000000..7ef32af5a3 --- /dev/null +++ b/test-browser/commands/debugTransaction.js @@ -0,0 +1,25 @@ +const EventEmitter = require('events') + +class debugTransaction extends EventEmitter { + command (index = 0) { + this.api.perform((done) => { + checkStyle(this.api, index, () => { + done() + this.emit('complete') + }) + }) + return this + } +} + +function checkStyle (browser, index, callback) { + browser.pause(2000).execute(function (index) { + const debugBtn = document.querySelectorAll('*[data-shared="txLoggerDebugButton"]')[index] + + debugBtn.click() + }, [index], function () { + callback() + }) +} + +module.exports = debugTransaction diff --git a/test-browser/tests/debugger.js b/test-browser/tests/debugger.js index e09fb36aee..083ba7fbca 100644 --- a/test-browser/tests/debugger.js +++ b/test-browser/tests/debugger.js @@ -17,8 +17,7 @@ module.exports = { .clickLaunchIcon('udapp') .waitForElementPresent('*[title="Deploy - transact (not payable)"]') .click('*[title="Deploy - transact (not payable)"]') - .waitForElementPresent('*[data-shared="txLoggerDebugButton"]:nth-of-type(1)') - .click('*[data-shared="txLoggerDebugButton"]:nth-of-type(1)') + .debugTransaction(0) .assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEBUGGER') }, @@ -27,9 +26,10 @@ module.exports = { .clickLaunchIcon('udapp') .waitForElementPresent('*[data-id="universalDappUiTitleExpander"]') .click('*[data-id="universalDappUiTitleExpander"]') - .waitForElementPresent('*[data-shared="multiParamManagerBasicInputField"]:nth-of-type(1)') - .sendKeys('*[data-shared="multiParamManagerBasicInputField"]:nth-of-type(1)', '"toast", 999') - .pause(100000) + .scrollAndClick('*[title="string name, uint256 goal"]') + .setValue('*[title="string name, uint256 goal"]', '"toast", 999') + .click('*[data-id="createProject - transact (not payable)"]') + .debugTransaction(1) .end() }, From e0ffd3b4d1e812f7d0d5cd9c05bcd55f5aa206f5 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Sun, 22 Mar 2020 17:40:20 +0000 Subject: [PATCH 3/4] Debugger slider test --- src/app/tabs/debugger/debuggerUI/Slider.js | 2 +- .../debuggerUI/vmDebugger/SolidityLocals.js | 2 +- .../debugger/debuggerUI/vmDebugger/StepDetail.js | 2 +- test-browser/tests/debugger.js | 13 +++++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/app/tabs/debugger/debuggerUI/Slider.js b/src/app/tabs/debugger/debuggerUI/Slider.js index 865dd8bcd9..d67be06dc2 100644 --- a/src/app/tabs/debugger/debuggerUI/Slider.js +++ b/src/app/tabs/debugger/debuggerUI/Slider.js @@ -43,7 +43,7 @@ class Slider { render () { var self = this var view = yo`
-
` if (!this.view) { diff --git a/src/app/tabs/debugger/debuggerUI/vmDebugger/SolidityLocals.js b/src/app/tabs/debugger/debuggerUI/vmDebugger/SolidityLocals.js index 35edfd81f7..592b2ef060 100644 --- a/src/app/tabs/debugger/debuggerUI/vmDebugger/SolidityLocals.js +++ b/src/app/tabs/debugger/debuggerUI/vmDebugger/SolidityLocals.js @@ -29,7 +29,7 @@ class SolidityLocals { } render () { - this.view = yo`
${this.basicPanel.render()}
` + this.view = yo`
${this.basicPanel.render()}
` return this.view } } diff --git a/src/app/tabs/debugger/debuggerUI/vmDebugger/StepDetail.js b/src/app/tabs/debugger/debuggerUI/vmDebugger/StepDetail.js index fcfa13612c..0bcc30395b 100644 --- a/src/app/tabs/debugger/debuggerUI/vmDebugger/StepDetail.js +++ b/src/app/tabs/debugger/debuggerUI/vmDebugger/StepDetail.js @@ -17,7 +17,7 @@ StepDetail.prototype.updateField = function (key, value) { } StepDetail.prototype.render = function () { - return yo`
${this.basicPanel.render()}
` + return yo`
${this.basicPanel.render()}
` } module.exports = StepDetail diff --git a/test-browser/tests/debugger.js b/test-browser/tests/debugger.js index 083ba7fbca..1641738e11 100644 --- a/test-browser/tests/debugger.js +++ b/test-browser/tests/debugger.js @@ -30,6 +30,19 @@ module.exports = { .setValue('*[title="string name, uint256 goal"]', '"toast", 999') .click('*[data-id="createProject - transact (not payable)"]') .debugTransaction(1) + .pause(2000) + .scrollAndClick('*[data-id="solidityLocals"]') + .assert.containsText('*[data-id="solidityLocals"]', "toast") + .assert.containsText('*[data-id="solidityLocals"]', "999") + }, + + 'Should debug transaction using slider': function (browser) { + browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]') + .click('*[data-id="slider"]') + .setValue('*[data-id="slider"]', 50) + .pause(2000) + .assert.containsText('*[data-id="solidityLocals"]', "no locals") + .assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 92') .end() }, From 900e9f956e960c53739044e15b133f0c18485e33 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 23 Mar 2020 03:29:07 +0000 Subject: [PATCH 4/4] Fixed linting error --- src/app/editor/editor.js | 2 +- .../debugger/debuggerUI/ButtonNavigator.js | 8 ++-- src/app/ui/txLogger.js | 2 +- test-browser/tests/debugger.js | 37 +++++++++++++++++-- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/app/editor/editor.js b/src/app/editor/editor.js index 976d242d43..d418e48c16 100644 --- a/src/app/editor/editor.js +++ b/src/app/editor/editor.js @@ -91,7 +91,7 @@ class Editor extends Plugin { } // Editor Setup - const el = yo`
` + const el = yo`
` this.editor = ace.edit(el) ace.acequire('ace/ext/language_tools') diff --git a/src/app/tabs/debugger/debuggerUI/ButtonNavigator.js b/src/app/tabs/debugger/debuggerUI/ButtonNavigator.js index d65d815eef..8c03ae4aa7 100644 --- a/src/app/tabs/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/tabs/debugger/debuggerUI/ButtonNavigator.js @@ -47,15 +47,15 @@ ButtonNavigator.prototype.render = function () { var view = yo`
- - + +
- + - +