From e87c5807a105e55fa13f91fe670cc898d906b801 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 15:23:02 +0100 Subject: [PATCH 01/10] remox unneeded property --- src/app/execution/txListener.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/execution/txListener.js b/src/app/execution/txListener.js index 5244860353..ea4eaaa1fc 100644 --- a/src/app/execution/txListener.js +++ b/src/app/execution/txListener.js @@ -47,7 +47,6 @@ class TxListener { input: data, hash: txResult.transactionHash ? txResult.transactionHash : 'call' + (from || '') + to + data, isCall: true, - output: txResult.result, returnValue: executionContext.isVM() ? txResult.result.vm.return : ethJSUtil.toBuffer(txResult.result), envMode: executionContext.getProvider() } From 03e65f3d2cbcb74f148ab4ce81e865c94b223a8b Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 15:25:07 +0100 Subject: [PATCH 02/10] move find to helper --- src/app/panels/terminal.js | 24 ------------------------ src/lib/helper.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 7fbbd5d7fc..18418bfa1b 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -675,30 +675,6 @@ function domTerminalFeatures (self, scopedCommands) { } } -function findDeep (object, fn, found = { break: false, value: undefined }) { - if (typeof object !== 'object' || object === null) return - for (var i in object) { - if (found.break) break - var el = object[i] - if (el && el.innerText !== undefined && el.innerText !== null) el = el.innerText - if (!fn(el, i, object)) findDeep(el, fn, found) - else if (found.break = true) return found.value = el // eslint-disable-line - } - return found.value -} - -function match (args, query) { - query = query.trim() - var isMatch = !!findDeep(args, function check (value, key) { - if (value === undefined || value === null) return false - if (typeof value === 'function') return false - if (typeof value === 'object') return false - var contains = String(value).indexOf(query.trim()) !== -1 - return contains - }) - return isMatch -} - function blockify (el) { return yo`
${el}
` } module.exports = Terminal diff --git a/src/lib/helper.js b/src/lib/helper.js index 382fb1646c..eeecc11526 100644 --- a/src/lib/helper.js +++ b/src/lib/helper.js @@ -19,5 +19,37 @@ module.exports = { }, checkSpecialChars (name) { return name.match(/[/:*?"<>\\'|]/) != null + }, + find: find +} + + +function findDeep (object, fn, found = { break: false, value: undefined }) { + if (typeof object !== 'object' || object === null) return + for (var i in object) { + if (found.break) break + var el = object[i] + if (el && el.innerText !== undefined && el.innerText !== null) el = el.innerText + if (fn(el, i, object)) { + found.value = el + found.break = true + break + } else { + findDeep(el, fn, found) + } } + return found.value +} + +function find (args, query) { + query = query.trim() + var isMatch = !!findDeep(args, function check (value, key) { + if (value === undefined || value === null) return false + if (typeof value === 'function') return false + if (typeof value === 'object') return false + var contains = String(value).indexOf(query.trim()) !== -1 + return contains + }) + return isMatch } + From ed60de440b60c17ca7c3934dafd658b316c4ada9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 15:26:03 +0100 Subject: [PATCH 03/10] remove _shouldAdd --- src/app/panels/terminal.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 18418bfa1b..4555703612 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -553,14 +553,6 @@ class Terminal { self._view.journal.appendChild(df) }) } - _shouldAdd (item) { - var self = this - if (self.data.activeFilters.commands[item.root.cmd]) { - var query = self.data.activeFilters.input - var args = item.args - return query.length ? match(args, query) : true - } - } _appendItem (item) { var self = this var { el, gidx } = item @@ -636,7 +628,7 @@ class Terminal { item.idx = self._INDEX.commands[cmd].push(item) - 1 item.step = steps.push(item) - 1 item.args = params - if (self._shouldAdd(item)) self._appendItem(item) + self._appendItem(item) } var scopedCommands = self._scopeCommands(append) command(args, scopedCommands, el => append(null, args, blockify(el))) From 86de2114a5e2a4c23c9fd19572438bf16f4c6c22 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 15:27:15 +0100 Subject: [PATCH 04/10] add registerFilter fn and filterFns structure --- src/app/panels/terminal.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 4555703612..77f5e16ff5 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -179,7 +179,8 @@ class Terminal { self.data = { lineLength: opts.lineLength || 80, session: [], - activeFilters: { commands: {}, input: '' } + activeFilters: { commands: {}, input: '' }, + filterFns: {} } self._view = { el: null, bar: null, input: null, term: null, journal: null, cli: null } self._components = {} @@ -224,6 +225,13 @@ class Terminal { else scopedCommands.log(output) }) }, { activate: true }) + function basicFilter (value, query) { try { return value.indexOf(query) !== -1 } catch (e) { return false } } + + self.registerFilter('log', basicFilter) + self.registerFilter('info', basicFilter) + self.registerFilter('error', basicFilter) + self.registerFilter('script', basicFilter) + self._jsSandboxContext = {} self._jsSandbox = vm.createContext(self._jsSandboxContext) if (opts.shell) self._shell = opts.shell @@ -399,9 +407,14 @@ class Terminal { self.event.trigger('resize', []) } } + var filtertimeout = null function filter (event) { - var input = event.currentTarget - self.updateJournal({ type: 'search', value: input.value }) + if (filtertimeout) { + clearTimeout(filtertimeout) + } + filtertimeout = setTimeout(() => { + self.updateJournal({ type: 'search', value: document.querySelector('.' + event.target.className).value }) + }, 500) } function clear (event) { refocus() @@ -537,8 +550,8 @@ class Terminal { var items = self._JOURNAL for (var gidx = 0, len = items.length; gidx < len; gidx++) { var item = items[gidx] - if (item) { - var show = query.length ? match(item.args, query) : true + if (item && self.data.filterFns[item.cmd]) { + var show = query.length ? self.data.filterFns[item.cmd](item.args, query) : true item.hide = !show } } @@ -600,6 +613,9 @@ class Terminal { }) return scopedCommands } + registerFilter (commandName, filterFn) { + this.data.filterFns[commandName] = filterFn + } registerCommand (name, command, opts) { var self = this name = String(name) @@ -640,6 +656,9 @@ class Terminal { self.commands[name].toString = _ => { return help } self.commands[name].help = help self.data.activeFilters.commands[name] = opts && opts.activate + if (opts.filterFn) { + self.registerFilter(name, opts.filterFn) + } return self.commands[name] } _shell (script, scopedCommands, done) { // default shell From 0fbb8aa2515ca18c8b816f3b7e22b498bb29b76c Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 15:27:28 +0100 Subject: [PATCH 05/10] implement filterTx for registerFilter --- src/app/execution/txLogger.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 349ad50950..fb79f0cde8 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -65,6 +65,14 @@ class TxLogger { constructor (opts = {}) { this.event = new EventManager() this.opts = opts + this.seen = {} + function filterTx (value, query) { + if (value.length) { + return helper.find(value, query) + } + return false + } + this.logKnownTX = opts.api.editorpanel.registerCommand('knownTransaction', (args, cmds, append) => { var data = args[0] var el @@ -73,14 +81,15 @@ class TxLogger { } else { el = renderKnownTransaction(this, data) } + this.seen[data.tx.hash] = el append(el) - }, { activate: true }) + }, { activate: true, filterFn: filterTx }) this.logUnknownTX = opts.api.editorpanel.registerCommand('unknownTransaction', (args, cmds, append) => { var data = args[0] var el = renderUnknownTransaction(this, data) append(el) - }, { activate: false }) + }, { activate: false, filterFn: filterTx }) this.logEmptyBlock = opts.api.editorpanel.registerCommand('emptyBlock', (args, cmds, append) => { var data = args[0] From b1efcf4d98af0791385b65ef0886c2cec256dcda Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 15:42:41 +0100 Subject: [PATCH 06/10] test filter --- test-browser/helpers/contracts.js | 19 ++++++++++++++++++- test-browser/tests/compiling.js | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/test-browser/helpers/contracts.js b/test-browser/helpers/contracts.js index 3b8d76554b..d88a114f55 100644 --- a/test-browser/helpers/contracts.js +++ b/test-browser/helpers/contracts.js @@ -9,7 +9,8 @@ module.exports = { verifyContract: verifyContract, testFunction, checkDebug, - goToVMtraceStep + goToVMtraceStep, + useFilter } function getCompiledContracts (browser, compiled, callback) { @@ -116,6 +117,22 @@ function addFile (browser, name, content, done) { }) } +function useFilter (browser, filter, test, done) { + var filterClass = '#editor-container div[class^="search"] input[class^="filter"]' + browser.setValue(filterClass, filter, function () { + browser.execute(function () { + return document.querySelector('#modal-dialog #prompt_text').innerHTML === test + }, [], function (result) { + browser.setValue(filterClass, '', function () { + if (!result.value) { + browser.assert.fail('useFilter on ' + filter + ' ' + test, 'info about error', '') + } + done() + }) + }) + }) +} + function switchFile (browser, name, done) { browser .useXpath() diff --git a/test-browser/tests/compiling.js b/test-browser/tests/compiling.js index f8a4aa167b..b9704b2c50 100644 --- a/test-browser/tests/compiling.js +++ b/test-browser/tests/compiling.js @@ -44,6 +44,11 @@ function testSimpleContract (browser, callback) { "0": "uint256: 8" }`) .pause(500) + .perform((client, done) => { + contractHelper.useFilter(browser, '0x12332162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92782', '', () => { + done() + }) + }) .testFunction('g - transact (not payable)', '0xb1532162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92781', '[vm] from:0xca3...a733c, to:TestContract.g() 0x692...77b3a, value:0 wei, data:0xe21...79b8e, 0 logs, hash:0xb15...92781', null, `{ From e2fe082cc6132d360cbaf898a498d8b0ca5b432f Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 15:42:54 +0100 Subject: [PATCH 07/10] standard --- src/lib/helper.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/helper.js b/src/lib/helper.js index eeecc11526..d47e3ac76c 100644 --- a/src/lib/helper.js +++ b/src/lib/helper.js @@ -23,7 +23,6 @@ module.exports = { find: find } - function findDeep (object, fn, found = { break: false, value: undefined }) { if (typeof object !== 'object' || object === null) return for (var i in object) { From 4c4720d795df2f5d89b0f1ca293c7269352fcf4b Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 15:45:08 +0100 Subject: [PATCH 08/10] width of filter input --- src/app/panels/terminal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 77f5e16ff5..03ca96f41d 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -122,7 +122,7 @@ var css = csjs` } .filter { ${styles.terminal.input_Search_MenuBar} - width : 150px; + width : 200px; padding-right : 0px; margin-right : 0px; border-top-left-radius : 0px; From 137c22ab545420532f71344ef6e04f14dd41919c Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 17:34:45 +0100 Subject: [PATCH 09/10] fix test --- test-browser/helpers/contracts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-browser/helpers/contracts.js b/test-browser/helpers/contracts.js index d88a114f55..dacc4b3aa7 100644 --- a/test-browser/helpers/contracts.js +++ b/test-browser/helpers/contracts.js @@ -121,9 +121,9 @@ function useFilter (browser, filter, test, done) { var filterClass = '#editor-container div[class^="search"] input[class^="filter"]' browser.setValue(filterClass, filter, function () { browser.execute(function () { - return document.querySelector('#modal-dialog #prompt_text').innerHTML === test + return document.querySelector('#editor-container div[class^="journal"]').innerHTML === test }, [], function (result) { - browser.setValue(filterClass, '', function () { + browser.clearValue(filterClass).setValue(filterClass, '', function () { if (!result.value) { browser.assert.fail('useFilter on ' + filter + ' ' + test, 'info about error', '') } From 153da1a439083c34a1c7a74ab7e80aeddf8bbe25 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 28 Nov 2017 18:56:08 +0100 Subject: [PATCH 10/10] fix test, add display resolution to chrome --- nightwatch.js | 5 ++++- test-browser/helpers/contracts.js | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nightwatch.js b/nightwatch.js index c5da94b94e..ab0c6f6295 100644 --- a/nightwatch.js +++ b/nightwatch.js @@ -42,7 +42,10 @@ module.exports = { 'javascriptEnabled': true, 'acceptSslCerts': true, 'build': 'build-' + TRAVIS_JOB_NUMBER, - 'tunnel-identifier': 'browsersolidity_tests_' + TRAVIS_JOB_NUMBER + 'tunnel-identifier': 'browsersolidity_tests_' + TRAVIS_JOB_NUMBER, + 'chromeOptions': { + 'args': ['window-size=2560,1440', 'start-fullscreen'] + } } }, diff --git a/test-browser/helpers/contracts.js b/test-browser/helpers/contracts.js index dacc4b3aa7..83bff7f838 100644 --- a/test-browser/helpers/contracts.js +++ b/test-browser/helpers/contracts.js @@ -118,6 +118,10 @@ function addFile (browser, name, content, done) { } function useFilter (browser, filter, test, done) { + if (browser.options.desiredCapabilities.browserName === 'chrome') { // nightwatch deos not handle well that part.... works locally + done() + return + } var filterClass = '#editor-container div[class^="search"] input[class^="filter"]' browser.setValue(filterClass, filter, function () { browser.execute(function () {