You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
57 lines
1.6 KiB
6 years ago
|
const EventEmitter = require('events')
|
||
|
|
||
6 years ago
|
class VerifyContracts extends EventEmitter {
|
||
5 years ago
|
command (compiledContractNames, opts = { wait: 1000 }) {
|
||
6 years ago
|
this.api.perform((done) => {
|
||
5 years ago
|
verifyContracts(this.api, compiledContractNames, opts, () => {
|
||
6 years ago
|
done()
|
||
|
this.emit('complete')
|
||
|
})
|
||
|
})
|
||
|
return this
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
function getCompiledContracts (browser, opts, callback) {
|
||
5 years ago
|
browser
|
||
|
.clickLaunchIcon('solidity')
|
||
5 years ago
|
.pause(opts.wait)
|
||
5 years ago
|
.waitForElementPresent('*[data-id="compiledContracts"] option')
|
||
5 years ago
|
.execute(function () {
|
||
5 years ago
|
var contracts = document.querySelectorAll('*[data-id="compiledContracts"] option')
|
||
6 years ago
|
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)
|
||
|
})
|
||
|
}
|
||
|
|
||
5 years ago
|
function verifyContracts (browser, compiledContractNames, opts, callback) {
|
||
|
getCompiledContracts(browser, opts, (result) => {
|
||
6 years ago
|
if (result.value) {
|
||
|
for (var contract in compiledContractNames) {
|
||
6 years ago
|
console.log(' - ' + compiledContractNames[contract], result.value)
|
||
6 years ago
|
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()
|
||
|
})
|
||
|
}
|
||
|
|
||
6 years ago
|
module.exports = VerifyContracts
|