pull/7/head
yann300 8 years ago
parent 9d03238bd1
commit 7696ff1db1
  1. 18
      ci/browser_tests.sh
  2. 8
      index.html
  3. 5
      src/ui/CalldataPanel.js
  4. 5
      src/ui/CallstackPanel.js
  5. 18
      src/ui/CodeListView.js
  6. 14
      src/ui/DropdownPanel.js
  7. 2
      src/ui/Ethdebugger.js
  8. 6
      src/ui/FullStoragesChanges.js
  9. 5
      src/ui/MemoryPanel.js
  10. 11
      src/ui/StackPanel.js
  11. 21
      src/ui/StepDetail.js
  12. 5
      src/ui/StoragePanel.js
  13. 6
      src/ui/TxBrowser.js
  14. 10
      src/ui/VmDebugger.js
  15. 12
      src/ui/styles/basicStyles.js
  16. 12
      src/ui/styles/sliderStyles.js
  17. 133
      test-browser/init.js
  18. 70
      test-browser/vmdebugger.js
  19. 77
      test/resources/insertTestWeb3.js

@ -1,6 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SAUCECONNECT_URL="https://saucelabs.com/downloads/sc-4.3.16-linux.tar.gz" SAUCECONNECT_URL="https://saucelabs.com/downloads/sc-4.3.16-linux.tar.gz"
SAUCECONNECT_USERNAME="yanneth" SAUCECONNECT_USERNAME="yanneth"
SAUCECONNECT_ACCESSKEY="1f5a4560-b02b-41aa-b52b-f033aad30870" SAUCECONNECT_ACCESSKEY="1f5a4560-b02b-41aa-b52b-f033aad30870"
@ -18,10 +17,19 @@ while [ ! -f $SAUCECONNECT_READYFILE ]; do
sleep .5 sleep .5
done done
npm run nightwatch_remote_firefox || TEST_EXITCODE=1 npm run nightwatch_remote_safari
npm run nightwatch_remote_chrome || TEST_EXITCODE=1 echo $?
npm run nightwatch_remote_safari || TEST_EXITCODE=1 if [ $? -eq 1 ]
npm run nightwatch_remote_ie || TEST_EXITCODE=1 then
TEST_EXITCODE = 1
fi
npm run nightwatch_remote_ie
if [ $? -eq 1 ]
then
TEST_EXITCODE = 1
fi
node ci/sauceDisconnect.js $SAUCECONNECT_USERNAME $SAUCECONNECT_ACCESSKEY $SAUCECONNECT_JOBIDENTIFIER node ci/sauceDisconnect.js $SAUCECONNECT_USERNAME $SAUCECONNECT_ACCESSKEY $SAUCECONNECT_JOBIDENTIFIER

@ -6,10 +6,10 @@
<script type="text/javascript"> <script type="text/javascript">
function loadDebugger() { function loadDebugger() {
var container = document.getElementById('app') var container = document.getElementById('app')
container.vmdebugger = new window.remix.ui.Debugger() container.debugger = new window.remix.ui.Debugger()
container.vmdebugger.addProvider('INTERNAL') container.debugger.addProvider('INTERNAL')
container.vmdebugger.switchProvider('INTERNAL') container.debugger.switchProvider('INTERNAL')
container.appendChild(container.vmdebugger.render()) container.appendChild(container.debugger.render())
} }
</script> </script>
<div id="app"></div> <div id="app"></div>

@ -21,12 +21,11 @@ CalldataPanel.prototype.init = function () {
self.traceManager.getCallDataAt(index, function (error, calldata) { self.traceManager.getCallDataAt(index, function (error, calldata) {
if (error) { if (error) {
self.basicPanel.data = {} self.basicPanel.update({})
console.log(error) console.log(error)
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = calldata self.basicPanel.update(calldata)
} }
self.basicPanel.update()
}) })
}) })
} }

@ -22,11 +22,10 @@ CallstackPanel.prototype.init = function () {
self.traceManager.getCallStackAt(index, function (error, callstack) { self.traceManager.getCallStackAt(index, function (error, callstack) {
if (error) { if (error) {
console.log(error) console.log(error)
self.basicPanel.data = {} self.basicPanel.update({})
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = callstack self.basicPanel.update(callstack)
} }
self.basicPanel.update()
}) })
}) })
} }

