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