parent
b8ad41d3c4
commit
e7df29cbd7
@ -1,54 +1,55 @@ |
|||||||
const EventEmitter = require('events') |
const EventEmitter = require('events') |
||||||
const deepequal = require('deep-equal') |
|
||||||
|
|
||||||
class TestFunction extends EventEmitter { |
/* |
||||||
command (fnFullName, txHash, log, expectedInput, expectedReturn, expectedEvent, callback) { |
Checks if any child elements of journal (console) contains a matching value. |
||||||
this.api.waitForElementPresent('.instance button[title="' + fnFullName + '"]') |
*/ |
||||||
.perform(function (client, done) { |
class testTransactionLog extends EventEmitter { |
||||||
client.execute(function () { |
command (txHash, expectedValue) { |
||||||
document.querySelector('#runTabView').scrollTop = document.querySelector('#runTabView').scrollHeight |
const browser = this.api; |
||||||
}, [], function () { |
browser.perform(() => { |
||||||
if (expectedInput) { |
const result = parseTransactionLog(this.api, txHash) |
||||||
client.setValue('#runTabView input[title="' + expectedInput.types + '"]', expectedInput.values, function () {}) |
|
||||||
} |
|
||||||
done() |
|
||||||
}) |
|
||||||
}) |
|
||||||
.click('.instance button[title="' + fnFullName + '"]') |
|
||||||
.pause(500) |
|
||||||
.waitForElementPresent('#main-panel div[class^="terminal"] span[id="tx' + txHash + '"]') |
|
||||||
.assert.containsText('#main-panel div[class^="terminal"] span[id="tx' + txHash + '"] span', log) |
|
||||||
.click('#main-panel div[class^="terminal"] span[id="tx' + txHash + '"] div[class^="log"]') |
|
||||||
.perform(function (client, done) { |
|
||||||
if (expectedReturn) { |
|
||||||
client.getText('#main-panel div[class^="terminal"] span[id="tx' + txHash + '"] table[class^="txTable"] #decodedoutput', (result) => { |
|
||||||
console.log(result) |
|
||||||
var equal = deepequal(JSON.parse(result.value), JSON.parse(expectedReturn)) |
|
||||||
if (!equal) { |
|
||||||
client.assert.fail('expected ' + expectedReturn + ' got ' + result.value, 'info about error', '') |
|
||||||
} |
|
||||||
}) |
|
||||||
} |
|
||||||
done() |
|
||||||
}) |
|
||||||
.perform((client, done) => { |
|
||||||
if (expectedEvent) { |
|
||||||
client.getText('#main-panel div[class^="terminal"] span[id="tx' + txHash + '"] table[class^="txTable"] #logs', (result) => { |
|
||||||
console.log(result) |
|
||||||
var equal = deepequal(JSON.parse(result.value), JSON.parse(expectedEvent)) |
|
||||||
if (!equal) { |
|
||||||
client.assert.fail('expected ' + expectedEvent + ' got ' + result.value, 'info about error', '') |
|
||||||
} |
|
||||||
}) |
|
||||||
} |
|
||||||
done() |
|
||||||
if (callback) { |
|
||||||
callback.call(this.api) |
|
||||||
} |
|
||||||
this.emit('complete') |
this.emit('complete') |
||||||
}) |
}) |
||||||
return this |
return this |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
module.exports = TestFunction |
function parseTransactionLog(browser, txHash){ |
||||||
|
const logs = {
|
||||||
|
status: '', |
||||||
|
'transaction hash': '', |
||||||
|
'contract address': '', |
||||||
|
from: '', |
||||||
|
to: '', |
||||||
|
gas: '', |
||||||
|
'transaction cost': '', |
||||||
|
'execution cost': '', |
||||||
|
hash: '', |
||||||
|
input: '', |
||||||
|
'decoded input': '', |
||||||
|
'decoded output': '', |
||||||
|
logs: '', |
||||||
|
value: ''
|
||||||
|
} |
||||||
|
|
||||||
|
browser.waitForElementVisible('txLoggerTable'+txHash) |
||||||
|
.getText(`*[data-id="txLoggerTableStatus${txHash}"]`, (result) => logs.status = result) |
||||||
|
.getText(`*[data-id="txLoggerTableTransactionHash${txHash}"]`, (result) => logs['transaction hash'] = result) |
||||||
|
.getText(`*[data-id="txLoggerTableContractAddress${txHash}"]`, (result) => logs['contract address'] = result) |
||||||
|
.getText(`*[data-id="txLoggerTableFrom${txHash}"]`, (result) => logs.from = result) |
||||||
|
.getText(`*[data-id="txLoggerTableTo${txHash}"]`, (result) => logs.to = result) |
||||||
|
.getText(`*[data-id="txLoggerTableGas${txHash}"]`, (result) => logs.gas = result) |
||||||
|
.getText(`*[data-id="txLoggerTableTransactionCost${txHash}"]`, (result) => logs['transaction cost'] = result) |
||||||
|
.getText(`*[data-id="txLoggerTableExecutionCost${txHash}"]`, (result) => logs['execution cost'] = result) |
||||||
|
.getText(`*[data-id="txLoggerTableHash${txHash}"]`, (result) => logs.hash = result) |
||||||
|
.getText(`*[data-id="txLoggerTableInput${txHash}"]`, (result) => logs.input = result) |
||||||
|
.getText(`*[data-id="txLoggerTableDecodedInput${txHash}"]`, (result) => logs['decoded input'] = result) |
||||||
|
.getText(`*[data-id="txLoggerTableDecodedOutput${txHash}"]`, (result) => logs['decoded output'] = result) |
||||||
|
.getText(`*[data-id="txLoggerTableDecodedLogs${txHash}"]`, (result) => logs.logs = result) |
||||||
|
.getText(`*[data-id="txLoggerTableDecodedLogs${txHash}"]`, (result) => logs.value = result) |
||||||
|
|
||||||
|
return logs; |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = testFunction |
Loading…
Reference in new issue