Merge pull request #199 from poanetwork/double-fired-events-fix
(Fix) Doubled fired events
This commit is contained in:
commit
f577d693da
|
@ -10329,7 +10329,7 @@
|
|||
}
|
||||
},
|
||||
"eth-contract-metadata": {
|
||||
"version": "github:MetaMask/eth-contract-metadata#2b64863468ff91f64db034b06d55df7009992540",
|
||||
"version": "github:MetaMask/eth-contract-metadata#966a891dd9c79b873fd8968a0155b067ca630502",
|
||||
"from": "github:MetaMask/eth-contract-metadata#master"
|
||||
},
|
||||
"eth-ens-namehash": {
|
||||
|
@ -10398,27 +10398,18 @@
|
|||
}
|
||||
},
|
||||
"eth-json-rpc-filters": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eth-json-rpc-filters/-/eth-json-rpc-filters-3.0.1.tgz",
|
||||
"integrity": "sha512-F/UbtD47UnZDFILYP5GJLklYQ7witEI9TdCLgw0r4iag8ZLzz5h4Q+9odg2ASVZKkm8E50mrb7PaYCK0thVxfw==",
|
||||
"version": "github:poanetwork/eth-json-rpc-filters#22d40ab0103e3b4bc1c35b0818ef674b17fa1e78",
|
||||
"from": "github:poanetwork/eth-json-rpc-filters#3.0.2",
|
||||
"requires": {
|
||||
"await-semaphore": "^0.1.3",
|
||||
"eth-json-rpc-middleware": "^2.6.0",
|
||||
"ethjs-query": "^0.3.8",
|
||||
"fast-deep-equal": "^2.0.1",
|
||||
"json-rpc-engine": "^3.8.0",
|
||||
"lodash.flatmap": "^4.5.0",
|
||||
"safe-event-emitter": "^1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"babelify": {
|
||||
"version": "7.3.0",
|
||||
"resolved": "http://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz",
|
||||
"integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=",
|
||||
"requires": {
|
||||
"babel-core": "^6.0.14",
|
||||
"object-assign": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"eth-json-rpc-middleware": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-2.6.0.tgz",
|
||||
|
@ -10442,30 +10433,19 @@
|
|||
"promise-to-callback": "^1.0.0",
|
||||
"safe-event-emitter": "^1.0.1",
|
||||
"tape": "^4.6.3"
|
||||
}
|
||||
},
|
||||
"eth-sig-util": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
||||
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
|
||||
"requires": {
|
||||
"ethereumjs-util": "^5.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"eth-sig-util": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
||||
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
|
||||
"requires": {
|
||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
|
||||
"ethereumjs-util": "^5.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereumjs-abi": {
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||
"requires": {
|
||||
"bn.js": "^4.10.0",
|
||||
"ethereumjs-util": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ethereumjs-abi": {
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
|
||||
"requires": {
|
||||
"bn.js": "^4.10.0",
|
||||
"ethereumjs-util": "^5.0.0"
|
||||
|
@ -10474,7 +10454,7 @@
|
|||
}
|
||||
},
|
||||
"ethereumjs-abi": {
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||
"requires": {
|
||||
"bn.js": "^4.10.0",
|
||||
|
@ -10514,18 +10494,10 @@
|
|||
"promise-to-callback": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"json-rpc-engine": {
|
||||
"version": "3.8.0",
|
||||
"resolved": "https://registry.npmjs.org/json-rpc-engine/-/json-rpc-engine-3.8.0.tgz",
|
||||
"integrity": "sha512-6QNcvm2gFuuK4TKU1uwfH0Qd/cOSb9c1lls0gbnIhciktIUQJwz6NQNAW4B1KiGPenv7IKu97V222Yo1bNhGuA==",
|
||||
"requires": {
|
||||
"async": "^2.0.1",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"babelify": "^7.3.0",
|
||||
"json-rpc-error": "^2.0.0",
|
||||
"promise-to-callback": "^1.0.0",
|
||||
"safe-event-emitter": "^1.0.1"
|
||||
}
|
||||
"fast-deep-equal": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
|
||||
"integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -10614,7 +10586,7 @@
|
|||
"dependencies": {
|
||||
"ethereumjs-abi": {
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#2863c40e0982acfc0b7163f0285d4c56427c7799",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bn.js": "^4.10.0",
|
||||
|
@ -10666,7 +10638,7 @@
|
|||
"dependencies": {
|
||||
"babelify": {
|
||||
"version": "7.3.0",
|
||||
"resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz",
|
||||
"integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=",
|
||||
"requires": {
|
||||
"babel-core": "^6.0.14",
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
"eth-block-tracker": "^4.0.3",
|
||||
"eth-contract-metadata": "github:MetaMask/eth-contract-metadata#master",
|
||||
"eth-ens-namehash": "^2.0.8",
|
||||
"eth-json-rpc-filters": "^3.0.1",
|
||||
"eth-json-rpc-filters": "github:poanetwork/eth-json-rpc-filters#3.0.2",
|
||||
"eth-json-rpc-infura": "^3.0.0",
|
||||
"eth-keychain-controller": "^5.0.0",
|
||||
"eth-ledger-bridge-keyring": "^0.1.0",
|
||||
|
|
|
@ -46,6 +46,10 @@ module.exports = {
|
|||
},
|
||||
},
|
||||
screens: {
|
||||
eventsEmitter: {
|
||||
button: By.className('btn btn-default'),
|
||||
event: By.className('Toastify__toast-body'),
|
||||
},
|
||||
signMessage: {
|
||||
buttons: {
|
||||
sign: By.css('#app-content > div > div.app-primary.from-right > div > div > div.flex-row.flex-space-around > button:nth-child(2)'),
|
||||
|
@ -161,6 +165,10 @@ module.exports = {
|
|||
button: {
|
||||
submit: By.css('#pending-tx-form > div.flex-row.flex-space-around.conf-buttons > input'),
|
||||
},
|
||||
fields: {
|
||||
gasLimit: By.css('#pending-tx-form > div:nth-child(1) > div.table-box > div:nth-child(3) > div.cell.value > div > div > input'),
|
||||
gasPrice: By.css('#pending-tx-form > div:nth-child(1) > div.table-box > div:nth-child(4) > div.cell.value > div > div > input'),
|
||||
},
|
||||
},
|
||||
sendTransaction: {
|
||||
title: By.css('#app-content > div > div.app-primary.from-right > div > h3:nth-child(2)'),
|
||||
|
@ -233,7 +241,8 @@ module.exports = {
|
|||
menu: By.className('wallet-view__tab-history'),
|
||||
tokens: By.className('activeForm right'),
|
||||
},
|
||||
balance: By.css('#app-content > div > div.app-primary.from-right > div > div > div.flex-row > div.ether-balance.ether-balance-amount > div > div > div:nth-child(1) > div:nth-child(1)'),
|
||||
// balance: By.css('#app-content > div > div.app-primary.from-right > div > div > div.flex-row > div.ether-balance.ether-balance-amount > div > div > div:nth-child(1) > div:nth-child(1)'),
|
||||
balance: By.xpath('//*[@id="app-content"]/div/div[2]/div/div/div[2]/div[1]/div/div/div[1]/div[1]'),
|
||||
address: By.css('#app-content > div > div.app-primary.from-left > div > div > div:nth-child(1) > flex-column > div.flex-row > div'),
|
||||
tokens: {
|
||||
menu: By.id('wallet-view__tab-tokens'),
|
||||
|
|
|
@ -8,7 +8,9 @@ const { By, Key } = webdriver
|
|||
const { delay, buildChromeWebDriver, buildFirefoxWebdriver, installWebExt, getExtensionIdChrome, getExtensionIdFirefox } = require('./func')
|
||||
const { menus, screens, elements, NETWORKS } = require('./elements')
|
||||
const testSeedPhrase = 'juice teach unaware view expand beef divorce spatial evolve rack scheme foster'
|
||||
const account1 = '0x00caA30bb79b3a1CDbdAE146e17e0D7d8710b5EF'
|
||||
const account2 = '0x27836ca9B60E2E1aE13852388edd9a130Be81475'
|
||||
const eventsEmitter = 'https://vbaranov.github.io/event-listener-dapp/'
|
||||
|
||||
describe('Metamask popup page', async function () {
|
||||
let driver, accountAddress, tokenAddress, extensionId
|
||||
|
@ -52,7 +54,7 @@ describe('Metamask popup page', async function () {
|
|||
})
|
||||
|
||||
after(async function () {
|
||||
// await driver.quit()
|
||||
// await driver.quit()
|
||||
})
|
||||
|
||||
describe('Setup', async function () {
|
||||
|
@ -320,11 +322,11 @@ describe('Metamask popup page', async function () {
|
|||
|
||||
it('Auto-detect tokens for POA core network ', async function () {
|
||||
// await setProvider(NETWORKS.POA)
|
||||
const tab = await waitUntilShowUp(screens.main.tokens.menu)
|
||||
await tab.click()
|
||||
const balance = await waitUntilShowUp(screens.main.tokens.balance)
|
||||
console.log(await balance.getText())
|
||||
assert.equal(await balance.getText(), '1 DOPR', 'token isnt\' auto-detected')
|
||||
const tab = await waitUntilShowUp(screens.main.tokens.menu)
|
||||
await tab.click()
|
||||
const balance = await waitUntilShowUp(screens.main.tokens.balance)
|
||||
console.log(await balance.getText())
|
||||
assert.equal(await balance.getText(), '1 DOPR', 'token isnt\' auto-detected')
|
||||
})
|
||||
|
||||
it('Auto-detect tokens for MAIN core network ', async function () {
|
||||
|
@ -481,7 +483,7 @@ describe('Metamask popup page', async function () {
|
|||
|
||||
it('balance renders', async function () {
|
||||
const balance = await waitUntilShowUp(screens.main.balance)
|
||||
assert.equal(await balance.getText(), '100.000')
|
||||
assert.equal(await balance.getText(), '100.000', "balance isn't correct")
|
||||
})
|
||||
|
||||
it('sends transaction', async function () {
|
||||
|
@ -513,6 +515,71 @@ describe('Metamask popup page', async function () {
|
|||
assert.equal(await transactionAmount.getText(), '10.0')
|
||||
})
|
||||
})
|
||||
|
||||
describe(' Check the filter of emitted events', function () {
|
||||
|
||||
it('emit event', async function () {
|
||||
await setProvider(NETWORKS.SOKOL)
|
||||
let account
|
||||
if (process.env.SELENIUM_BROWSER === 'chrome') {
|
||||
account = account1
|
||||
} else if (process.env.SELENIUM_BROWSER === 'firefox') {
|
||||
account = account2
|
||||
const accountMenu = await waitUntilShowUp(menus.account.menu)
|
||||
await accountMenu.click()
|
||||
const item = await waitUntilShowUp(menus.account.account2)
|
||||
await item.click()
|
||||
}
|
||||
|
||||
const balanceField = await waitUntilShowUp(screens.main.balance)
|
||||
await delay(2000)
|
||||
const balance = await balanceField.getText()
|
||||
console.log('Account = ' + account)
|
||||
console.log('Balance = ' + balance)
|
||||
assert.equal(parseInt(balance) > 0.001, true, 'Balance of account ' + account + ' TOO LOW !!! Please refill with Sokol eth!!!!')
|
||||
await driver.get(eventsEmitter)
|
||||
const button = await waitUntilShowUp(screens.eventsEmitter.button)
|
||||
await button.click()
|
||||
await delay(1000)
|
||||
})
|
||||
|
||||
it('confirms transaction in MetaMask popup', async function () {
|
||||
const windowHandles = await driver.getAllWindowHandles()
|
||||
await driver.switchTo().window(windowHandles[windowHandles.length - 1])
|
||||
|
||||
const gasPrice = await waitUntilShowUp(screens.confirmTransaction.fields.gasPrice)
|
||||
await gasPrice.sendKeys('10')
|
||||
const button = await waitUntilShowUp(screens.confirmTransaction.button.submit)
|
||||
await click(button)
|
||||
await delay(5000)
|
||||
})
|
||||
|
||||
it('check number of events', async function () {
|
||||
const windowHandles = await driver.getAllWindowHandles()
|
||||
await driver.switchTo().window(windowHandles[0])
|
||||
const event = await waitUntilShowUp(screens.eventsEmitter.event, 1200)
|
||||
const events = await driver.findElements(screens.eventsEmitter.event)
|
||||
console.log('number of events = ' + events.length)
|
||||
if (!event) console.log("event wasn't created or transaction failed")
|
||||
else {
|
||||
const events = await driver.findElements(screens.eventsEmitter.event)
|
||||
assert.equal(events.length, 1, 'More than 1 event was fired: ' + events.length + ' events')
|
||||
}
|
||||
})
|
||||
|
||||
it('open app', async function () {
|
||||
if (process.env.SELENIUM_BROWSER === 'chrome') {
|
||||
await driver.get(`chrome-extension://${extensionId}/popup.html`)
|
||||
} else if (process.env.SELENIUM_BROWSER === 'firefox') {
|
||||
await driver.get(`moz-extension://${extensionId}/popup.html`)
|
||||
const accountMenu = await waitUntilShowUp(menus.account.menu)
|
||||
await accountMenu.click()
|
||||
const item = await waitUntilShowUp(menus.account.account1)
|
||||
await item.click()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('Add Token: Custom', function () {
|
||||
const symbol = 'TST'
|
||||
const decimals = '0'
|
||||
|
@ -542,7 +609,6 @@ describe('Metamask popup page', async function () {
|
|||
await tokenSymbol.sendKeys('TST')
|
||||
await click(createToken)
|
||||
await delay(1000)
|
||||
|
||||
})
|
||||
|
||||
it('confirms transaction in MetaMask popup', async function () {
|
||||
|
|
Loading…
Reference in New Issue