Fix 'testSignature' browser tests under nightwatch_local

The `testSignature()` browser test in `generalTests.js` would
occasionally fail due to not obtaining the correct `hash` and
`signature` values from the browser, resulting in:
```
✖ generalTests
   - Simple Contract (40.954s)
   Failed [equal]: ('' == '0: address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c')  - expected "0: address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c" but got: ""
       at Object.<anonymous> (/home/scottt/work/remix-0.8/remix-ide/test-browser/helpers/contracts.js:129:22)
```
failures.

This patch fixes it by waiting for the DOM elements with
`waitForElementPresent` which implicitly retries and obtaining
the correct contract instance address instead of hard coding it.
pull/1/head
Scott Tsai 6 years ago
parent 5785313aa0
commit d0ddd202bc
  1. 2
      src/app/tabs/runTab/settings.js
  2. 2
      test-browser/helpers/contracts.js
  3. 20
      test-browser/tests/generalTests.js

@ -97,7 +97,7 @@ class SettingsUI {
<div class=${css.account}>
<select name="txorigin" class="form-control ${css.select}" id="txorigin"></select>
${copyToClipboard(() => document.querySelector('#runTabView #txorigin').value)}
<i id="remixRunSignMsg" class="fas fa-edit ${css.icon}" aria-hiden="true" onclick=${this.signMessage.bind(this)} title="Sign a message using this account key"></i>
<i id="remixRunSignMsg" class="fas fa-edit ${css.icon}" aria-hidden="true" onclick=${this.signMessage.bind(this)} title="Sign a message using this account key"></i>
</div>
</div>
`

@ -172,7 +172,9 @@ function scrollInto (target) {
function signMsg (browser, msg, cb) {
let hash, signature
browser
.waitForElementPresent('i[id="remixRunSignMsg"]')
.click('i[id="remixRunSignMsg"]')
.waitForElementPresent('textarea[id="prompt_text"]')
.setValue('textarea[id="prompt_text"]', msg, () => {
browser.modalFooterOKClick().perform(
(client, done) => {

@ -34,7 +34,7 @@ function runTests (browser) {
async.waterfall([function (callback) { callback(null, browser) },
testSimpleContract,
testSuccessImport,
testFailedImport, /* testGitHubImport */
testFailedImport, /* testGitHubImport, */
addDeployLibTestFile,
testAutoDeployLib,
testManualDeployLib,
@ -168,22 +168,28 @@ function testSignature (browser, callback) {
contractHelper.signMsg(browser, 'test message', (h, s) => {
hash = h
signature = s
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')
contractHelper.addFile(browser, 'signMassage.sol', sources[6]['browser/signMassage.sol'], () => {
contractHelper.switchFile(browser, 'browser/signMassage.sol', () => {
contractHelper.selectContract(browser, 'ECVerify', () => { // deploy lib
contractHelper.createContract(browser, '', () => {
browser.waitForElementPresent('.instance:nth-of-type(4)')
.click('.instance:nth-of-type(4) > div > button')
.clickFunction('ecrecovery - call', {types: 'bytes32 hash, bytes sig', values: `"${hash.value}","${signature.value}"`}).perform(
const instanceSelector = '.instance:nth-of-type(4)'
browser.waitForElementPresent(instanceSelector)
.click(instanceSelector + ' > div > button')
.getAttribute(instanceSelector, 'id', (result) => {
// skip 'instance' part of e.g. 'instance0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'
const address = result.value.slice('instance'.length)
browser.clickFunction('ecrecovery - call', {types: 'bytes32 hash, bytes sig', values: `"${hash.value}","${signature.value}"`}).perform(
() => {
contractHelper.verifyCallReturnValue(
browser,
'0x08970fed061e7747cd9a38d680a601510cb659fb',
address,
['0: address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'],
() => { callback(null, browser) }
)
}
)
})
})
})
})
})

Loading…
Cancel
Save