Commit 3e9eb111 authored by yann300's avatar yann300

use nightwatch commands from tests

parent dac60a5a
const EventEmitter = require('events') const EventEmitter = require('events')
class GetAddressAtPositionInRunModule extends EventEmitter { class GetAddressAtPosition extends EventEmitter {
command (index, cb) { command (index, cb) {
this.api.perform((done) => { this.api.perform((done) => {
getAddressAtPosition(this.api, index, (pos) => { getAddressAtPosition(this.api, index, (pos) => {
cb(pos)
done() done()
cb(pos)
this.emit('complete') this.emit('complete')
}) })
}) })
...@@ -22,4 +22,4 @@ function getAddressAtPosition (browser, index, callback) { ...@@ -22,4 +22,4 @@ function getAddressAtPosition (browser, index, callback) {
}) })
} }
module.exports = GetAddressAtPositionInRunModule module.exports = GetAddressAtPosition
...@@ -13,7 +13,7 @@ class RemoveFile extends EventEmitter { ...@@ -13,7 +13,7 @@ class RemoveFile extends EventEmitter {
} }
function removeFile (browser, path, done) { function removeFile (browser, path, done) {
browser.execute(function (path, value) { browser.execute(function (path) {
function contextMenuClick (element) { function contextMenuClick (element) {
var evt = element.ownerDocument.createEvent('MouseEvents') var evt = element.ownerDocument.createEvent('MouseEvents')
var RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE var RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
...@@ -31,8 +31,10 @@ function removeFile (browser, path, done) { ...@@ -31,8 +31,10 @@ function removeFile (browser, path, done) {
contextMenuClick(document.querySelector('[data-path="' + path + '"]')) contextMenuClick(document.querySelector('[data-path="' + path + '"]'))
}, [path], function (result) { }, [path], function (result) {
browser browser
.waitForElementVisible('#menuitemdelete', 2000)
.click('#menuitemdelete') .click('#menuitemdelete')
.pause(500) .pause(500)
.waitForElementVisible('#modal-footer-ok', 2000)
.click('#modal-footer-ok') .click('#modal-footer-ok')
.waitForElementNotPresent('[data-path="' + path + '"]') .waitForElementNotPresent('[data-path="' + path + '"]')
.perform(() => { .perform(() => {
......
...@@ -40,7 +40,7 @@ function renameFile (browser, path, newFileName, renamedPath, done) { ...@@ -40,7 +40,7 @@ function renameFile (browser, path, newFileName, renamedPath, done) {
}) })
}) })
.click('body') // blur .click('body') // blur
.pause(500) .waitForElementVisible('#modal-footer-ok', 2000)
.click('#modal-footer-ok') .click('#modal-footer-ok')
.waitForElementNotPresent('[data-path="' + path + '"]') .waitForElementNotPresent('[data-path="' + path + '"]')
.waitForElementPresent('[data-path="' + renamedPath + '"]') .waitForElementPresent('[data-path="' + renamedPath + '"]')
......
const EventEmitter = require('events') const EventEmitter = require('events')
class SelectContract extends EventEmitter { class SelectContract extends EventEmitter {
command (msg) { command (msg, callback) {
this.api.perform((done) => { this.api.perform((done) => {
signMsg(this.api, msg, (hash, signature) => { signMsg(this.api, msg, (hash, signature) => {
callback(hash, signature)
done() done()
this.emit('complete') this.emit('complete')
}) })
......
...@@ -2,6 +2,7 @@ const EventEmitter = require('events') ...@@ -2,6 +2,7 @@ const EventEmitter = require('events')
class TestConstantFunction extends EventEmitter { class TestConstantFunction extends EventEmitter {
command (address, fnFullName, expectedInput, expectedOutput) { command (address, fnFullName, expectedInput, expectedOutput) {
console.log('TestConstantFunction ' + address + ' fnFullName')
this.api.perform((done) => { this.api.perform((done) => {
testConstantFunction(this.api, address, fnFullName, expectedInput, expectedOutput, () => { testConstantFunction(this.api, address, fnFullName, expectedInput, expectedOutput, () => {
done() done()
......
const EventEmitter = require('events') const EventEmitter = require('events')
class TestContract extends EventEmitter { class TestContracts extends EventEmitter {
command (fileName, contractCode, compiledContractNames) { command (fileName, contractCode, compiledContractNames) {
this.api.perform((done) => { this.api.perform((done) => {
testContracts(this.api, fileName, contractCode, compiledContractNames, () => { testContracts(this.api, fileName, contractCode, compiledContractNames, () => {
...@@ -18,10 +18,10 @@ function testContracts (browser, fileName, contractCode, compiledContractNames, ...@@ -18,10 +18,10 @@ function testContracts (browser, fileName, contractCode, compiledContractNames,
.clearValue('#input textarea') .clearValue('#input textarea')
.addFile(fileName, contractCode) .addFile(fileName, contractCode)
.pause(1000) .pause(1000)
.verifyContract(compiledContractNames) .verifyContracts(compiledContractNames)
.perform(() => { .perform(() => {
callback() callback()
}) })
} }
module.exports = TestContract module.exports = TestContracts
const EventEmitter = require('events') const EventEmitter = require('events')
class TestEditorValue extends EventEmitter { class TestEditorValue extends EventEmitter {
command (testvalue, callback) { command (testvalue) {
this.api.getEditorValue((value) => { this.api.getEditorValue((value) => {
this.api.assert.equal(testvalue, value) this.api.assert.equal(testvalue, value)
callback()
this.emit('complete') this.emit('complete')
}) })
return this return this
......
const EventEmitter = require('events') const EventEmitter = require('events')
class VerifyContract extends EventEmitter { class VerifyContracts extends EventEmitter {
command (compiledContractNames) { command (compiledContractNames) {
this.api.perform((done) => { this.api.perform((done) => {
verifyContract(this.api, compiledContractNames, () => { verifyContracts(this.api, compiledContractNames, () => {
done() done()
this.emit('complete') this.emit('complete')
}) })
...@@ -29,7 +29,7 @@ function getCompiledContracts (browser, callback) { ...@@ -29,7 +29,7 @@ function getCompiledContracts (browser, callback) {
}) })
} }
function verifyContract (browser, compiledContractNames, callback) { function verifyContracts (browser, compiledContractNames, callback) {
getCompiledContracts(browser, (result) => { getCompiledContracts(browser, (result) => {
if (result.value) { if (result.value) {
for (var contract in compiledContractNames) { for (var contract in compiledContractNames) {
...@@ -49,4 +49,4 @@ function verifyContract (browser, compiledContractNames, callback) { ...@@ -49,4 +49,4 @@ function verifyContract (browser, compiledContractNames, callback) {
}) })
} }
module.exports = VerifyContract module.exports = VerifyContracts
'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()
})
}
'use strict' 'use strict'
var contractHelper = require('../helpers/contracts')
var examples = require('../../src/app/editor/example-contracts') var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init') var init = require('../helpers/init')
var sauce = require('./sauce') var sauce = require('./sauce')
...@@ -25,69 +24,38 @@ function runTests (browser, testData) { ...@@ -25,69 +24,38 @@ function runTests (browser, testData) {
browser browser
.waitForElementVisible('#icon-panel', 10000) .waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('solidity') .clickLaunchIcon('solidity')
.perform((client, done) => { .testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
contractHelper.testContracts(browser, 'Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'], function () { .clickLaunchIcon('run')
done() .setValue('input[placeholder="uint8 _numProposals"]', '1')
}) .click('#runTabView button[class^="instanceButton"]')
}).clickLaunchIcon('run') .waitForElementPresent('.instance:nth-of-type(2)')
.setValue('input[placeholder="uint8 _numProposals"]', '1') .click('.instance:nth-of-type(2) > div > button')
.click('#runTabView button[class^="instanceButton"]') .testFunction('delegate - transact (not payable)', '0x0571a2439ea58bd349dd130afb8aff62a33af14c06de0dbc3928519bdf13ce2e',
.waitForElementPresent('.instance:nth-of-type(2)') `[vm]\nfrom:0xca3...a733c\nto:Ballot.delegate(address) 0x692...77b3a\nvalue:0 wei\ndata:0x5c1...4d2db\nlogs:0\nhash:0x057...3ce2e`,
.click('.instance:nth-of-type(2) > div > button') {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null)
.testFunction('delegate - transact (not payable)', '0x0571a2439ea58bd349dd130afb8aff62a33af14c06de0dbc3928519bdf13ce2e', .pause(500)
`[vm]\nfrom:0xca3...a733c\nto:Ballot.delegate(address) 0x692...77b3a\nvalue:0 wei\ndata:0x5c1...4d2db\nlogs:0\nhash:0x057...3ce2e`, .click('span#tx0x0571a2439ea58bd349dd130afb8aff62a33af14c06de0dbc3928519bdf13ce2e button[class^="debug"]')
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null) .pause(2000)
.pause(500) .clickLaunchIcon('debugger')
.click('span#tx0x0571a2439ea58bd349dd130afb8aff62a33af14c06de0dbc3928519bdf13ce2e button[class^="debug"]') .click('#jumppreviousbreakpoint')
.pause(2000) .pause(2000)
.clickLaunchIcon('debugger') .goToVMTraceStep(59)
.click('#jumppreviousbreakpoint') .pause(1000)
.pause(2000) .checkVariableDebug('soliditystate', stateCheck)
.perform(function (client, done) { .checkVariableDebug('soliditylocals', localsCheck)
console.log('goToVMtraceStep') .clickLaunchIcon('run')
contractHelper.goToVMtraceStep(browser, 59, () => { .click('button[class^="udappClose"]')
done() .addFile('ballot.abi', { content: ballotABI })
}) .addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3B', true, false)
}) .clickLaunchIcon('fileExplorers')
.pause(1000) .addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3A', true, true)
.perform(function (client, done) { .pause(500)
contractHelper.checkDebug(browser, 'soliditystate', stateCheck, () => { .waitForElementPresent('.instance:nth-of-type(2)')
done() .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`,
.perform(function (client, done) { {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null)
contractHelper.checkDebug(browser, 'soliditylocals', localsCheck, () => { .end()
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()
} }
var localsCheck = { var localsCheck = {
......
'use strict' 'use strict'
var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init') var init = require('../helpers/init')
var sauce = require('./sauce') var sauce = require('./sauce')
var async = require('async') var async = require('async')
...@@ -31,39 +30,36 @@ function runTests (browser) { ...@@ -31,39 +30,36 @@ function runTests (browser) {
} }
function testSimpleContract (browser, callback) { function testSimpleContract (browser, callback) {
contractHelper.testContracts(browser, 'Untitled.sol', sources[0]['browser/Untitled.sol'], ['TestContract'], function () { browser.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['TestContract'])
browser.clickLaunchIcon('run') .clickLaunchIcon('run')
.click('#runTabView button[class^="instanceButton"]') .click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)') .waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button') .click('.instance:nth-of-type(2) > div > button')
.click('#runTabView .instance div[class^="title"]') .click('#runTabView .instance div[class^="title"]')
.click('#runTabView .instance div[class^="title"]') .click('#runTabView .instance div[class^="title"]')
.testFunction('f - transact (not payable)', .testFunction('f - transact (not payable)',
'0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc', '0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc',
`[vm]\nfrom:0xca3...a733c\nto:TestContract.f() 0x692...77b3a\nvalue:0 wei\ndata:0x261...21ff0\nlogs:0\nhash:0xa17...523bc`, null, `[vm]\nfrom:0xca3...a733c\nto:TestContract.f() 0x692...77b3a\nvalue:0 wei\ndata:0x261...21ff0\nlogs:0\nhash:0xa17...523bc`, null,
`{ `{
"0": "uint256: 8" "0": "uint256: 8"
}`) }`)
.pause(500) .pause(500)
.perform((client, done) => { .checkTerminalFilter('0x12332162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92782', '')
contractHelper.useFilter(browser, '0x12332162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92782', '', () => { .testFunction('g - transact (not payable)',
done() '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",
.testFunction('g - transact (not payable)', "1": "string: comment_comment_",
'0xb1532162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92781', "2": "bool: true",
`[vm]\nfrom:0xca3...a733c\nto:TestContract.g() 0x692...77b3a\nvalue:0 wei\ndata:0xe21...79b8e\nlogs:0\nhash:0xb15...92781`, null, `{ "3": "uint256: 4"
"0": "uint256: 345", }`)
"1": "string: comment_comment_", .click('i[class^="clearinstance"]')
"2": "bool: true", .perform(() => { callback(null, browser) })
"3": "uint256: 4"
}`).click('i[class^="clearinstance"]').perform(() => { callback(null, browser) })
})
} }
function testReturnValues (browser, callback) { function testReturnValues (browser, callback) {
contractHelper.testContracts(browser, 'returnValues.sol', sources[1]['browser/returnValues.sol'], ['testReturnValues'], function () { browser.testContracts('returnValues.sol', sources[1]['browser/returnValues.sol'], ['testReturnValues'])
browser.clickLaunchIcon('run') .clickLaunchIcon('run')
.click('#runTabView button[class^="instanceButton"]') .click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)') .waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button') .click('.instance:nth-of-type(2) > div > button')
...@@ -96,16 +92,15 @@ function testReturnValues (browser, callback) { ...@@ -96,16 +92,15 @@ function testReturnValues (browser, callback) {
"0": "uint8: _en 2", "0": "uint8: _en 2",
"1": "int256[5][]: _a1 1,-45,-78,56,60,-1,42,334,-45455,-446,1,10,-5435,45,-7" "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) }) }`).click('i[class^="clearinstance"]').perform(() => { callback(null, browser) })
})
} }
function testInputValues (browser, callback) { function testInputValues (browser, callback) {
contractHelper.testContracts(browser, 'inputValues.sol', sources[2]['browser/inputValues.sol'], ['test'], function () { browser.testContracts('inputValues.sol', sources[2]['browser/inputValues.sol'], ['test'])
browser.clickLaunchIcon('run') .clickLaunchIcon('run')
.click('#runTabView button[class^="instanceButton"]') .click('#runTabView button[class^="instanceButton"]')
.waitForElementPresent('.instance:nth-of-type(2)') .waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button') .click('.instance:nth-of-type(2) > div > button')
.testFunction('inputValue1 - transact (not payable)', .testFunction('inputValue1 - transact (not payable)',
'0xf3265e3d9cd9299958bf81bed3cdfdd537942f85b9e0b95c5468c691d9396505', '0xf3265e3d9cd9299958bf81bed3cdfdd537942f85b9e0b95c5468c691d9396505',
`[vm]\nfrom:0xca3...a733c\nto:test.inputValue1(uint256,int256,string) 0x8c1...401f5\nvalue:0 wei\ndata:0xd69...00000\nlogs:0\nhash:0xf32...96505`, `[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 _"'}, {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) { ...@@ -113,7 +108,9 @@ function testInputValues (browser, callback) {
"0": "uint256: _uret 2343242", "0": "uint256: _uret 2343242",
"1": "int256: _iret -4324324", "1": "int256: _iret -4324324",
"2": "string: _strret string _ string _ string _ string _ string _ string _ string _ string _ string _ string _" "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', '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`, `[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"]'}, {types: 'uint256[3] _n, bytes8[4] _b8', values: '[1,2,3], ["0x1234000000000000", "0x1234000000000000","0x1234000000000000","0x1234000000000000"]'},
...@@ -146,8 +143,8 @@ function testInputValues (browser, callback) { ...@@ -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 // @TODO test: bytes8[3][] type as input
......
This diff is collapsed.
'use strict' 'use strict'
var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init') var init = require('../helpers/init')
var sauce = require('./sauce') var sauce = require('./sauce')
...@@ -52,11 +51,6 @@ function runTests (browser, testData) { ...@@ -52,11 +51,6 @@ function runTests (browser, testData) {
browser.end() browser.end()
return return
} }
if (browserName === 'chrome') {
console.log('do not run remixd test for ' + browserName + ': TODO to reenable later')
browser.end()
return
}
if (browserName === 'firefox') { if (browserName === 'firefox') {
console.log('do not run remixd test for ' + browserName + ': TODO to reenable later') console.log('do not run remixd test for ' + browserName + ': TODO to reenable later')
browser.end() browser.end()
...@@ -81,64 +75,31 @@ function runTests (browser, testData) { ...@@ -81,64 +75,31 @@ function runTests (browser, testData) {
.click('[data-path="localhost/folder1/contract2.sol"]') .click('[data-path="localhost/folder1/contract2.sol"]')
.click('[data-path="localhost/folder1/contract1.sol"]') // open localhost/folder1/contract1.sol .click('[data-path="localhost/folder1/contract1.sol"]') // open localhost/folder1/contract1.sol
.pause(1000) .pause(1000)
.perform(function (done) { // check the content and replace by another .testEditorValue('contract test1 { function get () returns (uint) { return 10; }}') // check the content and replace by another
browser.testEditorValue('contract test1 { function get () returns (uint) { return 10; }}', () => { .setEditorValue('contract test1Changed { function get () returns (uint) { return 10; }}')
console.log('testEditorValue') .testEditorValue('contract test1Changed { function get () returns (uint) { return 10; }}')
done() .setEditorValue('contract test1 { function get () returns (uint) { return 10; }}')
})
})
.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()
})
})
.click('[data-path="localhost/folder1/contract_' + browserName + '.sol"]') // rename a file and check .click('[data-path="localhost/folder1/contract_' + browserName + '.sol"]') // rename a file and check
.pause(1000) .pause(1000)
.perform(function (done) { .renameFile('localhost/folder1/contract_' + browserName + '.sol', 'renamed_contract_' + browserName + '.sol', 'localhost/folder1/renamed_contract_' + browserName + '.sol')
contractHelper.renameFile(browser, 'localhost/folder1/contract_' + browserName + '.sol', 'renamed_contract_' + browserName + '.sol',
'localhost/folder1/renamed_contract_' + browserName + '.sol', () => {
console.log('tested file renaming')
done()
})
})
.pause(1000) .pause(1000)
.perform(function (done) { // remove a file and check .removeFile('localhost/folder1/contract_' + browserName + '_toremove.sol')
contractHelper.removeFile(browser, 'localhost/folder1/contract_' + browserName + '_toremove.sol', () => {
console.log('tested file removing')
done()
})
})
.perform(function (done) { .perform(function (done) {
testImportFromRemixd(browser, () => { done() }) testImportFromRemixd(browser, () => { done() })
}) })
.perform(function () { .clickLaunchIcon('fileExplorers').click('[data-path="localhost"]') // collapse and expand
browser.clickLaunchIcon('fileExplorers').click('[data-path="localhost"]') // collapse and expand .waitForElementNotVisible('[data-path="localhost/folder1"]')
.waitForElementNotVisible('[data-path="localhost/folder1"]') .click('[data-path="localhost"]')
.click('[data-path="localhost"]') .waitForElementVisible('[data-path="localhost/folder1"]')
.waitForElementVisible('[data-path="localhost/folder1"]') .click('[data-path="localhost/folder1"]')
.click('[data-path="localhost/folder1"]') .waitForElementVisible('[data-path="localhost/folder1/contract1.sol"]')
.waitForElementVisible('[data-path="localhost/folder1/contract1.sol"]') .waitForElementVisible('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]') // check if renamed file is preset
.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 + '.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
.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"]')
.click('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]') .clickLaunchIcon('pluginManager')
.clickLaunchIcon('pluginManager') .click('#pluginManager article[id="remixPluginManagerListItem_remixd"] button')
.click('#pluginManager article[id="remixPluginManagerListItem_remixd"] button') .end()
.end()
})
} }
function testImportFromRemixd (browser, callback) { function testImportFromRemixd (browser, callback) {
...@@ -150,9 +111,6 @@ function testImportFromRemixd (browser, callback) { ...@@ -150,9 +111,6 @@ function testImportFromRemixd (browser, callback) {
.waitForElementVisible('[data-path="localhost/src/gmbh/company.sol"]', 100000) .waitForElementVisible('[data-path="localhost/src/gmbh/company.sol"]', 100000)
.click('[data-path="localhost/src/gmbh/company.sol"]') .click('[data-path="localhost/src/gmbh/company.sol"]')
.pause(1000) .pause(1000)
.perform(() => { .verifyContracts(['Assets', 'gmbh'])
contractHelper.verifyContract(browser, ['Assets', 'gmbh'], function () { .perform(() => { callback() })
callback()
})
})
} }
'use strict' 'use strict'
var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init') var init = require('../helpers/init')
var sauce = require('./sauce') var sauce = require('./sauce')
var dom = require('../helpers/dom')
var sources = [ var sources = [
{ {
...@@ -36,19 +34,35 @@ function runTests (browser) { ...@@ -36,19 +34,35 @@ function runTests (browser) {
browser browser
.waitForElementVisible('#icon-panel', 10000) .waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('solidity') .clickLaunchIcon('solidity')
contractHelper.testContracts(browser, 'Untitled.sol', sources[0]['browser/Untitled.sol'], ['TooMuchGas', 'test1', 'test2'], function () { .testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['TooMuchGas', 'test1', 'test2'])
browser .clickLaunchIcon('solidityStaticAnalysis')
.clickLaunchIcon('solidityStaticAnalysis') .click('#staticanalysisView button')
.click('#staticanalysisView button') .waitForElementPresent('#staticanalysisresult .staticAnalysisWarning', 2000, true, function () {
.waitForElementPresent('#staticanalysisresult .staticAnalysisWarning', 2000, true, function () { listSelectorContains(['browser/Untitled.sol:2:33:Use of tx.origin',
dom.listSelectorContains(['browser/Untitled.sol:2:33:Use of tx.origin', 'Fallback function of contract TooMuchGas requires too much gas',
'Fallback function of contract TooMuchGas requires too much gas', 'TooMuchGas.() : Variables have very similar names test and test1.'],
'TooMuchGas.() : Variables have very similar names test and test1.'], '#staticanalysisresult .staticAnalysisWarning',
'#staticanalysisresult .staticAnalysisWarning', browser, function () {
browser, function () { browser.end()
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()
}) })
} }
'use strict' 'use strict'
var contractHelper = require('../../helpers/contracts')
module.exports = { module.exports = {
'@disabled': true, // run by compiling.j '@disabled': true, // run by compiling.j
...@@ -7,8 +6,7 @@ module.exports = { ...@@ -7,8 +6,7 @@ module.exports = {
return sources return sources
}, },
test: function (browser, callback) { test: function (browser, callback) {
contractHelper.addFile(browser, 'scenario.json', {content: records}, () => { browser.addFile('scenario.json', {content: records})
browser
.clickLaunchIcon('run') .clickLaunchIcon('run')
.click('div[class^="cardContainer"] i[class^="arrow"]') .click('div[class^="cardContainer"] i[class^="arrow"]')
.click('#runTabView .runtransaction') .click('#runTabView .runtransaction')
...@@ -20,44 +18,32 @@ module.exports = { ...@@ -20,44 +18,32 @@ module.exports = {
.clickFunction('getAddress - call') .clickFunction('getAddress - call')
.clickFunction('getFromLib - call') .clickFunction('getFromLib - call')
.waitForElementPresent('div[class^="contractActionsContainer"] div[class^="value"] ul') .waitForElementPresent('div[class^="contractActionsContainer"] div[class^="value"] ul')
.perform((client, done) => { .verifyCallReturnValue('0x35ef07393b57464e93deb59175ff72e6499450cf', ['0: uint256: 1', '0: uint256: 3456', '0: address: 0x35eF07393b57464e93dEB59175fF72E6499450cF'])
contractHelper.verifyCallReturnValue(browser, '0x35ef07393b57464e93deb59175ff72e6499450cf', ['0: uint256: 1', '0: uint256: 3456', '0: address: 0x35eF07393b57464e93dEB59175fF72E6499450cF'], () => {
done()
})
})
.click('i[class^="clearinstance"]') .click('i[class^="clearinstance"]')
.perform((client, done) => { .testContracts('testRecorder.sol', sources[0]['browser/testRecorder.sol'], ['testRecorder'])
contractHelper.testContracts(browser, 'testRecorder.sol', sources[0]['browser/testRecorder.sol'], ['testRecorder'], function () { .createContract('12')
done()
})
})
.perform((client, done) => {
contractHelper.createContract(browser, '12', function () {
done()
})
})
.waitForElementPresent('.instance:nth-of-type(2)') .waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button') .click('.instance:nth-of-type(2) > div > button')
.perform((client, done) => { .clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'})
browser.clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'}) .click('i.savetransaction')
.click('i.savetransaction').modalFooterOKClick().getEditorValue(function (result) { .modalFooterOKClick()
var parsed = JSON.parse(result) .getEditorValue(function (result) {
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters)) var parsed = JSON.parse(result)
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.parameters), JSON.stringify(scenario.transactions[0].record.parameters))
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.name), JSON.stringify(scenario.transactions[0].record.name))
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.type), JSON.stringify(scenario.transactions[0].record.type))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.contractName), JSON.stringify(scenario.transactions[0].record.contractName)) 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.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.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.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)) browser.assert.equal(JSON.stringify(parsed.transactions[1].record.from), JSON.stringify(scenario.transactions[1].record.from))
done() })
}) .perform(() => {
}).perform(() => {
callback() callback()
}) })
})
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment