Merge pull request #2101 from ethereum/refactorBrowserTest

Refactor browser test
pull/1/head
yann300 5 years ago committed by GitHub
commit 67fc7e5623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      test-browser/commands/addAtAddressInstance.js
  2. 35
      test-browser/commands/addFile.js
  3. 35
      test-browser/commands/checkTerminalFilter.js
  4. 38
      test-browser/commands/checkVariableDebug.js
  5. 22
      test-browser/commands/createContract.js
  6. 25
      test-browser/commands/getAddressAtPosition.js
  7. 38
      test-browser/commands/goToVMTraceStep.js
  8. 46
      test-browser/commands/removeFile.js
  9. 53
      test-browser/commands/renameFile.js
  10. 22
      test-browser/commands/selectContract.js
  11. 42
      test-browser/commands/signMessage.js
  12. 24
      test-browser/commands/switchFile.js
  13. 36
      test-browser/commands/testConstantFunction.js
  14. 27
      test-browser/commands/testContracts.js
  15. 3
      test-browser/commands/testEditorValue.js
  16. 33
      test-browser/commands/verifyCallReturnValue.js
  17. 52
      test-browser/commands/verifyContracts.js
  18. 339
      test-browser/helpers/contracts.js
  19. 24
      test-browser/helpers/dom.js
  20. 96
      test-browser/tests/ballot.js
  21. 73
      test-browser/tests/compiling.js
  22. 203
      test-browser/tests/generalTests.js
  23. 86
      test-browser/tests/sharedFolderExplorer.js
  24. 46
      test-browser/tests/staticanalysis.js
  25. 56
      test-browser/tests/units/testRecorder.js

@ -0,0 +1,33 @@
const EventEmitter = require('events')
class addAtAddressInstance extends EventEmitter {
command (address, isValidFormat, isValidChecksum) {
this.api.perform((done) => {
addInstance(this.api, address, isValidFormat, isValidChecksum, () => {
done()
this.emit('complete')
})
})
return this
}
}
function addInstance (browser, address, isValidFormat, isValidChecksum, callback) {
browser.clickLaunchIcon('run').clearValue('.ataddressinput').setValue('.ataddressinput', address, function () {
browser.click('div[class^="atAddress"]')
.execute(function () {
var ret = document.querySelector('div[class^="modal-body"] div').innerHTML
document.querySelector('#modal-footer-ok').click()
return ret
}, [], function (result) {
if (!isValidFormat) {
browser.assert.equal(result.value, 'Invalid address.')
} else if (!isValidChecksum) {
browser.assert.equal(result.value, 'Invalid checksum address.')
}
callback()
})
})
}
module.exports = addAtAddressInstance

@ -0,0 +1,35 @@
const EventEmitter = require('events')
class AddFile extends EventEmitter {
command (name, content) {
this.api.perform((done) => {
addFile(this.api, name, content, () => {
done()
this.emit('complete')
})
})
return this
}
}
function addFile (browser, name, content, done) {
browser.clickLaunchIcon('run').clickLaunchIcon('fileExplorers').click('.newFile')
.perform((client, done) => {
browser.execute(function (fileName) {
if (fileName !== 'Untitled.sol') {
document.querySelector('#modal-dialog #prompt_text').setAttribute('value', fileName)
}
document.querySelector('#modal-footer-ok').click()
}, [name], function (result) {
console.log(result)
done()
})
})
.setEditorValue(content.content)
.pause(1000)
.perform(function () {
done()
})
}
module.exports = AddFile