@ -4,7 +4,7 @@ var yo = require('yo-yo')
var ui = require('../helpers/ui') var ui = require('../helpers/ui')
var DropdownPanel = require('./DropdownPanel') var DropdownPanel = require('./DropdownPanel')
function ListView (_parent, _codeManager) { function CodeListView (_parent, _codeManager) {
this.parent = _parent this.parent = _parent
this.codeManager = _codeManager this.codeManager = _codeManager
this.code this.code
@ -15,11 +15,11 @@ function ListView (_parent, _codeManager) {
this.init() this.init()
} }
ListView.prototype.render = function () { CodeListView.prototype.render = function () {
return yo`<div id='asmcodes' >${this.basicPanel.render({height: style.instructionsList.height})}</div>` return yo`<div id='asmcodes' >${this.basicPanel.render({height: style.instructionsList.height})}</div>`
} }
ListView.prototype.init = function () { CodeListView.prototype.init = function () {
var self = this var self = this
this.codeManager.register('changed', this, this.changed) this.codeManager.register('changed', this, this.changed)
this.parent.register('traceUnloaded', this, function () { this.parent.register('traceUnloaded', this, function () {
@ -27,20 +27,22 @@ ListView.prototype.init = function () {
}) })
} }
ListView.prototype.indexChanged = function (index) { CodeListView.prototype.indexChanged = function (index) {
if (index >= 0) { if (index >= 0) {
if (this.itemSelected) { if (this.itemSelected) {
this.itemSelected.removeAttribute('selected')
this.itemSelected.removeAttribute('style') this.itemSelected.removeAttribute('style')
this.itemSelected.firstChild.removeAttribute('style') this.itemSelected.firstChild.removeAttribute('style')
} }
this.itemSelected = this.codeView.children[index] this.itemSelected = this.codeView.children[index]
this.itemSelected.setAttribute('style', ui.formatCss({'background-color': '#eeeeee'})) this.itemSelected.setAttribute('style', ui.formatCss({'background-color': '#eeeeee'}))
this.itemSelected.setAttribute('selected', 'selected')
this.itemSelected.firstChild.setAttribute('style', ui.formatCss({'margin-left': '2px'})) this.itemSelected.firstChild.setAttribute('style', ui.formatCss({'margin-left': '2px'}))
this.codeView.scrollTop = this.itemSelected.offsetTop - parseInt(this.codeView.style.height.replace('px', '')) this.codeView.scrollTop = this.itemSelected.offsetTop - parseInt(this.codeView.offsetHeight)
} }
} }
ListView.prototype.changed = function (code, address, index) { CodeListView.prototype.changed = function (code, address, index) {
if (this.address !== address) { if (this.address !== address) {
this.code = code this.code = code
this.address = address this.address = address
@ -51,7 +53,7 @@ ListView.prototype.changed = function (code, address, index) {
this.indexChanged(index) this.indexChanged(index)
} }
ListView.prototype.renderAssemblyItems = function () { CodeListView.prototype.renderAssemblyItems = function () {
if (this.code) { if (this.code) {
var codeView = this.code.map(function (item, i) { var codeView = this.code.map(function (item, i) {
return yo`<li key=${i} value=${i}><span>${item}</span></li>` return yo`<li key=${i} value=${i}><span>${item}</span></li>`
@ -62,4 +64,4 @@ ListView.prototype.renderAssemblyItems = function () {
} }
} }
module.exports = ListView module.exports = CodeListView

@ -18,7 +18,13 @@ function DropdownPanel (_name, _raw) {
this.raw = _raw this.raw = _raw
} }
DropdownPanel.prototype.update = function () { DropdownPanel.prototype.update = function (_data) {
if (!this.view) {
return
}
if (_data) {
this.data = _data
}
this.view.querySelector('.dropdownpanel div').innerHTML = '' this.view.querySelector('.dropdownpanel div').innerHTML = ''
if (!this.raw) { if (!this.raw) {
var data = JSON.stringify(this.data, null, '\t') var data = JSON.stringify(this.data, null, '\t')
@ -28,11 +34,11 @@ DropdownPanel.prototype.update = function () {
var div = document.createElement('div') var div = document.createElement('div')
if (Array.isArray(this.data)) { if (Array.isArray(this.data)) {
this.data.map(function (item, i) { this.data.map(function (item, i) {
div.appendChild(yo`<div><span>${item}</span></div>`) div.appendChild(yo`<div>${item}</div>`)
}) })
} else { } else {
for (var k in this.data) { for (var k in this.data) {
div.appendChild(yo`<div><div style=${ui.formatCss(basicStyles.truncate, {display: 'inline-block', 'width': '100px'})} >${k}</div><div style=${ui.formatCss(basicStyles.truncate, {display: 'inline-block', 'width': '355px'})} >${this.data[k]}</div></div>`) div.appendChild(yo`<div><div style=${ui.formatCss(basicStyles.truncate, {display: 'inline-block', 'width': '10%'})} >${k}</div><div style=${ui.formatCss(basicStyles.truncate, {display: 'inline-block', 'width': '50%'})} >${this.data[k]}</div></div>`)
} }
} }
this.view.querySelector('.dropdownpanel div').appendChild(div) this.view.querySelector('.dropdownpanel div').appendChild(div)
@ -57,7 +63,7 @@ DropdownPanel.prototype.render = function (overridestyle) {
<button style=${ui.formatCss(style.button, styleDropdown.copyBtn)} class="btn" type="button"> <button style=${ui.formatCss(style.button, styleDropdown.copyBtn)} class="btn" type="button">
Copy to clipboard Copy to clipboard
</button> </button>
<div style=${ui.formatCss(styleDropdown.inner, overridestyle)}><span>Empty</span></div> <div style=${ui.formatCss(styleDropdown.inner, overridestyle)} class='dropdowncontent'><span>Empty</span></div>
</div> </div>
</div>` </div>`
if (!this.view) { if (!this.view) {

@ -81,7 +81,7 @@ Ethdebugger.prototype.debug = function (tx) {
Ethdebugger.prototype.render = function () { Ethdebugger.prototype.render = function () {
var view = yo`<div style=${ui.formatCss(style.font)}> var view = yo`<div style=${ui.formatCss(style.font)}>
<div style='margin: auto; width: 604px'> <div style='margin: auto; width: 31%'>
${this.txBrowser.render()} ${this.txBrowser.render()}
${this.stepManager.render()} ${this.stepManager.render()}
</div> </div>

@ -27,8 +27,7 @@ FullStoragesChanges.prototype.init = function () {
self.traceManager.getAddresses(function (error, addresses) { self.traceManager.getAddresses(function (error, addresses) {
if (!error) { if (!error) {
self.addresses = addresses self.addresses = addresses
self.basicPanel.data = {} self.basicPanel.update({})
self.basicPanel.update()
} }
}) })
@ -49,8 +48,7 @@ FullStoragesChanges.prototype.init = function () {
self.traceManager.getStorageAt(index, null, function (error, result) { self.traceManager.getStorageAt(index, null, function (error, result) {
if (!error) { if (!error) {
storageJSON[self.addresses[k]] = result storageJSON[self.addresses[k]] = result
self.basicPanel.data = storageJSON self.basicPanel.update(storageJSON)
self.basicPanel.update()
} }
}, self.addresses[k]) }, self.addresses[k])
} }

@ -23,11 +23,10 @@ MemoryPanel.prototype.init = function () {
self.traceManager.getMemoryAt(index, function (error, memory) { self.traceManager.getMemoryAt(index, function (error, memory) {
if (error) { if (error) {
console.log(error) console.log(error)
self.basicPanel.data = {} self.basicPanel.update({})
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = util.formatMemory(memory, 16) self.basicPanel.update(util.formatMemory(memory, 16))
} }
self.basicPanel.update()
}) })
}) })
} }

@ -22,22 +22,21 @@ StackPanel.prototype.init = function () {
self.traceManager.getStackAt(index, function (error, stack) { self.traceManager.getStackAt(index, function (error, stack) {
if (error) { if (error) {
self.basicPanel.data = {} self.basicPanel.update({})
console.log(error) console.log(error)
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = self.format(stack) self.basicPanel.update(self.format(stack))
} }
self.basicPanel.update()
}) })
}) })
} }
StackPanel.prototype.format = function (stack) { StackPanel.prototype.format = function (stack) {
var ret = [] var ret = []
for (var key in stack) { stack.map(function (item, i) {
var hex = ui.normalizeHex(stack[key]) var hex = ui.normalizeHex(item)
ret.push(hex) ret.push(hex)
} })
return ret return ret
} }

@ -14,19 +14,19 @@ function StepDetail (_parent, _traceManager) {
} }
StepDetail.prototype.render = function () { StepDetail.prototype.render = function () {
return yo`<div id='sticker' >${this.basicPanel.render()}</div>` return yo`<div id='stepdetail' >${this.basicPanel.render()}</div>`
} }
StepDetail.prototype.init = function () { StepDetail.prototype.init = function () {
var self = this var self = this
this.parent.register('traceUnloaded', this, function () { this.parent.register('traceUnloaded', this, function () {
self.detail = initDetail() self.detail = initDetail()
self.basicPanel.update() self.basicPanel.update(self.detail)
}) })
this.parent.register('newTraceLoaded', this, function () { this.parent.register('newTraceLoaded', this, function () {
self.detail = initDetail() self.detail = initDetail()
self.basicPanel.update() self.basicPanel.update(self.detail)
}) })
this.parent.register('indexChanged', this, function (index) { this.parent.register('indexChanged', this, function (index) {
@ -41,8 +41,7 @@ StepDetail.prototype.init = function () {
} else { } else {
self.detail.step = step self.detail.step = step
} }
self.basicPanel.data = self.detail self.basicPanel.update(self.detail)
self.basicPanel.update()
}) })
self.traceManager.getMemExpand(index, function (error, addmem) { self.traceManager.getMemExpand(index, function (error, addmem) {
@ -52,8 +51,7 @@ StepDetail.prototype.init = function () {
} else { } else {
self.detail.addmemory = addmem self.detail.addmemory = addmem
} }
self.basicPanel.data = self.detail self.basicPanel.update(self.detail)
self.basicPanel.update()
}) })
self.traceManager.getStepCost(index, function (error, gas) { self.traceManager.getStepCost(index, function (error, gas) {
@ -63,8 +61,7 @@ StepDetail.prototype.init = function () {
} else { } else {
self.detail.gas = gas self.detail.gas = gas
} }
self.basicPanel.data = self.detail self.basicPanel.update(self.detail)
self.basicPanel.update()
}) })
self.traceManager.getCurrentCalledAddressAt(index, function (error, address) { self.traceManager.getCurrentCalledAddressAt(index, function (error, address) {
@ -74,8 +71,7 @@ StepDetail.prototype.init = function () {
} else { } else {
self.detail.loadedAddress = address self.detail.loadedAddress = address
} }
self.basicPanel.data = self.detail self.basicPanel.update(self.detail)
self.basicPanel.update()
}) })
self.traceManager.getRemainingGas(index, function (error, remaingas) { self.traceManager.getRemainingGas(index, function (error, remaingas) {
@ -85,8 +81,7 @@ StepDetail.prototype.init = function () {
} else { } else {
self.detail.remainingGas = remaingas self.detail.remainingGas = remaingas
} }
self.basicPanel.data = self.detail self.basicPanel.update(self.detail)
self.basicPanel.update()
}) })
}) })
} }

