Commit 2526d9d5 authored by ioedeveloper's avatar ioedeveloper Committed by yann300

Updated transaction execution test with improved testFunction

parent 419aa385
...@@ -165,7 +165,7 @@ class Terminal extends Plugin { ...@@ -165,7 +165,7 @@ class Terminal extends Plugin {
${self._view.dragbar} ${self._view.dragbar}
<div class="${css.menu} border-top border-dark bg-light" data-id="terminalToggleMenu"> <div class="${css.menu} border-top border-dark bg-light" data-id="terminalToggleMenu">
${self._view.icon} ${self._view.icon}
<div class=${css.clear} id="clearConsole" onclick=${clear}> <div class=${css.clear} id="clearConsole" data-id="terminalClearConsole" onclick=${clear}>
<i class="fas fa-ban" aria-hidden="true" title="Clear console" <i class="fas fa-ban" aria-hidden="true" title="Clear console"
onmouseenter=${hover} onmouseleave=${hover}></i> onmouseenter=${hover} onmouseleave=${hover}></i>
</div> </div>
......
...@@ -54,7 +54,7 @@ class ContractDropdownUI { ...@@ -54,7 +54,7 @@ class ContractDropdownUI {
this.createPanel = yo`<div class="${css.deployDropdown}"></div>` this.createPanel = yo`<div class="${css.deployDropdown}"></div>`
this.orLabel = yo`<div class="${css.orLabel}">or</div>` this.orLabel = yo`<div class="${css.orLabel}">or</div>`
let el = yo` let el = yo`
<div class="${css.container}"> <div class="${css.container}" data-id="contractDropdownContainer">
<label class="${css.settingsLabel}">Contract</label> <label class="${css.settingsLabel}">Contract</label>
<div class="${css.subcontainer}"> <div class="${css.subcontainer}">
${this.selectContractNames} ${this.compFails} ${info} ${this.selectContractNames} ${this.compFails} ${info}
......
...@@ -69,7 +69,7 @@ class SettingsUI { ...@@ -69,7 +69,7 @@ class SettingsUI {
title="Execution environment has been provided by Metamask or similar provider." title="Execution environment has been provided by Metamask or similar provider."
value="injected" name="executionContext"> Injected Web3 value="injected" name="executionContext"> Injected Web3
</option> </option>
<option id="web3-mode" <option id="web3-mode" data-id="settingsWeb3Mode"
title="Execution environment connects to node at localhost (or via IPC if available), transactions will be sent to the network and can cause loss of money or worse! title="Execution environment connects to node at localhost (or via IPC if available), transactions will be sent to the network and can cause loss of money or worse!
If this page is served via https and you access your node via http, it might not work. In this case, try cloning the repository and serving it via http." If this page is served via https and you access your node via http, it might not work. In this case, try cloning the repository and serving it via http."
value="web3" name="executionContext"> Web3 Provider value="web3" name="executionContext"> Web3 Provider
......
...@@ -79,6 +79,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address ...@@ -79,6 +79,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
var close = yo` var close = yo`
<button <button
class="${css.udappClose} p-1 btn btn-secondary" class="${css.udappClose} p-1 btn btn-secondary"
data-id="universalDappUiUdappClose"
onclick=${remove} onclick=${remove}
title="Remove from the list" title="Remove from the list"
> >
...@@ -87,7 +88,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address ...@@ -87,7 +88,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
title.querySelector('.btn-group').appendChild(close) title.querySelector('.btn-group').appendChild(close)
var contractActionsWrapper = yo` var contractActionsWrapper = yo`
<div class="${css.cActionsWrapper}"> <div class="${css.cActionsWrapper}" data-id="universalDappUiContractActionWrapper">
</div> </div>
` `
......
...@@ -2,25 +2,12 @@ const EventEmitter = require('events') ...@@ -2,25 +2,12 @@ const EventEmitter = require('events')
const deepequal = require('deep-equal') const deepequal = require('deep-equal')
class TestFunction extends EventEmitter { class TestFunction extends EventEmitter {
command (fnFullName, txHash, expectedReturn, input) { command (txHash, expectedValue) {
const browser = this.api const browser = this.api
const logs = {} const logs = {}
const setLog = (index, value) => logs[Object.keys(logs)[index]] = value; const setLog = (index, value) => logs[Object.keys(logs)[index]] = value;
browser.waitForElementPresent(`*[data-id="${fnFullName}"]`) browser.waitForElementVisible(`*[data-id="txLogger${txHash}"]`)
.perform(function (client, done) {
client.execute(function () {
document.querySelector('*[data-id="runTabView"]').scrollTop = document.querySelector('*[data-id="runTabView"]').scrollHeight
}, [], function () {
if (input) {
client.setValue(`*[data-id="multiParamManagerBasicInputField${input.types}"]`, input.values, function () {})
}
done()
})
})
.click(`*[data-id="${fnFullName}"]`)
.pause(500)
.waitForElementVisible(`*[data-id="txLogger${txHash}"]`)
.click(`*[data-id="txLogger${txHash}"]`) .click(`*[data-id="txLogger${txHash}"]`)
.waitForElementVisible(`*[data-id="txLoggerTable${txHash}"]`) .waitForElementVisible(`*[data-id="txLoggerTable${txHash}"]`)
.click(`*[data-id="txLoggerTable${txHash}"]`) .click(`*[data-id="txLoggerTable${txHash}"]`)
...@@ -55,13 +42,13 @@ class TestFunction extends EventEmitter { ...@@ -55,13 +42,13 @@ class TestFunction extends EventEmitter {
}) })
browser.perform(() => { browser.perform(() => {
Object.keys(expectedReturn).forEach(key => { Object.keys(expectedValue).forEach(key => {
const equal = deepequal(logs[key], expectedReturn[key]) const equal = deepequal(logs[key], expectedValue[key])
if (!equal) { if (!equal) {
browser.assert.fail(`Expected ${expectedReturn[key]} but got ${logs[key]}`) browser.assert.fail(`Expected ${expectedValue[key]} but got ${logs[key]}`)
}else{ }else{
browser.assert.ok(true, `Expected value matched returned value ${expectedReturn[key]}`) browser.assert.ok(true, `Expected value matched returned value ${expectedValue[key]}`)
} }
}) })
this.emit('complete') this.emit('complete')
......
...@@ -23,25 +23,23 @@ module.exports = { ...@@ -23,25 +23,23 @@ module.exports = {
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c') .selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c')
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]') .setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
.click('*[data-id="Deploy - transact (not payable)"]') .click('*[data-id="Deploy - transact (not payable)"]')
.waitForElementPresent('.instance:nth-of-type(2)') .waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
.click('*[data-id="universalDappUiTitleExpander"]') .click('*[data-id="universalDappUiTitleExpander"]')
.testFunction( .clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
'delegate - transact (not payable)', .testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
{ {
status: '0x1 Transaction mined and execution succeed', status: '0x1 Transaction mined and execution succeed',
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3', 'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' } 'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
}, })
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
}, },
'Debug Ballot / delegate': function (browser) { 'Debug Ballot / delegate': function (browser) {
browser.pause(500) browser.pause(500)
.click('span#tx0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3 button[class^="debug"]') .click('*[data-id="txLoggerDebugButton0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3"]')
.pause(2000) .pause(2000)
.clickLaunchIcon('debugger') .clickLaunchIcon('debugger')
.click('#jumppreviousbreakpoint') .click('*[data-id="buttonNavigatorJumpPreviousBreakpoint"]')
.pause(2000) .pause(2000)
.goToVMTraceStep(79) .goToVMTraceStep(79)
.pause(1000) .pause(1000)
...@@ -51,36 +49,34 @@ module.exports = { ...@@ -51,36 +49,34 @@ module.exports = {
'Access Ballot via at address': function (browser) { 'Access Ballot via at address': function (browser) {
browser.clickLaunchIcon('udapp') browser.clickLaunchIcon('udapp')
.click('button[class^="udappClose"]') .click('*[data-id="universalDappUiUdappClose"]')
.addFile('ballot.abi', { content: ballotABI }) .addFile('ballot.abi', { content: ballotABI })
.addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3B', true, false) .addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3B', true, false)
.clickLaunchIcon('fileExplorers') .clickLaunchIcon('fileExplorers')
.addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3A', true, true) .addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3A', true, true)
.pause(500) .pause(500)
.waitForElementPresent('.instance:nth-of-type(2)') .waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
.click('.instance:nth-of-type(2) > div > button') .click('*[data-id="universalDappUiTitleExpander"]')
.createContract(["0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803"]) .clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
.pause(100000) .testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
.testTransactionLog('0x57f7ac07a894739a8bbf059248f47aa49935bfcf673494114b1c5c0c183890f0', { {
status: '0x1 Transaction mined and execution succeed', status: '0x0 Transaction mined but execution failed',
'transaction hash': '0x57f7ac07a894739a8bbf059248f47aa49935bfcf673494114b1c5c0c183890f0', 'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
'decoded input': { 'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
'bytes32[] proposalNames': [ '0x48656c6c6f20576f726c64210000000000000000000000000000000000000000' ]
}
}) })
}, },
'Deploy and use Ballot using external web3': function (browser) { 'Deploy and use Ballot using external web3': function (browser) {
browser browser
.click('#selectExEnvOptions #web3-mode') .click('*[data-id="settingsWeb3Mode"]')
.modalFooterOKClick() .modalFooterOKClick()
.clickLaunchIcon('solidity') .clickLaunchIcon('solidity')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) .testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp') .clickLaunchIcon('udapp')
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]') .setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
.click('#runTabView button[class^="instanceButton"]') .click('*[data-id="Deploy - transact (not payable)"]')
.clickInstance(0) .clickInstance(0)
.click('#clearConsole') .click('*[data-id="terminalClearConsole"]')
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'}) .clickFunction('delegate - transact (not payable)', {types: 'address to', values: '0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'})
.journalLastChildIncludes('Ballot.delegate(address)') .journalLastChildIncludes('Ballot.delegate(address)')
.journalLastChildIncludes('data:0x5c1...a733c') .journalLastChildIncludes('data:0x5c1...a733c')
......
This diff is collapsed.
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