@ -0,0 +1,35 @@
const EventEmitter = require('events')
class CheckTerminalFilter extends EventEmitter {
command (filter, test) {
this.api.perform((done) => {
checkFilter(this.api, filter, test, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkFilter (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 () {
return document.querySelector('#editor-container div[class^="journal"]').innerHTML === test
}, [], function (result) {
browser.clearValue(filterClass).setValue(filterClass, '', function () {
if (!result.value) {
browser.assert.fail('useFilter on ' + filter + ' ' + test, 'info about error', '')
}
done()
})
})
})
}
module.exports = CheckTerminalFilter

@ -0,0 +1,38 @@
const EventEmitter = require('events')
const deepequal = require('deep-equal')
class CreateContract extends EventEmitter {
command (id, debugValue) {
this.api.perform((done) => {
checkDebug(this.api, id, debugValue, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkDebug (browser, id, debugValue, done) {
// id is soliditylocals or soliditystate
browser.execute(function (id) {
return document.querySelector('#' + id + ' .dropdownrawcontent').innerText
}, [id], function (result) {
console.log(id + ' ' + result.value)
var value
try {
value = JSON.parse(result.value)
} catch (e) {
browser.assert.fail('cant parse solidity state', e.message, '')
done()
return
}
var equal = deepequal(debugValue, value)
if (!equal) {
browser.assert.fail('checkDebug on ' + id, 'info about error', '')
}
done()
})
}
module.exports = CreateContract

@ -0,0 +1,22 @@
const EventEmitter = require('events')
class CreateContract extends EventEmitter {
command (inputParams) {
this.api.perform((done) => {
createContract(this.api, inputParams, () => {
done()
this.emit('complete')
})
})
return this
}
}
function createContract (browser, inputParams, callback) {
browser.clickLaunchIcon('settings').clickLaunchIcon('run')
.setValue('div[class^="contractActionsContainerSingle"] input', inputParams, function () {
browser.click('#runTabView button[class^="instanceButton"]').pause(500).perform(function () { callback() })
})
}
module.exports = CreateContract

@ -0,0 +1,25 @@
const EventEmitter = require('events')
class GetAddressAtPosition extends EventEmitter {
command (index, cb) {
this.api.perform((done) => {
getAddressAtPosition(this.api, index, (pos) => {
done()
cb(pos)
this.emit('complete')
})
})
return this
}
}
function getAddressAtPosition (browser, index, callback) {
index = index + 2
browser.execute(function (index) {
return document.querySelector('.instance:nth-of-type(' + index + ')').getAttribute('id').replace('instance', '')
}, [index], function (result) {
callback(result.value)
})
}
module.exports = GetAddressAtPosition

@ -0,0 +1,38 @@
const EventEmitter = require('events')
class GoToVmTraceStep extends EventEmitter {
command (step, incr) {
this.api.perform((done) => {
goToVMtraceStep(this.api, step, incr, () => {
done()
this.emit('complete')
})
})
return this
}
}
function goToVMtraceStep (browser, step, incr, done) {
if (!incr) incr = 0
browser.execute(function (step) {
return document.querySelector('#stepdetail').innerHTML
}, [step], function (result) {
if (result.value.indexOf('vm trace step: ' + step) !== -1) {
done()
} else if (incr > 1000) {
console.log(result)
browser.assert.fail('goToVMtraceStep fails', 'info about error', '')
done()
} else {
incr++
browser.click('#intoforward')
.perform(() => {
setTimeout(() => {
goToVMtraceStep(browser, step, done, incr)
}, 200)
})
}
})
}
module.exports = GoToVmTraceStep

@ -0,0 +1,46 @@
const EventEmitter = require('events')
class RemoveFile extends EventEmitter {
command (path) {
this.api.perform((done) => {
removeFile(this.api, path, () => {
done()
this.emit('complete')
})
})
return this
}
}
function removeFile (browser, path, done) {
browser.execute(function (path) {
function contextMenuClick (element) {
var evt = element.ownerDocument.createEvent('MouseEvents')
var RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null)
if (document.createEventObject) {
// dispatch for IE
return element.fireEvent('onclick', evt)
} else {
// dispatch for firefox + others
return !element.dispatchEvent(evt)
}
}
contextMenuClick(document.querySelector('[data-path="' + path + '"]'))
}, [path], function (result) {
browser
.waitForElementVisible('#menuitemdelete', 2000)
.click('#menuitemdelete')
.pause(500)
.waitForElementVisible('#modal-footer-ok', 2000)
.click('#modal-footer-ok')
.waitForElementNotPresent('[data-path="' + path + '"]')
.perform(() => {
done()
})
})
}
module.exports = RemoveFile

@ -0,0 +1,53 @@
const EventEmitter = require('events')
class RenameFile extends EventEmitter {
command (path, newFileName, renamedPath) {
this.api.perform((done) => {
renameFile(this.api, path, newFileName, renamedPath, () => {
done()
this.emit('complete')
})
})
return this
}
}
function renameFile (browser, path, newFileName, renamedPath, done) {
browser.execute(function (path) {
function contextMenuClick (element) {
var evt = element.ownerDocument.createEvent('MouseEvents')
var RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null)
if (document.createEventObject) {
// dispatch for IE
return element.fireEvent('onclick', evt)
} else {
// dispatch for firefox + others
return !element.dispatchEvent(evt)
}
}
contextMenuClick(document.querySelector('[data-path="' + path + '"]'))
}, [path], function (result) {
browser
.click('#menuitemrename')
.perform((client, doneSetValue) => {
browser.execute(function (path, addvalue) {
document.querySelector('[data-path="' + path + '"]').innerHTML = addvalue
}, [path, newFileName], () => {
doneSetValue()
})
})
.click('body') // blur
.waitForElementVisible('#modal-footer-ok', 2000)
.click('#modal-footer-ok')
.waitForElementNotPresent('[data-path="' + path + '"]')
.waitForElementPresent('[data-path="' + renamedPath + '"]')
.perform(() => {
done()
})
})
}
module.exports = RenameFile

@ -0,0 +1,22 @@
const EventEmitter = require('events')
class SelectContract extends EventEmitter {
command (contractName) {
this.api.perform((done) => {
selectContract(this.api, contractName, () => {
done()
this.emit('complete')
})
})
return this
}
}
function selectContract (browser, contractName, callback) {
browser.clickLaunchIcon('settings').clickLaunchIcon('run')
.setValue('#runTabView select[class^="contractNames"]', contractName).perform(() => {
callback()
})
}
module.exports = SelectContract

@ -0,0 +1,42 @@
const EventEmitter = require('events')
class SelectContract extends EventEmitter {
command (msg, callback) {
this.api.perform((done) => {
signMsg(this.api, msg, (hash, signature) => {
callback(hash, signature)
done()
this.emit('complete')
})
})
return this
}
}
function signMsg (browser, msg, cb) {
let hash, signature
browser
.waitForElementPresent('i[id="remixRunSignMsg"]')
.click('i[id="remixRunSignMsg"]')
.waitForElementPresent('textarea[id="prompt_text"]')
.setValue('textarea[id="prompt_text"]', msg, () => {
browser.modalFooterOKClick().perform(
(client, done) => {
browser.getText('span[id="remixRunSignMsgHash"]', (v) => { hash = v; done() })
}
)
.perform(
(client, done) => {
browser.getText('span[id="remixRunSignMsgSignature"]', (v) => { signature = v; done() })
}
)
.modalFooterOKClick()
.perform(
() => {
cb(hash, signature)
}
)
})
}
module.exports = SelectContract

@ -0,0 +1,24 @@
const EventEmitter = require('events')
class SwitchFile extends EventEmitter {
command (contractName) {
this.api.perform((done) => {
switchFile(this.api, contractName, () => {
done()
this.emit('complete')
})
})
return this
}
}
function switchFile (browser, name, done) {
browser.clickLaunchIcon('settings').clickLaunchIcon('fileExplorers')
.click('li[key="' + name + '"]')
.pause(2000)
.perform(() => {
done()
})
}
module.exports = SwitchFile

@ -0,0 +1,36 @@
const EventEmitter = require('events')
class TestConstantFunction extends EventEmitter {
command (address, fnFullName, expectedInput, expectedOutput) {
console.log('TestConstantFunction ' + address + ' fnFullName')
this.api.perform((done) => {
testConstantFunction(this.api, address, fnFullName, expectedInput, expectedOutput, () => {
done()
this.emit('complete')
})
})
return this
}
}
function testConstantFunction (browser, address, fnFullName, expectedInput, expectedOutput, cb) {
browser.waitForElementPresent('.instance button[title="' + fnFullName + '"]').perform(function (client, done) {
client.execute(function () {
document.querySelector('#runTabView').scrollTop = document.querySelector('#runTabView').scrollHeight
}, [], function () {
if (expectedInput) {
client.setValue('#runTabView input[title="' + expectedInput.types + '"]', expectedInput.values, function () {})
}
done()
})
})
.click('.instance button[title="' + fnFullName + '"]')
.pause(1000)
.waitForElementPresent('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]')
.scrollInto('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]')
.assert.containsText('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]', expectedOutput).perform(() => {
cb()
})
}
module.exports = TestConstantFunction

@ -0,0 +1,27 @@
const EventEmitter = require('events')
class TestContracts extends EventEmitter {
command (fileName, contractCode, compiledContractNames) {
this.api.perform((done) => {
testContracts(this.api, fileName, contractCode, compiledContractNames, () => {
done()
this.emit('complete')
})
})
return this
}
}
function testContracts (browser, fileName, contractCode, compiledContractNames, callback) {
browser
.clickLaunchIcon('solidity')
.clearValue('#input textarea')
.addFile(fileName, contractCode)
.pause(1000)
.verifyContracts(compiledContractNames)
.perform(() => {
callback()
})
}
module.exports = TestContracts

@ -1,10 +1,9 @@
const EventEmitter = require('events')
class TestEditorValue extends EventEmitter {
command (testvalue, callback) {
command (testvalue) {
this.api.getEditorValue((value) => {
this.api.assert.equal(testvalue, value)
callback()
this.emit('complete')
})
return this

@ -0,0 +1,33 @@
const EventEmitter = require('events')
class VerifyCallReturnValue extends EventEmitter {
command (address, checks) {
this.api.perform((done) => {
verifyCallReturnValue(this.api, address, checks, () => {
done()
this.emit('complete')
})
})
return this
}
}
function verifyCallReturnValue (browser, address, checks, done) {
browser.execute(function (address) {
var nodes = document.querySelectorAll('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]')
var ret = []
for (var k = 0; k < nodes.length; k++) {
var text = nodes[k].innerText ? nodes[k].innerText : nodes[k].textContent
ret.push(text.replace('\n', ''))
}
return ret
}, [address], function (result) {
console.log('verifyCallReturnValue', result)
for (var k in checks) {
browser.assert.equal(result.value[k], checks[k])
}
done()
})
}
module.exports = VerifyCallReturnValue

@ -0,0 +1,52 @@
const EventEmitter = require('events')
class VerifyContracts extends EventEmitter {
command (compiledContractNames) {
this.api.perform((done) => {
verifyContracts(this.api, compiledContractNames, () => {
done()
this.emit('complete')
})
})
return this
}
}
function getCompiledContracts (browser, callback) {
browser.clickLaunchIcon('solidity').execute(function () {
var contracts = document.querySelectorAll('#compileTabView select option')
if (!contracts) {
return null
} else {
var ret = []
for (var c = 0; c < contracts.length; c++) {
ret.push(contracts[c].value)
}
return ret
}
}, [], function (result) {
callback(result)
})
}
function verifyContracts (browser, compiledContractNames, callback) {
getCompiledContracts(browser, (result) => {
if (result.value) {
for (var contract in compiledContractNames) {
console.log(' - ' + compiledContractNames[contract])
if (result.value.indexOf(compiledContractNames[contract]) === -1) {
browser.assert.fail('compiled contract ' + compiledContractNames + ' not found', 'info about error', '')
browser.end()
return
}
}
} else {
browser.assert.fail('compiled contract ' + compiledContractNames + ' not found - none found', 'info about error', '')
browser.end()
}
console.log('contracts all found ' + compiledContractNames)
callback()
})
}
module.exports = VerifyContracts

@ -1,339 +0,0 @@
'use strict'
var deepequal = require('deep-equal')
module.exports = {
getCompiledContracts,
testContracts,
addFile,
switchFile,
verifyContract,
selectContract,
testConstantFunction,
checkDebug,
goToVMtraceStep,
useFilter,
addInstance,
verifyCallReturnValue,
createContract,
renameFile,
removeFile,
getAddressAtPosition,
signMsg
}
function getCompiledContracts (browser, compiled, callback) {
browser.clickLaunchIcon('solidity').execute(function () {
var contracts = document.querySelectorAll('#compileTabView select option')
if (!contracts) {
return null
} else {
var ret = []
for (var c = 0; c < contracts.length; c++) {
ret.push(contracts[c].value)
}
return ret
}
}, [], function (result) {
callback(result)
})
}
function selectContract (browser, contractName, callback) {
browser.clickLaunchIcon('settings').clickLaunchIcon('run')
.setValue('#runTabView select[class^="contractNames"]', contractName).perform(() => {
callback()
})
}
function createContract (browser, inputParams, callback) {
browser.clickLaunchIcon('settings').clickLaunchIcon('run')
.setValue('div[class^="contractActionsContainerSingle"] input', inputParams, function () {
browser.click('#runTabView button[class^="instanceButton"]').pause(500).perform(function () { callback() })
})
}
function verifyContract (browser, compiledContractNames, callback) {
getCompiledContracts(browser, compiledContractNames, (result) => {
if (result.value) {
for (var contract in compiledContractNames) {
console.log(' - ' + compiledContractNames[contract])
if (result.value.indexOf(compiledContractNames[contract]) === -1) {
browser.assert.fail('compiled contract ' + compiledContractNames + ' not found', 'info about error', '')
browser.end()
return
}
}
} else {
browser.assert.fail('compiled contract ' + compiledContractNames + ' not found - none found', 'info about error', '')
browser.end()
}
console.log('contracts all found ' + compiledContractNames)
callback()
})
}
function testContracts (browser, fileName, contractCode, compiledContractNames, callback) {
browser
.clickLaunchIcon('solidity')
.clearValue('#input textarea')
.perform((client, done) => {
addFile(browser, fileName, contractCode, done)
})
.pause(1000)
.perform(function () {
verifyContract(browser, compiledContractNames, callback)
})
}
function verifyCallReturnValue (browser, address, checks, done) {
console.log('verifyCallReturnValue address', address)
browser.execute(function (address) {
var nodes = document.querySelectorAll('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]')
var ret = []
for (var k = 0; k < nodes.length; k++) {
var text = nodes[k].innerText ? nodes[k].innerText : nodes[k].textContent
ret.push(text.replace('\n', ''))
}
return ret
}, [address], function (result) {
console.log('verifyCallReturnValue', result)
for (var k in checks) {
browser.assert.equal(result.value[k], checks[k])
}
done()
})
}
function getAddressAtPosition (browser, index, callback) {
index = index + 2
browser.execute(function (index) {
return document.querySelector('.instance:nth-of-type(' + index + ')').getAttribute('id').replace('instance', '')
}, [index], function (result) {
callback(result.value)
})
}
function testConstantFunction (browser, address, fnFullName, expectedInput, expectedOutput, cb) {
browser.waitForElementPresent('.instance button[title="' + fnFullName + '"]').perform(function (client, done) {
client.execute(function () {
document.querySelector('#runTabView').scrollTop = document.querySelector('#runTabView').scrollHeight
}, [], function () {
if (expectedInput) {
client.setValue('#runTabView input[title="' + expectedInput.types + '"]', expectedInput.values, function () {})
}
done()
})
})
.click('.instance button[title="' + fnFullName + '"]')
.pause(1000)
.waitForElementPresent('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]')
.scrollInto('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]')
.assert.containsText('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]', expectedOutput).perform(() => {
cb()
})
}
function signMsg (browser, msg, cb) {
let hash, signature
browser
.waitForElementPresent('i[id="remixRunSignMsg"]')
.click('i[id="remixRunSignMsg"]')
.waitForElementPresent('textarea[id="prompt_text"]')
.setValue('textarea[id="prompt_text"]', msg, () => {
browser.modalFooterOKClick().perform(
(client, done) => {
browser.getText('span[id="remixRunSignMsgHash"]', (v) => { hash = v; done() })
}
)
.perform(
(client, done) => {
browser.getText('span[id="remixRunSignMsgSignature"]', (v) => { signature = v; done() })
}
)
.modalFooterOKClick()
.perform(
() => {
cb(hash, signature)
}
)
})
}
function addInstance (browser, address, isValidFormat, isValidChecksum, callback) {
browser.clickLaunchIcon('run').clearValue('.ataddressinput').setValue('.ataddressinput', address, function () {
browser.click('div[class^="atAddress"]')
.execute(function () {
var ret = document.querySelector('div[class^="modal-body"] div').innerHTML
document.querySelector('#modal-footer-ok').click()
return ret
}, [], function (result) {
if (!isValidFormat) {
browser.assert.equal(result.value, 'Invalid address.')
} else if (!isValidChecksum) {
browser.assert.equal(result.value, 'Invalid checksum address.')
}
callback()
})
})
}
function addFile (browser, name, content, done) {
browser.clickLaunchIcon('run').clickLaunchIcon('fileExplorers').click('.newFile')
.perform((client, done) => {
browser.execute(function (fileName) {
if (fileName !== 'Untitled.sol') {
document.querySelector('#modal-dialog #prompt_text').setAttribute('value', fileName)
}
document.querySelector('#modal-footer-ok').click()
}, [name], function (result) {
console.log(result)
done()
})
})
.setEditorValue(content.content)
.pause(1000)
.perform(function () {
done()
})
}
function renameFile (browser, path, newFileName, renamedPath, done) {
browser.execute(function (path) {
function contextMenuClick (element) {
var evt = element.ownerDocument.createEvent('MouseEvents')
var RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null)
if (document.createEventObject) {
// dispatch for IE
return element.fireEvent('onclick', evt)
} else {
// dispatch for firefox + others
return !element.dispatchEvent(evt)
}
}
contextMenuClick(document.querySelector('[data-path="' + path + '"]'))
}, [path], function (result) {
browser
.click('#menuitemrename')
.perform((client, doneSetValue) => {
browser.execute(function (path, addvalue) {
document.querySelector('[data-path="' + path + '"]').innerHTML = addvalue
}, [path, newFileName], () => {
doneSetValue()
})
})
.click('body') // blur
.pause(500)
.click('#modal-footer-ok')
.waitForElementNotPresent('[data-path="' + path + '"]')
.waitForElementPresent('[data-path="' + renamedPath + '"]')
.perform(() => {
done()
})
})
}
function removeFile (browser, path, done) {
browser.execute(function (path, value) {
function contextMenuClick (element) {
var evt = element.ownerDocument.createEvent('MouseEvents')
var RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null)
if (document.createEventObject) {
// dispatch for IE
return element.fireEvent('onclick', evt)
} else {
// dispatch for firefox + others
return !element.dispatchEvent(evt)
}
}
contextMenuClick(document.querySelector('[data-path="' + path + '"]'))
}, [path], function (result) {
browser
.click('#menuitemdelete')
.pause(500)
.click('#modal-footer-ok')
.waitForElementNotPresent('[data-path="' + path + '"]')
.perform(() => {
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 () {
return document.querySelector('#editor-container div[class^="journal"]').innerHTML === test
}, [], function (result) {
browser.clearValue(filterClass).setValue(filterClass, '', function () {
if (!result.value) {
browser.assert.fail('useFilter on ' + filter + ' ' + test, 'info about error', '')
}
done()
})
})
})
}
function switchFile (browser, name, done) {
browser.clickLaunchIcon('settings').clickLaunchIcon('fileExplorers')
.click('li[key="' + name + '"]')
.pause(2000)
.perform(() => {
done()
})
}
function checkDebug (browser, id, debugValue, done) {
// id is soliditylocals or soliditystate
browser.execute(function (id) {
return document.querySelector('#' + id + ' .dropdownrawcontent').innerText
}, [id], function (result) {
console.log(id + ' ' + result.value)
var value
try {
value = JSON.parse(result.value)
} catch (e) {
browser.assert.fail('cant parse solidity state', e.message, '')
done()
return
}
var equal = deepequal(debugValue, value)
if (!equal) {
browser.assert.fail('checkDebug on ' + id, 'info about error', '')
}
done()
})
}
function goToVMtraceStep (browser, step, done, incr) {
if (!incr) incr = 0
browser.execute(function (step) {
return document.querySelector('#stepdetail').innerHTML
}, [step], function (result) {
if (result.value.indexOf('vm trace step: ' + step) !== -1) {
done()
} else if (incr > 1000) {
console.log(result)
browser.assert.fail('goToVMtraceStep fails', 'info about error', '')
done()
} else {
incr++
browser.click('#intoforward')
.perform(() => {
setTimeout(() => {
goToVMtraceStep(browser, step, done, incr)
}, 200)
})
}
})
}

@ -1,24 +0,0 @@
'use strict'
module.exports = {
listSelectorContains: listSelectorContains
}
function listSelectorContains (textsToFind, selector, browser, callback) {
browser.execute(function (selector) {
var items = document.querySelectorAll(selector)
var ret = []
for (var k = 0; k < items.length; k++) {
ret.push(items[k].innerText)
}
return ret
}, [selector], function (result) {
console.log(result.value)
for (var k in textsToFind) {
console.log('testing ' + result.value[k] + ' against ' + textsToFind[k])
browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true)
}
callback()
})
}

@ -1,5 +1,4 @@
'use strict'
var contractHelper = require('../helpers/contracts')
var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
@ -25,69 +24,38 @@ function runTests (browser, testData) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('solidity')
.perform((client, done) => {
contractHelper.testContracts(browser, 'Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'], function () {
done()
})
}).clickLaunchIcon('run')
.setValue('input[placeholder="uint8 _numProposals"]', '1')
.click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.testFunction('delegate - transact (not payable)', '0x0571a2439ea58bd349dd130afb8aff62a33af14c06de0dbc3928519bdf13ce2e',
`[vm]\nfrom:0xca3...a733c\nto:Ballot.delegate(address) 0x692...77b3a\nvalue:0 wei\ndata:0x5c1...4d2db\nlogs:0\nhash:0x057...3ce2e`,
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null)
.pause(500)
.click('span#tx0x0571a2439ea58bd349dd130afb8aff62a33af14c06de0dbc3928519bdf13ce2e button[class^="debug"]')
.pause(2000)
.clickLaunchIcon('debugger')
.click('#jumppreviousbreakpoint')
.pause(2000)
.perform(function (client, done) {
console.log('goToVMtraceStep')
contractHelper.goToVMtraceStep(browser, 59, () => {
done()
})
})
.pause(1000)
.perform(function (client, done) {
contractHelper.checkDebug(browser, 'soliditystate', stateCheck, () => {
done()
})
})
.perform(function (client, done) {
contractHelper.checkDebug(browser, 'soliditylocals', localsCheck, () => {
done()
})
})
.clickLaunchIcon('run')
.click('button[class^="udappClose"]')
.perform((client, done) => {
console.log('ballot.abi')
contractHelper.addFile(browser, 'ballot.abi', { content: ballotABI }, () => {
done()
})
})
.perform((client, done) => {
console.log('addInstance invalid checksum address 0x692a70D2e424a56D2C6C27aA97D1a86395877b3B')
contractHelper.addInstance(browser, '0x692a70D2e424a56D2C6C27aA97D1a86395877b3B', true, false, () => {
done()
})
})
.clickLaunchIcon('fileExplorers')
.perform((client, done) => {
console.log('addInstance 0x692a70D2e424a56D2C6C27aA97D1a86395877b3A')
contractHelper.addInstance(browser, '0x692a70D2e424a56D2C6C27aA97D1a86395877b3A', true, true, () => {
done()
})
})
.pause(500)
.perform((client, done) => {
console.log('delegate - transact (not payable)')
browser.waitForElementPresent('.instance:nth-of-type(2)').click('.instance:nth-of-type(2) > div > button').testFunction('delegate - transact (not payable)', '0xd3cd54e2f76f3993078ecf9e1b54a148def4520afc141a182293b3610bddf10f',
`[vm]\nfrom:0xca3...a733c\nto:Ballot.delegate(address) 0x692...77b3a\nvalue:0 wei\ndata:0x5c1...4d2db\nlogs:0\nhash:0xd3c...df10f`,
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null, () => { done() })
}).end()
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.clickLaunchIcon('run')
.setValue('input[placeholder="uint8 _numProposals"]', '1')
.click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.testFunction('delegate - transact (not payable)', '0x0571a2439ea58bd349dd130afb8aff62a33af14c06de0dbc3928519bdf13ce2e',
`[vm]\nfrom:0xca3...a733c\nto:Ballot.delegate(address) 0x692...77b3a\nvalue:0 wei\ndata:0x5c1...4d2db\nlogs:0\nhash:0x057...3ce2e`,
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null)
.pause(500)
.click('span#tx0x0571a2439ea58bd349dd130afb8aff62a33af14c06de0dbc3928519bdf13ce2e button[class^="debug"]')
.pause(2000)
.clickLaunchIcon('debugger')
.click('#jumppreviousbreakpoint')
.pause(2000)
.goToVMTraceStep(59)
.pause(1000)
.checkVariableDebug('soliditystate', stateCheck)
.checkVariableDebug('soliditylocals', localsCheck)
.clickLaunchIcon('run')
.click('button[class^="udappClose"]')
.addFile('ballot.abi', { content: ballotABI })
.addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3B', true, false)
.clickLaunchIcon('fileExplorers')
.addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3A', true, true)
.pause(500)
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.testFunction('delegate - transact (not payable)', '0xd3cd54e2f76f3993078ecf9e1b54a148def4520afc141a182293b3610bddf10f',
`[vm]\nfrom:0xca3...a733c\nto:Ballot.delegate(address) 0x692...77b3a\nvalue:0 wei\ndata:0x5c1...4d2db\nlogs:0\nhash:0xd3c...df10f`,
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null)
.end()
}
var localsCheck = {

@ -1,5 +1,4 @@
'use strict'
var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var async = require('async')
@ -31,39 +30,36 @@ function runTests (browser) {
}
function testSimpleContract (browser, callback) {
contractHelper.testContracts(browser, 'Untitled.sol', sources[0]['browser/Untitled.sol'], ['TestContract'], function () {
browser.clickLaunchIcon('run')
.click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.click('#runTabView .instance div[class^="title"]')
.click('#runTabView .instance div[class^="title"]')
.testFunction('f - transact (not payable)',
'0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc',
`[vm]\nfrom:0xca3...a733c\nto:TestContract.f() 0x692...77b3a\nvalue:0 wei\ndata:0x261...21ff0\nlogs:0\nhash:0xa17...523bc`, null,
`{
"0": "uint256: 8"
}`)
.pause(500)
.perform((client, done) => {
contractHelper.useFilter(browser, '0x12332162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92782', '', () => {
done()
})
})
.testFunction('g - transact (not payable)',
'0xb1532162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92781',
`[vm]\nfrom:0xca3...a733c\nto:TestContract.g() 0x692...77b3a\nvalue:0 wei\ndata:0xe21...79b8e\nlogs:0\nhash:0xb15...92781`, null, `{
"0": "uint256: 345",
"1": "string: comment_comment_",
"2": "bool: true",
"3": "uint256: 4"
}`).click('i[class^="clearinstance"]').perform(() => { callback(null, browser) })
})
browser.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['TestContract'])
.clickLaunchIcon('run')
.click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.click('#runTabView .instance div[class^="title"]')
.click('#runTabView .instance div[class^="title"]')
.testFunction('f - transact (not payable)',
'0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc',
`[vm]\nfrom:0xca3...a733c\nto:TestContract.f() 0x692...77b3a\nvalue:0 wei\ndata:0x261...21ff0\nlogs:0\nhash:0xa17...523bc`, null,
`{
"0": "uint256: 8"
}`)
.pause(500)
.checkTerminalFilter('0x12332162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92782', '')
.testFunction('g - transact (not payable)',
'0xb1532162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92781',
`[vm]\nfrom:0xca3...a733c\nto:TestContract.g() 0x692...77b3a\nvalue:0 wei\ndata:0xe21...79b8e\nlogs:0\nhash:0xb15...92781`, null, `{
"0": "uint256: 345",
"1": "string: comment_comment_",
"2": "bool: true",
"3": "uint256: 4"
}`)
.click('i[class^="clearinstance"]')
.perform(() => { callback(null, browser) })
}
function testReturnValues (browser, callback) {
contractHelper.testContracts(browser, 'returnValues.sol', sources[1]['browser/returnValues.sol'], ['testReturnValues'], function () {
browser.clickLaunchIcon('run')
browser.testContracts('returnValues.sol', sources[1]['browser/returnValues.sol'], ['testReturnValues'])
.clickLaunchIcon('run')
.click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
@ -96,16 +92,15 @@ function testReturnValues (browser, callback) {
"0": "uint8: _en 2",
"1": "int256[5][]: _a1 1,-45,-78,56,60,-1,42,334,-45455,-446,1,10,-5435,45,-7"
}`).click('i[class^="clearinstance"]').perform(() => { callback(null, browser) })
})
}
function testInputValues (browser, callback) {
contractHelper.testContracts(browser, 'inputValues.sol', sources[2]['browser/inputValues.sol'], ['test'], function () {
browser.clickLaunchIcon('run')
browser.testContracts('inputValues.sol', sources[2]['browser/inputValues.sol'], ['test'])
.clickLaunchIcon('run')
.click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.testFunction('inputValue1 - transact (not payable)',
.testFunction('inputValue1 - transact (not payable)',
'0xf3265e3d9cd9299958bf81bed3cdfdd537942f85b9e0b95c5468c691d9396505',
`[vm]\nfrom:0xca3...a733c\nto:test.inputValue1(uint256,int256,string) 0x8c1...401f5\nvalue:0 wei\ndata:0xd69...00000\nlogs:0\nhash:0xf32...96505`,
{types: 'uint256 _u, int256 _i, string _str', values: '"2343242", "-4324324", "string _ string _ string _ string _ string _ string _ string _ string _ string _ string _"'},
@ -113,7 +108,9 @@ function testInputValues (browser, callback) {
"0": "uint256: _uret 2343242",
"1": "int256: _iret -4324324",
"2": "string: _strret string _ string _ string _ string _ string _ string _ string _ string _ string _ string _"
}`).pause(500).testFunction('inputValue2 - transact (not payable)',
}`)
.pause(500)
.testFunction('inputValue2 - transact (not payable)',
'0xd9ec6d8aa73d81755447190f52939ee3084e105b988d445a11e7ac718392ff5a',
`[vm]\nfrom:0xca3...a733c\nto:test.inputValue2(uint256[3],bytes8[4]) 0x8c1...401f5\nvalue:0 wei\ndata:0x1b7...00000\nlogs:1\nhash:0xd9e...2ff5a`,
{types: 'uint256[3] _n, bytes8[4] _b8', values: '[1,2,3], ["0x1234000000000000", "0x1234000000000000","0x1234000000000000","0x1234000000000000"]'},
@ -146,8 +143,8 @@ function testInputValues (browser, callback) {
}
}
]`)
.click('i[class^="clearinstance"]').perform(() => { callback(null, browser) })
})
.click('i[class^="clearinstance"]')
.perform(() => { callback(null, browser) })
}
// @TODO test: bytes8[3][] type as input

@ -1,5 +1,4 @@
'use strict'
var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var async = require('async')
@ -41,155 +40,151 @@ function runTests (browser) {
function testSimpleContract (browser, callback) {
console.log('testSimpleContract')
contractHelper.testContracts(browser, 'Untitled.sol', sources[0]['browser/Untitled.sol'], ['test1', 'test2'], function () {
browser.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['test1', 'test2'])
.perform(() => {
callback(null, browser)
})
}
function testSuccessImport (browser, callback) {
console.log('testSuccessImport')
contractHelper.addFile(browser, 'Untitled1.sol', sources[1]['browser/Untitled1.sol'], () => {
contractHelper.addFile(browser, 'Untitled2.sol', sources[1]['browser/Untitled2.sol'], () => {
contractHelper.switchFile(browser, 'browser/Untitled1.sol', function () {
contractHelper.verifyContract(browser, ['test6', 'test4', 'test5'], function () {
browser.addFile('Untitled1.sol', sources[1]['browser/Untitled1.sol'])
.addFile('Untitled2.sol', sources[1]['browser/Untitled2.sol'])
.switchFile('browser/Untitled1.sol')
.verifyContracts(['test6', 'test4', 'test5'])
.perform(() => {
callback(null, browser)
})
})
})
})
}
function testFailedImport (browser, callback) {
console.log('testFailedImport')
contractHelper.addFile(browser, 'Untitled3.sol', sources[2]['browser/Untitled3.sol'], () => {
browser.clickLaunchIcon('solidity').assert.containsText('#compileTabView .error pre', 'Unable to import "browser/Untitled11.sol": File not found')
.perform(function () {
callback(null, browser)
})
})
browser.addFile('Untitled3.sol', sources[2]['browser/Untitled3.sol'])
.clickLaunchIcon('solidity')
.assert.containsText('#compileTabView .error pre', 'Unable to import "browser/Untitled11.sol": File not found')
.perform(function () {
callback(null, browser)
})
}
function addDeployLibTestFile (browser, callback) {
contractHelper.addFile(browser, 'Untitled5.sol', sources[5]['browser/Untitled5.sol'], () => {
callback(null, browser)
})
browser.addFile('Untitled5.sol', sources[5]['browser/Untitled5.sol'])
.perform(() => {
callback(null, browser)
})
}
function testAutoDeployLib (browser, callback) {
console.log('testAutoDeployLib')
contractHelper.verifyContract(browser, ['test'], () => {
contractHelper.selectContract(browser, 'test', () => {
contractHelper.createContract(browser, '', () => {
contractHelper.getAddressAtPosition(browser, 0, (address) => {
console.log(address)
browser.waitForElementPresent('.instance:nth-of-type(2)').click('.instance:nth-of-type(2) > div > button').perform(() => {
contractHelper.testConstantFunction(browser, address, 'get - call', '', '0: uint256: 45', () => { callback(null, browser) })
let addressRef
browser.verifyContracts(['test'])
.selectContract('test')
.createContract('')
.getAddressAtPosition(0, (address) => {
console.log('testAutoDeployLib ' + address)
addressRef = address
})
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.perform(() => {
browser
.testConstantFunction(addressRef, 'get - call', '', '0: uint256: 45')
.perform(() => {
callback(null, browser)
})
})
})
})
})
}
function testManualDeployLib (browser, callback) {
console.log('testManualDeployLib')
browser.click('i[class^="clearinstance"]').pause(5000).clickLaunchIcon('settings').click('#generatecontractmetadata').perform(() => {
browser.clickLaunchIcon('solidity').click('#compileTabView button[title="Compile"]').perform(() => { // that should generate the JSON artefact
contractHelper.verifyContract(browser, ['test'], () => {
contractHelper.selectContract(browser, 'lib', () => { // deploy lib
contractHelper.createContract(browser, '', () => {
contractHelper.getAddressAtPosition(browser, 0, (address) => {
console.log('address:', address)
checkDeployShouldFail(browser, () => {
checkDeployShouldSucceed(browser, address, () => {
callback(null, browser)
})
})
browser.click('i[class^="clearinstance"]')
.pause(5000)
.clickLaunchIcon('settings')
.click('#generatecontractmetadata')
.clickLaunchIcon('solidity')
.click('#compileTabView button[title="Compile"]') // that should generate the JSON artefact
.verifyContracts(['test'])
.selectContract('lib') // deploy lib
.createContract('')
.getAddressAtPosition(0, (address) => {
console.log(address)
checkDeployShouldFail(browser, () => {
checkDeployShouldSucceed(browser, address, () => {
callback(null, browser)
})
})
})
})
})
})
}
function checkDeployShouldFail (browser, callback) {
contractHelper.switchFile(browser, 'browser/test.json', () => {
browser.getEditorValue((content) => {
var config = JSON.parse(content)
config.deploy['VM:-'].autoDeployLib = false
browser.setEditorValue(JSON.stringify(config), () => {
contractHelper.switchFile(browser, 'browser/Untitled5.sol', () => {
contractHelper.selectContract(browser, 'test', () => { // deploy lib
contractHelper.createContract(browser, '', () => {
browser.assert.containsText('div[class^="terminal"]', '<address> is not a valid address').perform(() => { callback() })
})
})
let config
browser.switchFile('browser/test.json')
.getEditorValue((content) => {
config = JSON.parse(content)
config.deploy['VM:-'].autoDeployLib = false
})
})
})
})
.perform(() => {
browser.setEditorValue(JSON.stringify(config))
})
.switchFile('browser/Untitled5.sol')
.selectContract('test') // deploy lib
.createContract('')
.assert.containsText('div[class^="terminal"]', '<address> is not a valid address')
.perform(() => { callback() })
}
function checkDeployShouldSucceed (browser, address, callback) {
contractHelper.switchFile(browser, 'browser/test.json', () => {
browser.getEditorValue((content) => {
var config = JSON.parse(content)
config.deploy['VM:-'].autoDeployLib = false
config.deploy['VM:-']['linkReferences']['browser/Untitled5.sol'].lib = address
browser.setEditorValue(JSON.stringify(config), () => {
contractHelper.switchFile(browser, 'browser/Untitled5.sol', () => {
contractHelper.selectContract(browser, 'test', () => { // deploy lib
contractHelper.createContract(browser, '', () => {
contractHelper.getAddressAtPosition(browser, 1, (address) => {
browser.waitForElementPresent('.instance:nth-of-type(3)')
.click('.instance:nth-of-type(3) > div > button').perform(() => {
contractHelper.testConstantFunction(browser, address, 'get - call', '', '0: uint256: 45', () => { callback(null, browser) })
})
})
})
})
let addressRef
let config
browser.switchFile('browser/test.json')
.getEditorValue((content) => {
config = JSON.parse(content)
config.deploy['VM:-'].autoDeployLib = false
config.deploy['VM:-']['linkReferences']['browser/Untitled5.sol'].lib = address
})
.perform(() => {
browser.setEditorValue(JSON.stringify(config))
})
.switchFile('browser/Untitled5.sol')
.selectContract('test') // deploy lib
.createContract('')
.getAddressAtPosition(1, (address) => {
addressRef = address
})
.waitForElementPresent('.instance:nth-of-type(3)')
.click('.instance:nth-of-type(3) > div > button')
.perform(() => {
browser
.testConstantFunction(addressRef, 'get - call', '', '0: uint256: 45')
.perform(() => { callback() })
})
})
})
})
}
function testSignature (browser, callback) {
let hash, signature
contractHelper.signMsg(browser, 'test message', (h, s) => {
browser.signMessage('test message', (h, s) => {
hash = h
signature = s
browser.assert.ok(typeof hash.value === 'string', 'type of hash.value must be String')
browser.assert.ok(typeof signature.value === 'string', 'type of signature.value must be String')
contractHelper.addFile(browser, 'signMassage.sol', sources[6]['browser/signMassage.sol'], () => {
contractHelper.switchFile(browser, 'browser/signMassage.sol', () => {
contractHelper.selectContract(browser, 'ECVerify', () => { // deploy lib
contractHelper.createContract(browser, '', () => {
const instanceSelector = '.instance:nth-of-type(4)'
browser.waitForElementPresent(instanceSelector)
.click(instanceSelector + ' > div > button')
.getAttribute(instanceSelector, 'id', (result) => {
// skip 'instance' part of e.g. 'instance0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'
// const address = result.value.slice('instance'.length)
browser.clickFunction('ecrecovery - call', {types: 'bytes32 hash, bytes sig', values: `"${hash.value}","${signature.value}"`}).perform(
() => {
callback(null, browser)
/*
contractHelper.verifyCallReturnValue(
browser,
address,
['0: address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'],
() => { callback(null, browser) }
)
*/
})
})
.addFile('signMassage.sol', sources[6]['browser/signMassage.sol'])
.switchFile('browser/signMassage.sol')
.selectContract('ECVerify')
.createContract('')
.waitForElementPresent('.instance:nth-of-type(4)')
.click('.instance:nth-of-type(4) > div > button')
.getAttribute('.instance:nth-of-type(4)', 'id', (result) => {
// skip 'instance' part of e.g. 'instance0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'
const address = result.value.slice('instance'.length)
browser.clickFunction('ecrecovery - call', {types: 'bytes32 hash, bytes sig', values: `"${hash.value}","${signature.value}"`})
.verifyCallReturnValue(
address,
['0: address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'])
.perform(() => {
callback(null, browser)
})
})
})
})
})
})
}
/*

@ -1,5 +1,4 @@
'use strict'
var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
@ -52,11 +51,6 @@ function runTests (browser, testData) {
browser.end()
return
}
if (browserName === 'chrome') {
console.log('do not run remixd test for ' + browserName + ': TODO to reenable later')
browser.end()
return
}
if (browserName === 'firefox') {
console.log('do not run remixd test for ' + browserName + ': TODO to reenable later')
browser.end()
@ -69,6 +63,8 @@ function runTests (browser, testData) {
.click('#pluginManager article[id="remixPluginManagerListItem_remixd"] button')
.waitForElementVisible('#modal-footer-ok', 2000)
.click('#modal-footer-ok')
.pause(2000)
.click('#modal-footer-ok')
.clickLaunchIcon('fileExplorers')
.waitForElementVisible('[data-path="localhost/folder1"]')
.click('[data-path="localhost/folder1"]')
@ -81,64 +77,31 @@ function runTests (browser, testData) {
.click('[data-path="localhost/folder1/contract2.sol"]')
.click('[data-path="localhost/folder1/contract1.sol"]') // open localhost/folder1/contract1.sol
.pause(1000)
.perform(function (done) { // check the content and replace by another
browser.testEditorValue('contract test1 { function get () returns (uint) { return 10; }}', () => {
console.log('testEditorValue')
done()
})
})
.perform(function (done) {
browser.setEditorValue('contract test1Changed { function get () returns (uint) { return 10; }}', () => {
console.log('setEditorValue')
done()
})
})
.perform(function (done) {
browser.testEditorValue('contract test1Changed { function get () returns (uint) { return 10; }}', () => {
console.log('testEditorValue')
done()
})
})
.perform(function (done) {
browser.setEditorValue('contract test1 { function get () returns (uint) { return 10; }}', () => {
console.log('setEditorValue')
done()
})
})
.testEditorValue('contract test1 { function get () returns (uint) { return 10; }}') // check the content and replace by another
.setEditorValue('contract test1Changed { function get () returns (uint) { return 10; }}')
.testEditorValue('contract test1Changed { function get () returns (uint) { return 10; }}')
.setEditorValue('contract test1 { function get () returns (uint) { return 10; }}')
.click('[data-path="localhost/folder1/contract_' + browserName + '.sol"]') // rename a file and check
.pause(1000)
.perform(function (done) {
contractHelper.renameFile(browser, 'localhost/folder1/contract_' + browserName + '.sol', 'renamed_contract_' + browserName + '.sol',
'localhost/folder1/renamed_contract_' + browserName + '.sol', () => {
console.log('tested file renaming')
done()
})
})
.renameFile('localhost/folder1/contract_' + browserName + '.sol', 'renamed_contract_' + browserName + '.sol', 'localhost/folder1/renamed_contract_' + browserName + '.sol')
.pause(1000)
.perform(function (done) { // remove a file and check
contractHelper.removeFile(browser, 'localhost/folder1/contract_' + browserName + '_toremove.sol', () => {
console.log('tested file removing')
done()
})
})
.removeFile('localhost/folder1/contract_' + browserName + '_toremove.sol')
.perform(function (done) {
testImportFromRemixd(browser, () => { done() })
})
.perform(function () {
browser.clickLaunchIcon('fileExplorers').click('[data-path="localhost"]') // collapse and expand
.waitForElementNotVisible('[data-path="localhost/folder1"]')
.click('[data-path="localhost"]')
.waitForElementVisible('[data-path="localhost/folder1"]')
.click('[data-path="localhost/folder1"]')
.waitForElementVisible('[data-path="localhost/folder1/contract1.sol"]')
.waitForElementVisible('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]') // check if renamed file is preset
.waitForElementNotPresent('[data-path="localhost/folder1/contract_' + browserName + '.sol"]') // check if renamed (old) file is not present
.waitForElementNotPresent('[data-path="localhost/folder1/contract_' + browserName + '_toremove.sol"]') // check if removed (old) file is not present
.click('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]')
.clickLaunchIcon('pluginManager')
.click('#pluginManager article[id="remixPluginManagerListItem_remixd"] button')
.end()
})
.clickLaunchIcon('fileExplorers').click('[data-path="localhost"]') // collapse and expand
.waitForElementNotVisible('[data-path="localhost/folder1"]')
.click('[data-path="localhost"]')
.waitForElementVisible('[data-path="localhost/folder1"]')
.click('[data-path="localhost/folder1"]')
.waitForElementVisible('[data-path="localhost/folder1/contract1.sol"]')
.waitForElementVisible('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]') // check if renamed file is preset
.waitForElementNotPresent('[data-path="localhost/folder1/contract_' + browserName + '.sol"]') // check if renamed (old) file is not present
.waitForElementNotPresent('[data-path="localhost/folder1/contract_' + browserName + '_toremove.sol"]') // check if removed (old) file is not present
.click('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]')
.clickLaunchIcon('pluginManager')
.click('#pluginManager article[id="remixPluginManagerListItem_remixd"] button')
.end()
}
function testImportFromRemixd (browser, callback) {
@ -150,9 +113,6 @@ function testImportFromRemixd (browser, callback) {
.waitForElementVisible('[data-path="localhost/src/gmbh/company.sol"]', 100000)
.click('[data-path="localhost/src/gmbh/company.sol"]')
.pause(1000)
.perform(() => {
contractHelper.verifyContract(browser, ['Assets', 'gmbh'], function () {
callback()
})
})
.verifyContracts(['Assets', 'gmbh'])
.perform(() => { callback() })
}

@ -1,8 +1,6 @@
'use strict'
var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var dom = require('../helpers/dom')
var sources = [
{
@ -36,19 +34,35 @@ function runTests (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('solidity')
contractHelper.testContracts(browser, 'Untitled.sol', sources[0]['browser/Untitled.sol'], ['TooMuchGas', 'test1', 'test2'], function () {
browser
.clickLaunchIcon('solidityStaticAnalysis')
.click('#staticanalysisView button')
.waitForElementPresent('#staticanalysisresult .staticAnalysisWarning', 2000, true, function () {
dom.listSelectorContains(['browser/Untitled.sol:2:33:Use of tx.origin',
'Fallback function of contract TooMuchGas requires too much gas',
'TooMuchGas.() : Variables have very similar names test and test1.'],
'#staticanalysisresult .staticAnalysisWarning',
browser, function () {
browser.end()
}
)
})
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['TooMuchGas', 'test1', 'test2'])
.clickLaunchIcon('solidityStaticAnalysis')
.click('#staticanalysisView button')
.waitForElementPresent('#staticanalysisresult .staticAnalysisWarning', 2000, true, function () {
listSelectorContains(['browser/Untitled.sol:2:33:Use of tx.origin',
'Fallback function of contract TooMuchGas requires too much gas',
'TooMuchGas.() : Variables have very similar names test and test1.'],
'#staticanalysisresult .staticAnalysisWarning',
browser, function () {
browser.end()
}
)
})
}
function listSelectorContains (textsToFind, selector, browser, callback) {
browser.execute(function (selector) {
var items = document.querySelectorAll(selector)
var ret = []
for (var k = 0; k < items.length; k++) {
ret.push(items[k].innerText)
}
return ret
}, [selector], function (result) {
console.log(result.value)
for (var k in textsToFind) {
console.log('testing ' + result.value[k] + ' against ' + textsToFind[k])
browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true)
}
callback()
})
}

@ -1,5 +1,4 @@
'use strict'
var contractHelper = require('../../helpers/contracts')
module.exports = {
'@disabled': true, // run by compiling.j
@ -7,8 +6,7 @@ module.exports = {
return sources
},
test: function (browser, callback) {
contractHelper.addFile(browser, 'scenario.json', {content: records}, () => {
browser
browser.addFile('scenario.json', {content: records})
.clickLaunchIcon('run')
.click('div[class^="cardContainer"] i[class^="arrow"]')
.click('#runTabView .runtransaction')
@ -20,44 +18,32 @@ module.exports = {
.clickFunction('getAddress - call')
.clickFunction('getFromLib - call')
.waitForElementPresent('div[class^="contractActionsContainer"] div[class^="value"] ul')
.perform((client, done) => {
contractHelper.verifyCallReturnValue(browser, '0x35ef07393b57464e93deb59175ff72e6499450cf', ['0: uint256: 1', '0: uint256: 3456', '0: address: 0x35eF07393b57464e93dEB59175fF72E6499450cF'], () => {
done()
})
})
.verifyCallReturnValue('0x35ef07393b57464e93deb59175ff72e6499450cf', ['0: uint256: 1', '0: uint256: 3456', '0: address: 0x35eF07393b57464e93dEB59175fF72E6499450cF'])
.click('i[class^="clearinstance"]')
.perform((client, done) => {
contractHelper.testContracts(browser, 'testRecorder.sol', sources[0]['browser/testRecorder.sol'], ['testRecorder'], function () {
done()
})
})
.perform((client, done) => {
contractHelper.createContract(browser, '12', function () {
done()
})
})
.testContracts('testRecorder.sol', sources[0]['browser/testRecorder.sol'], ['testRecorder'])
.createContract('12')
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.perform((client, done) => {
browser.clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'})
.click('i.savetransaction').modalFooterOKClick().getEditorValue(function (result) {
var parsed = JSON.parse(result)
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.name), JSON.stringify(scenario.transactions[0].record.name))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.type), JSON.stringify(scenario.transactions[0].record.type))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.from), JSON.stringify(scenario.transactions[0].record.from))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.contractName), JSON.stringify(scenario.transactions[0].record.contractName))
.clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'})
.click('i.savetransaction')
.modalFooterOKClick()
.getEditorValue(function (result) {
var parsed = JSON.parse(result)
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.name), JSON.stringify(scenario.transactions[0].record.name))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.type), JSON.stringify(scenario.transactions[0].record.type))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.from), JSON.stringify(scenario.transactions[0].record.from))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.contractName), JSON.stringify(scenario.transactions[0].record.contractName))
browser.assert.equal(JSON.stringify(parsed.transactions[1].record.parameters), JSON.stringify(scenario.transactions[1].record.parameters))
browser.assert.equal(JSON.stringify(parsed.transactions[1].record.name), JSON.stringify(scenario.transactions[1].record.name))
browser.assert.equal(JSON.stringify(parsed.transactions[1].record.type), JSON.stringify(scenario.transactions[1].record.type))
browser.assert.equal(JSON.stringify(parsed.transactions[1].record.from), JSON.stringify(scenario.transactions[1].record.from))
done()
})
}).perform(() => {
browser.assert.equal(JSON.stringify(parsed.transactions[1].record.parameters), JSON.stringify(scenario.transactions[1].record.parameters))
browser.assert.equal(JSON.stringify(parsed.transactions[1].record.name), JSON.stringify(scenario.transactions[1].record.name))
browser.assert.equal(JSON.stringify(parsed.transactions[1].record.type), JSON.stringify(scenario.transactions[1].record.type))
browser.assert.equal(JSON.stringify(parsed.transactions[1].record.from), JSON.stringify(scenario.transactions[1].record.from))
})
.perform(() => {
callback()
})
})
}
}

Loading…
Cancel
Save