@ -25,11 +25,10 @@ StoragePanel.prototype.init = function () {
self.traceManager.getStorageAt(index, self.parent.tx, function (error, storage) { self.traceManager.getStorageAt(index, self.parent.tx, function (error, storage) {
if (error) { if (error) {
console.log(error) console.log(error)
self.basicPanel.data = {} self.basicPanel.update({})
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = storage self.basicPanel.update(storage)
} }
self.basicPanel.update()
}, self.address) }, self.address)
}) })
} }

@ -136,13 +136,13 @@ TxBrowser.prototype.render = function () {
var self = this var self = this
var view = yo`<div> var view = yo`<div>
${this.connectionSetting()} ${this.connectionSetting()}
<input onkeyup=${function () { self.updateBlockN(arguments[0]) }} type='text' placeholder=${'Block number'} style='width: 231px' /> <input onkeyup=${function () { self.updateBlockN(arguments[0]) }} type='text' placeholder=${'Block number'} />
<input id='txinput' onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' placeholder=${'Transaction index or hash'} style='width: 266px' /> <input id='txinput' onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' placeholder=${'Transaction index or hash'} />
<button id='load' onclick=${function () { self.submit() }} style=${ui.formatCss(style.button)}> <button id='load' onclick=${function () { self.submit() }} style=${ui.formatCss(style.button)}>
Load Load
</button> </button>
<button id='unload' onclick=${function () { self.unload() }} style=${ui.formatCss(style.button)}>Reset</button> <button id='unload' onclick=${function () { self.unload() }} style=${ui.formatCss(style.button)}>Reset</button>
<div style=${ui.formatCss(style.transactionInfo)}> <div style=${ui.formatCss(style.transactionInfo)} id='txinfo'>
${this.basicPanel.render()} ${this.basicPanel.render()}
</div> </div>
</div>` </div>`

@ -1,5 +1,5 @@
'use strict' 'use strict'
var ListView = require('./ListView') var CodeListView = require('./CodeListView')
var CalldataPanel = require('./CalldataPanel') var CalldataPanel = require('./CalldataPanel')
var MemoryPanel = require('./MemoryPanel') var MemoryPanel = require('./MemoryPanel')
var CallstackPanel = require('./CallstackPanel') var CallstackPanel = require('./CallstackPanel')
@ -11,7 +11,7 @@ var DropdownPanel = require('./DropdownPanel')
var yo = require('yo-yo') var yo = require('yo-yo')
function VmDebugger (_parent, _traceManager, _codeManager) { function VmDebugger (_parent, _traceManager, _codeManager) {
this.asmCode = new ListView(_parent, _codeManager) this.asmCode = new CodeListView(_parent, _codeManager)
this.stackPanel = new StackPanel(_parent, _traceManager) this.stackPanel = new StackPanel(_parent, _traceManager)
this.storagePanel = new StoragePanel(_parent, _traceManager) this.storagePanel = new StoragePanel(_parent, _traceManager)
this.memoryPanel = new MemoryPanel(_parent, _traceManager) this.memoryPanel = new MemoryPanel(_parent, _traceManager)
@ -49,8 +49,7 @@ function VmDebugger (_parent, _traceManager, _codeManager) {
VmDebugger.prototype.render = function () { VmDebugger.prototype.render = function () {
var view = yo`<div id='vmdebugger' style='display:none'> var view = yo`<div id='vmdebugger' style='display:none'>
<div> <div>
<div>
${this.asmCode.render()} ${this.asmCode.render()}
${this.stepDetail.render()} ${this.stepDetail.render()}
${this.stackPanel.render()} ${this.stackPanel.render()}
@ -60,8 +59,7 @@ VmDebugger.prototype.render = function () {
${this.callstackPanel.render()} ${this.callstackPanel.render()}
${this.returnValuesPanel.render()} ${this.returnValuesPanel.render()}
${this.fullStoragesChangesPanel.render()} ${this.fullStoragesChangesPanel.render()}
</div> </div>
</div>
</div>` </div>`
if (!this.view) { if (!this.view) {
this.view = view this.view = view

@ -21,10 +21,10 @@ module.exports = {
}, },
instructionsList: { instructionsList: {
'width': '72%', 'width': '72%',
'height': '330px',
'overflow-y': 'scroll', 'overflow-y': 'scroll',
'list-style-type': 'none', 'list-style-type': 'none',
'margin': 'auto' 'margin': 'auto',
'max-height': '500px'
}, },
transactionInfo: { transactionInfo: {
'margin-top': '5px' 'margin-top': '5px'
@ -32,10 +32,10 @@ module.exports = {
panel: { panel: {
container: { container: {
'border': '1px solid', 'border': '1px solid',
'width': '600px' 'width': '70%'
}, },
tableContainer: { tableContainer: {
'height': '300px', 'height': '50%',
'overflow-y': 'auto' 'overflow-y': 'auto'
}, },
table: { table: {
@ -52,10 +52,6 @@ module.exports = {
display: { display: {
'display': 'block' 'display': 'block'
}, },
sticker: {
'vertical-align': 'top',
'margin': '5px'
},
inline: { inline: {
'display': 'inline-block' 'display': 'inline-block'
}, },

@ -1,16 +1,6 @@
'use strict' 'use strict'
module.exports = { module.exports = {
rule: { rule: {
'width': '600px' 'width': '98%'
},
runner: {
'position': 'absolute',
'width': '16px',
'height': '16px',
'margin': '0',
'padding': '0',
'overflow': 'hidden',
'border': '1px solid #a4bed4',
'background-color': '#f1f7ff'
} }
} }

@ -1,87 +1,38 @@
var init = require('../test/init')
module.exports = function (browser, callback) { module.exports = function (browser, callback) {
extendBrowser(browser) extendBrowser(browser)
browser browser
.url('http://127.0.0.1:8080') .url('http://127.0.0.1:8080')
.waitForElementPresent('#app div', 1000) .injectScript('test/resources/insertTestWeb3.js', function () {
injectScript('./test/resources/testWeb3.json', browser, function () { // wait for the script to load test web3...
callback() setTimeout(function () {
})
}
function injectScript (file, browser, callback) {
init.readFile(file, function (error, result) {
if (!error) {
browser.execute(function (data) {
var vmdebugger = document.getElementById('app').vmdebugger
data = JSON.parse(data)
var uiTestweb3 = {}
uiTestweb3.eth = {}
uiTestweb3.debug = {}
uiTestweb3.eth.getCode = function (address, callback) {
if (callback) {
callback(null, data.testCodes[address])
} else {
return data.testCodes[address]
}
}
uiTestweb3.debug.traceTransaction = function (txHash, options, callback) {
callback(null, data.testTraces[txHash])
}
uiTestweb3.debug.storageAt = function (blockNumber, txIndex, address, callback) {
callback(null, {})
}
uiTestweb3.eth.getTransaction = function (txHash, callback) {
if (callback) {
callback(null, data.testTxs[txHash])
} else {
return data.testTxs[txHash]
}
}
uiTestweb3.eth.getTransactionFromBlock = function (blockNumber, txIndex, callback) {
if (callback) {
callback(null, data.testTxsByBlock[blockNumber + '-' + txIndex])
} else {
return data.testTxsByBlock[blockNumber + '-' + txIndex]
}
}
uiTestweb3.eth.getBlockNumber = function (callback) { callback(null, 'web3 modified for testing purposes :)') }
uiTestweb3.eth.providers = { 'HttpProvider': function (url) {} }
uiTestweb3.eth.setProvider = function (provider) {}
uiTestweb3.currentProvider = {host: 'web3 modified for testing purposes :)'}
vmdebugger.addProvider('TEST', uiTestweb3)
vmdebugger.switchProvider('TEST')
}, [result], function () {
callback() callback()
}) }, 5000)
} })
})
} }
function extendBrowser (browser) { function extendBrowser (browser) {
browser.assertCurrentSelectedItem = function (expected) { browser.assertCurrentSelectedItem = function (expected) {
browser.getValue('#asmitems', function (result) { browser.execute(function (id) {
browser.expect.element('#asmitems option[value="' + result.value + '"]').text.to.equal(expected) var node = document.querySelector('#asmcodes ul li[selected="selected"] span')
return node.innerText
}, [''], function (returnValue) {
browser.assert.equal(returnValue.value, expected)
})
return browser
}
browser.retrieveInnerText = function (selector, callback) {
browser.execute(function (selector) {
var node = document.querySelector(selector)
return node ? node.innerText : ''
}, [selector], function (returnValue) {
callback(returnValue.value)
}) })
return browser return browser
} }
browser.assertSticker = function (vmtracestepinfo, stepinfo, addmemoryinfo, gasinfo, remaininggasinfo, loadedaddressinfo) { browser.assertStepDetail = function (vmtracestepinfo, stepinfo, addmemoryinfo, gasinfo, remaininggasinfo, loadedaddressinfo) {
browser.expect.element('#vmtracestepinfo').text.to.equal(vmtracestepinfo) assertPanel('#stepdetail', browser, ['vmTraceStep' + vmtracestepinfo, 'step' + stepinfo, 'addmemory' + addmemoryinfo, 'gas' + gasinfo, 'remainingGas' + remaininggasinfo, 'loadedAddress' + loadedaddressinfo])
browser.expect.element('#stepinfo').text.to.equal(stepinfo)
browser.expect.element('#addmemoryinfo').text.to.equal(addmemoryinfo)
browser.expect.element('#gasinfo').text.to.equal(gasinfo)
browser.expect.element('#remaininggasinfo').text.to.equal(remaininggasinfo)
browser.expect.element('#loadedaddressinfo').text.to.equal(loadedaddressinfo)
return browser return browser
} }
@ -177,29 +128,31 @@ browser.fireEvent = function (el, key, times, callback) {
} }
function assertPanel (id, browser, value) { function assertPanel (id, browser, value) {
browser.expect.element(id + ' #basicpanel').text.to.equal(value) var selector = id + ' .dropdownpanel div div'
return browser browser.execute(function (id) {
} var node = document.querySelector(id)
var ret = []
function assertPanelValue (id, browser, index, value) { for (var k in node.children) {
getInnerText(id + ' #basicpanel', browser, function (result) { if (node.children[k].innerText) {
var values ret.push(node.children[k].innerText)
if (result.value.indexOf('\r\n') !== -1) { }
values = result.value.split('\r\n')
} else if (result.value.indexOf('\n') !== -1) {
values = result.value.split('\n')
} else if (result.value.indexOf('\r') !== -1) {
values = result.value.split('\r')
} }
browser.assert.equal(values[index], value) return ret
}, [selector], function (returnValues) {
value.map(function (item, index) {
browser.assert.equal(returnValues.value[index], value[index])
})
}) })
return browser return browser
} }
function getInnerText (id, browser, callback) { function assertPanelValue (id, browser, index, value) {
browser.execute(function (data) { var selector = id + ' .dropdownpanel div div'
return document.querySelector(data).innerText browser.execute(function (id, index) {
}, [id], function (result) { var node = document.querySelector(id)
callback(result) return node.children[index].innerText
}, [selector, index], function (returnValues) {
browser.assert.equal(returnValues.value, value)
}) })
return browser
} }

@ -5,7 +5,9 @@ var sauce = require('./sauce')
module.exports = { module.exports = {
beforeEach: function (browser, done) { beforeEach: function (browser, done) {
try { try {
init(browser, done) init(browser, function () {
done()
})
} catch (e) { } catch (e) {
var mes = 'error ' + e.message var mes = 'error ' + e.message
console.log(mes) console.log(mes)
@ -14,42 +16,38 @@ module.exports = {
}, },
'vmdebugger': function (browser) { 'vmdebugger': function (browser) {
loadTrace(browser)
browser.click('#unload')
loadTraceNotFound(browser) loadTraceNotFound(browser)
browser.click('#unload') .click('#unload')
loadTrace(browser)
.click('#unload')
panels(browser) panels(browser)
browser.click('#unload') .click('#unload')
slider(browser) slider(browser)
browser.click('#unload') .click('#unload')
stepping(browser) stepping(browser)
browser.click('#unload') .click('#unload')
sticker(browser) stepdetail(browser)
browser.end() .end()
}, },
tearDown: sauce tearDown: sauce
} }
function loadTrace (browser) { function loadTraceNotFound (browser) {
browser browser
.clearValue('#txinput') .clearValue('#txinput')
.setValue('#txinput', '0x20ef65b8b186ca942zcccd634f37074dde49b541c27994fc7596740ef44cfd51') .setValue('#txinput', '0x20ef65b8b186ca942zcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.click('#load') .click('#load')
.assert.containsText('#txhash', '<not found>') .assert.attributeContains('#txinfo .dropdownpanel button', 'data-clipboard-text', '<not found>')
return browser return browser
} }
function loadTraceNotFound (browser) { function loadTrace (browser) {
browser browser
.clearValue('#txinput') .clearValue('#txinput')
.setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') .setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.click('#load') .click('#load')
.waitForElementVisible('#vmdebugger', 1000) .assert.attributeContains('#txinfo .dropdownpanel button', 'data-clipboard-text', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.expect.element('#txhash').text.to.equal('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
browser.expect.element('#txfrom').text.to.equal('0x00101c5bfa3fc8bad02c9f5fd65b069306251915')
browser.expect.element('#txto').text.to.equal('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
browser.expect.element('#txto').text.to.equal('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
browser.click('#unload') browser.click('#unload')
.waitForElementNotVisible('#vmdebugger', 1000) .waitForElementNotVisible('#vmdebugger', 1000)
return browser return browser
@ -60,22 +58,21 @@ function panels (browser) {
.clearValue('#txinput') .clearValue('#txinput')
.setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') .setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.click('#load') .click('#load')
.waitForElementVisible('#vmdebugger', 1000)
.click('#nextcall') .click('#nextcall')
.assertStack('0x\n0x60\n0x65\n0x38\n0x55\n0x60fe47b1') .assertStack(['0x', '0x60', '0x65', '0x38', '0x55', '0x60fe47b1'])
.assertStorageChanges('0x00 0x38') .assertStorageChanges(['0x000x38'])
.assertCallData('0x60fe47b10000000000000000000000000000000000000000000000000000000000000038') .assertCallData(['0x60fe47b10000000000000000000000000000000000000000000000000000000000000038'])
.assertCallStack('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5') .assertCallStack(['0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'])
.assertStackValue(1, '0x60') .assertStackValue(1, '0x60')
.assertMemoryValue(6, '0x60\t\t60606040526040516020806045833981\t????R??Q????E?9?') .assertMemoryValue(6, '0x6060606040526040516020806045833981\t????R??Q????E?9?')
.assertMemoryValue(7, '0x70\t\t01604052808051906020019091905050\t???R??Q???????PP') .assertMemoryValue(7, '0x7001604052808051906020019091905050\t???R??Q???????PP')
.assertMemoryValue(8, '0x80\t\t5b806001016000600050819055505b50\t?????????P??UP?P') .assertMemoryValue(8, '0x805b806001016000600050819055505b50\t?????????P??UP?P')
.click('#intoforward') // CREATE .click('#intoforward') // CREATE
.assertStack('') .assertStack(['Empty'])
.assertStorageChanges('') .assertStorageChanges(['Empty'])
.assertMemory('') .assertMemory(['Empty'])
.assertCallData('0x0000000000000000000000000000000000000000000000000000000000000000000000000000006060606040526040516020806045833981016040528080519060200190919050505b806001016000600050819055') .assertCallData(['0x0000000000000000000000000000000000000000000000000000000000000000000000000000006060606040526040516020806045833981016040528080519060200190919050505b806001016000600050819055'])
.assertCallStack('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5\n(Contract Creation - Step 63)') .assertCallStack(['0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', '(Contract Creation - Step 63)'])
return browser return browser
} }
@ -84,7 +81,6 @@ function slider (browser) {
.clearValue('#txinput') .clearValue('#txinput')
.setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') .setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.click('#load') .click('#load')
.waitForElementVisible('#vmdebugger', 1000)
.click('#intoforward') .click('#intoforward')
.click('#intoforward') .click('#intoforward')
.click('#intoforward') .click('#intoforward')
@ -114,7 +110,6 @@ function stepping (browser) {
.clearValue('#txinput') .clearValue('#txinput')
.setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') .setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.click('#load') .click('#load')
.waitForElementVisible('#vmdebugger', 1000)
.click('#intoforward') .click('#intoforward')
.click('#intoforward') .click('#intoforward')
.assertCurrentSelectedItem('004 MSTORE') .assertCurrentSelectedItem('004 MSTORE')
@ -136,12 +131,11 @@ function stepping (browser) {
return browser return browser
} }
function sticker (browser) { function stepdetail (browser) {
browser browser
.clearValue('#txinput') .clearValue('#txinput')
.setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') .setValue('#txinput', '0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
.click('#load') .click('#load')
.waitForElementVisible('#vmdebugger', 1000)
.click('#intoforward') .click('#intoforward')
.click('#intoforward') .click('#intoforward')
.click('#intoforward') .click('#intoforward')
@ -161,13 +155,13 @@ function sticker (browser) {
.end() .end()
}) })
*/ */
.assertSticker('6', '6', '', '3', '84476', '0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5') .assertStepDetail('6', '6', '', '3', '84476', '0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
.click('#nextcall') .click('#nextcall')
.assertSticker('63', '63', '', '32000', '79283', '0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5') .assertStepDetail('63', '63', '', '32000', '79283', '0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
.click('#intoforward') .click('#intoforward')
.click('#overforward') .click('#overforward')
.assertSticker('108', '44', '', '0', '27145', '(Contract Creation - Step 63)') .assertStepDetail('108', '44', '', '0', '27145', '(Contract Creation - Step 63)')
.click('#intoforward') .click('#intoforward')
.assertSticker('109', '64', '', '3', '25145', '0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5') .assertStepDetail('109', '64', '', '3', '25145', '0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
return browser return browser
} }

@ -0,0 +1,77 @@
function loadJSON (url, callback) {
var xobj = new XMLHttpRequest()
xobj.overrideMimeType('application/json')
xobj.open('GET', url, true)
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == '200') {
callback(xobj.responseText)
}
}
xobj.send(null)
}
function loadTestWeb3 (data) {
var container = document.getElementById('app')
var vmdebugger = container.debugger
var uiTestweb3 = {}
uiTestweb3.eth = {}
uiTestweb3.debug = {}
uiTestweb3.eth.getCode = function (address, callback) {
if (callback) {
callback(null, data.testCodes[address])
} else {
return data.testCodes[address]
}
}
uiTestweb3.debug.traceTransaction = function (txHash, options, callback) {
callback(null, data.testTraces[txHash])
}
uiTestweb3.debug.storageAt = function (blockNumber, txIndex, address, callback) {
callback(null, {})
}
uiTestweb3.eth.getTransaction = function (txHash, callback) {
if (callback) {
callback(null, data.testTxs[txHash])
} else {
return data.testTxs[txHash]
}
}
uiTestweb3.eth.getTransactionFromBlock = function (blockNumber, txIndex, callback) {
if (callback) {
callback(null, data.testTxsByBlock[blockNumber + '-' + txIndex])
} else {
return data.testTxsByBlock[blockNumber + '-' + txIndex]
}
}
uiTestweb3.eth.getBlockNumber = function (callback) { callback(null, 'web3 modified for testing purposes :)') }
uiTestweb3.providers = { 'HttpProvider': function (url) {} }
uiTestweb3.setProvider = function (provider) {}
uiTestweb3.currentProvider = {host: 'web3 modified for testing purposes :)'}
vmdebugger.addProvider('TEST', uiTestweb3)
vmdebugger.switchProvider('TEST')
}
function waitForRemix (data) {
setTimeout(function () {
if (!document.getElementById('app').debugger) {
waitForRemix(data)
} else {
loadTestWeb3(data)
}
}, 500)
}
loadJSON('/test/resources/testWeb3.json', function (result) {
var data = JSON.parse(result)
waitForRemix(data)
})
Loading…
Cancel
Save