From 7810880f0c96ff8628cfd87bf7e6cb8145bb147a Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 12 Sep 2017 12:23:21 -0700 Subject: [PATCH 01/30] Add specific error message for failed address checksum. --- ui/app/send.js | 5 +++++ ui/app/util.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/ui/app/send.js b/ui/app/send.js index a21a219eb..e59c1130e 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -262,6 +262,11 @@ SendTransactionScreen.prototype.onSubmit = function () { return this.props.dispatch(actions.displayWarning(message)) } + if ((util.isInvalidChecksumAddress(recipient))) { + message = 'Recipient address checksum is invalid.' + return this.props.dispatch(actions.displayWarning(message)) + } + if ((!util.isValidAddress(recipient) && !txData) || (!recipient && !txData)) { message = 'Recipient address is invalid.' return this.props.dispatch(actions.displayWarning(message)) diff --git a/ui/app/util.js b/ui/app/util.js index 1368ebf11..860a17224 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -37,6 +37,7 @@ module.exports = { bnTable: bnTable, isHex: isHex, exportAsFile: exportAsFile, + isInvalidChecksumAddress, } function valuesFor (obj) { @@ -66,6 +67,12 @@ function isValidAddress (address) { return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed) } +function isInvalidChecksumAddress (address) { + var prefixed = ethUtil.addHexPrefix(address) + if (address === '0x0000000000000000000000000000000000000000') return false + return ethUtil.isValidAddress(prefixed) && !ethUtil.isValidChecksumAddress(prefixed) +} + function isAllOneCase (address) { if (!address) return true var lower = address.toLowerCase() From 243be92ac165d028d532a02f5b32ff9edc526f23 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 12 Sep 2017 12:24:02 -0700 Subject: [PATCH 02/30] Changelogaroo. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89eaefa79..54ddb4a1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Add ability to export private keys as a file. - Add ability to export seed words as a file. - Changed state logs to a file download than a clipboard copy. +- Add specific error for failed recipient address checksum. ## 3.10.0 2017-9-11 From ef6967325e43de26edc0d99ac5853804648024ae Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 12 Sep 2017 12:52:13 -0700 Subject: [PATCH 03/30] Check if all lower or upper before doing checksum. --- ui/app/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/util.js b/ui/app/util.js index 860a17224..3f8b4dcc3 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -70,7 +70,7 @@ function isValidAddress (address) { function isInvalidChecksumAddress (address) { var prefixed = ethUtil.addHexPrefix(address) if (address === '0x0000000000000000000000000000000000000000') return false - return ethUtil.isValidAddress(prefixed) && !ethUtil.isValidChecksumAddress(prefixed) + return !isAllOneCase(prefixed) && !ethUtil.isValidChecksumAddress(prefixed) && ethUtil.isValidAddress(prefixed) } function isAllOneCase (address) { From 962794d0257da705b2424351b7a187ccd4ec76ea Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 12 Sep 2017 16:15:56 -0700 Subject: [PATCH 04/30] fixed position of tooltips to avoid overflow. --- ui/app/components/tooltip.js | 2 +- ui/app/components/transaction-list-item-icon.js | 2 +- ui/app/components/transaction-list-item.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/app/components/tooltip.js b/ui/app/components/tooltip.js index edbc074bb..efab2c497 100644 --- a/ui/app/components/tooltip.js +++ b/ui/app/components/tooltip.js @@ -17,6 +17,6 @@ Tooltip.prototype.render = function () { return h(ReactTooltip, { position: position || 'left', title, - fixed: false, + fixed: true, }, children) } diff --git a/ui/app/components/transaction-list-item-icon.js b/ui/app/components/transaction-list-item-icon.js index 431054340..f442b05af 100644 --- a/ui/app/components/transaction-list-item-icon.js +++ b/ui/app/components/transaction-list-item-icon.js @@ -35,7 +35,7 @@ TransactionIcon.prototype.render = function () { case 'submitted': return h(Tooltip, { title: 'Pending', - position: 'bottom', + position: 'right', }, [ h('i.fa.fa-ellipsis-h', { style: { diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js index 5d5d0bcc5..0e5c0b5a3 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -65,7 +65,7 @@ TransactionListItem.prototype.render = function () { h(Tooltip, { title: 'Transaction Number', - position: 'bottom', + position: 'right', }, [ h('span', { style: { From 5305d414b5901ff68ee58a3eca182af9c69debb0 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 12 Sep 2017 16:16:29 -0700 Subject: [PATCH 05/30] changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f30c04985..4fb81c350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Add ability to export seed words as a file. - Changed state logs to a file download than a clipboard copy. - Fix link to support center. +- Fixed tooltip icon locations to avoid overflow. ## 3.10.0 2017-9-11 From 06153dd47d16c2e3c6eed7470501d7534c29cbd4 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 13 Sep 2017 12:17:42 -0700 Subject: [PATCH 06/30] Add warning of higher failure risk since app proposed gasLimit. --- ui/app/components/pending-tx.js | 64 ++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 3e53d47f9..37b242728 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -52,7 +52,8 @@ PendingTx.prototype.render = function () { const gas = txParams.gas const gasBn = hexToBn(gas) const gasLimit = new BN(parseInt(blockGasLimit)) - const safeGasLimit = this.bnMultiplyByFraction(gasLimit, 19, 20).toString(10) + const safeGasLimitBN = this.bnMultiplyByFraction(gasLimit, 19, 20) + const safeGasLimit = safeGasLimitBN.toString(10) // Gas Price const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16) @@ -66,6 +67,8 @@ PendingTx.prototype.render = function () { const balanceBn = hexToBn(balance) const insufficientBalance = balanceBn.lt(maxCost) + const dangerousGasLimit = gasBn.gte(safeGasLimitBN) + const gasLimitSpecified = txMeta.gasLimitSpecified const buyDisabled = insufficientBalance || !this.state.valid || !isValidAddress || this.state.submitting const showRejectAll = props.unconfTxListLength > 1 @@ -263,33 +266,44 @@ PendingTx.prototype.render = function () { text-transform: uppercase; } `), + h('.cell.row', { + style: { + textAlign: 'center', + }, + }, [ + txMeta.simulationFails ? + h('.error', { + style: { + fontSize: '0.9em', + }, + }, 'Transaction Error. Exception thrown in contract code.') + : null, - txMeta.simulationFails ? - h('.error', { - style: { - marginLeft: 50, - fontSize: '0.9em', - }, - }, 'Transaction Error. Exception thrown in contract code.') - : null, + !isValidAddress ? + h('.error', { + style: { + fontSize: '0.9em', + }, + }, 'Recipient address is invalid. Sending this transaction will result in a loss of ETH.') + : null, - !isValidAddress ? - h('.error', { - style: { - marginLeft: 50, - fontSize: '0.9em', - }, - }, 'Recipient address is invalid. Sending this transaction will result in a loss of ETH.') - : null, + insufficientBalance ? + h('span.error', { + style: { + fontSize: '0.9em', + }, + }, 'Insufficient balance for transaction') + : null, + + (dangerousGasLimit && gasLimitSpecified) ? + h('span.error', { + style: { + fontSize: '0.9em', + }, + }, 'Gas limit set dangerously high. Approving this transaction is likely to fail.') + : null, + ]), - insufficientBalance ? - h('span.error', { - style: { - marginLeft: 50, - fontSize: '0.9em', - }, - }, 'Insufficient balance for transaction') - : null, // send + cancel h('.flex-row.flex-space-around.conf-buttons', { From 6e725b123b878da12494904b121237ee41af7f76 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 13 Sep 2017 12:22:08 -0700 Subject: [PATCH 07/30] Lower warning threshold for high tx fee to account for fluctuating blockGasLimits --- ui/app/components/pending-tx.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 37b242728..ec2b15de4 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -53,6 +53,7 @@ PendingTx.prototype.render = function () { const gasBn = hexToBn(gas) const gasLimit = new BN(parseInt(blockGasLimit)) const safeGasLimitBN = this.bnMultiplyByFraction(gasLimit, 19, 20) + const saferGasLimitBN = this.bnMultiplyByFraction(gasLimit, 18, 20) const safeGasLimit = safeGasLimitBN.toString(10) // Gas Price @@ -67,7 +68,7 @@ PendingTx.prototype.render = function () { const balanceBn = hexToBn(balance) const insufficientBalance = balanceBn.lt(maxCost) - const dangerousGasLimit = gasBn.gte(safeGasLimitBN) + const dangerousGasLimit = gasBn.gte(saferGasLimitBN) const gasLimitSpecified = txMeta.gasLimitSpecified const buyDisabled = insufficientBalance || !this.state.valid || !isValidAddress || this.state.submitting const showRejectAll = props.unconfTxListLength > 1 From 3d36d565afe908ca7c4424ff8a7d3659d0978aca Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 13 Sep 2017 12:26:24 -0700 Subject: [PATCH 08/30] Bump changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f30c04985..6f357c92c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Add ability to export seed words as a file. - Changed state logs to a file download than a clipboard copy. - Fix link to support center. +- Warn users when a dapp proposes a high gas limit (90% of blockGasLimit or higher) ## 3.10.0 2017-9-11 From a22a2586abcca35d2a4bc1a0407aeaacc55f0a27 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 13 Sep 2017 13:24:16 -0700 Subject: [PATCH 09/30] Haha silly me, only when gas is estimated and not explicit. --- ui/app/components/pending-tx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index ec2b15de4..c3350fcc1 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -296,7 +296,7 @@ PendingTx.prototype.render = function () { }, 'Insufficient balance for transaction') : null, - (dangerousGasLimit && gasLimitSpecified) ? + (dangerousGasLimit && !gasLimitSpecified) ? h('span.error', { style: { fontSize: '0.9em', From dd90e8e364a7023431be081d293d10129b76422c Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Sep 2017 16:04:48 -0700 Subject: [PATCH 10/30] tests - break out coveralls npm script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 12f79ba35..d618983bd 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "test-unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"", "single-test": "METAMASK_ENV=test mocha --require test/helper.js", "test-integration": "npm run buildMock && npm run buildCiUnits && karma start", - "test-coverage": "nyc npm run test-unit && if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", + "test-coverage": "nyc npm run test-unit && npm run coveralls-upload", + "coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", "ci": "npm run lint && npm run test-coverage && npm run test-integration", "lint": "gulp lint", "buildCiUnits": "node test/integration/index.js", From 56db3999adeaec1733218173b260bf74fa63ccbe Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Sep 2017 16:45:31 -0700 Subject: [PATCH 11/30] tests - start migrating mascara tests to karma --- mascara/src/ui.js | 9 +++++++-- mascara/test/test-ui.js | 13 +++++++++++++ mascara/test/window-load.js | 5 ----- mock-dev.js | 1 - package.json | 11 ++++++----- karma.conf.js => test/base.conf.js | 6 ++---- test/mascara.conf.js | 14 ++++++++++++++ test/together.conf.js | 8 ++++++++ 8 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 mascara/test/test-ui.js delete mode 100644 mascara/test/window-load.js rename karma.conf.js => test/base.conf.js (95%) create mode 100644 test/mascara.conf.js create mode 100644 test/together.conf.js diff --git a/mascara/src/ui.js b/mascara/src/ui.js index 5f9be542f..5662270c1 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -44,13 +44,18 @@ background.on('ready', (sw) => { background.removeListener('updatefound', connectApp) connectApp(sw) }) -background.on('updatefound', () => window.location.reload()) +background.on('updatefound', windowReload) background.startWorker() .then(() => { setTimeout(() => { const appContent = document.getElementById(`app-content`) - if (!appContent.children.length) window.location.reload() + if (!appContent.children.length) windowReload() }, 2000) }) console.log('hello from MetaMascara ui!') + +function windowReload() { + if (window.METAMASK_SKIP_RELOAD) return + window.location.reload() +} diff --git a/mascara/test/test-ui.js b/mascara/test/test-ui.js new file mode 100644 index 000000000..ebeffe8cb --- /dev/null +++ b/mascara/test/test-ui.js @@ -0,0 +1,13 @@ +const Helper = require('./util/mascara-test-helper.js') + +window.METAMASK_SKIP_RELOAD = true +window.addEventListener('load', () => { + // inject app container + const body = document.body + const container = document.createElement('div') + container.id = 'app-content' + body.appendChild(container) + + // start ui + require('../src/ui.js') +}) diff --git a/mascara/test/window-load.js b/mascara/test/window-load.js deleted file mode 100644 index d3f44f05f..000000000 --- a/mascara/test/window-load.js +++ /dev/null @@ -1,5 +0,0 @@ -const Helper = require('./util/mascara-test-helper.js') - -window.addEventListener('load', () => { - require('../src/ui.js') -}) diff --git a/mock-dev.js b/mock-dev.js index b6652bdf7..452fe37c5 100644 --- a/mock-dev.js +++ b/mock-dev.js @@ -96,7 +96,6 @@ function startApp(){ const container = document.createElement('div') container.id = 'app-content' body.appendChild(container) - console.log('container', container) render( h('.super-dev-container', [ diff --git a/package.json b/package.json index d618983bd..8ba6e16cb 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "test": "npm run lint && npm run test-unit && npm run test-integration", "test-unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"", "single-test": "METAMASK_ENV=test mocha --require test/helper.js", - "test-integration": "npm run buildMock && npm run buildCiUnits && karma start", + "test-integration": "npm run buildMock && npm run buildCiUnits && karma start test/together.conf.js", "test-coverage": "nyc npm run test-unit && npm run coveralls-upload", "coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", "ci": "npm run lint && npm run test-coverage && npm run test-integration", @@ -27,10 +27,11 @@ "generateNotice": "node notices/notice-generator.js", "deleteNotice": "node notices/notice-delete.js", "mascara": "node ./mascara/example/server", - "buildMascaraCi": "browserify mascara/test/window-load.js -o mascara/test/bundle.js", - "buildMascaraSWCi": "browserify mascara/src/background.js -o mascara/test/background.js", - "mascaraCi": "npm run buildMascaraCi && npm run buildMascaraSWCi && node mascara/test/index.js", - "testMascara": "cd mascara/test && npm run mascaraCi && testem ci -P 3" + "testMascara": "npm run buildMascara && karma start test/mascara.conf.js", + "buildMascara": "npm run buildMascaraUi && npm run buildMascaraBackground && npm run buildMascaraTests", + "buildMascaraUi": "browserify mascara/test/test-ui.js -o mascara/test/ui-bundle.js", + "buildMascaraBackground": "browserify mascara/src/background.js -o mascara/test/background.js", + "buildMascaraTests": "browserify test/integration/lib/first-time.js -o mascara/test/test-bundle.js" }, "browserify": { "transform": [ diff --git a/karma.conf.js b/test/base.conf.js similarity index 95% rename from karma.conf.js rename to test/base.conf.js index 8e6d55972..122392822 100644 --- a/karma.conf.js +++ b/test/base.conf.js @@ -2,7 +2,7 @@ // Generated on Mon Sep 11 2017 18:45:48 GMT-0700 (PDT) module.exports = function(config) { - config.set({ + return { // base path that will be used to resolve all patterns (eg. files, exclude) basePath: process.cwd(), @@ -16,9 +16,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'development/bundle.js', 'test/integration/jquery-3.1.0.min.js', - 'test/integration/bundle.js', { pattern: 'dist/chrome/images/**/*.*', watched: false, included: false, served: true }, { pattern: 'dist/chrome/fonts/**/*.*', watched: false, included: false, served: true }, ], @@ -57,5 +55,5 @@ module.exports = function(config) { // Concurrency level // how many browser should be started simultaneous concurrency: Infinity - }) + } } diff --git a/test/mascara.conf.js b/test/mascara.conf.js new file mode 100644 index 000000000..8e8fa2cdf --- /dev/null +++ b/test/mascara.conf.js @@ -0,0 +1,14 @@ +const getBaseConfig = require('./base.conf.js') + +module.exports = function(config) { + const settings = getBaseConfig(config) + settings.files.push('mascara/test/ui-bundle.js') + settings.files.push('mascara/test/test-bundle.js') + // settings.files.push('test/integration/bundle.js') + settings.files.push({ pattern: 'mascara/test/background.js', watched: false, included: false, served: true }), + // /background.js + + settings.proxies['/background.js'] = '/base/mascara/test/background.js' + + config.set(settings) +} diff --git a/test/together.conf.js b/test/together.conf.js new file mode 100644 index 000000000..cd2dbdcdc --- /dev/null +++ b/test/together.conf.js @@ -0,0 +1,8 @@ +const getBaseConfig = require('./base.conf.js') + +module.exports = function(config) { + const settings = getBaseConfig(config) + settings.files.push('development/bundle.js') + settings.files.push('test/integration/bundle.js') + config.set(settings) +} From cbff5fd450ac0a55a9ef7b48b0ce540b66dfca6b Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Sep 2017 16:52:38 -0700 Subject: [PATCH 12/30] tests - mascara - move temp build files into dist/mascara --- package.json | 8 ++++---- test/mascara.conf.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 8ba6e16cb..c4a19a52c 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,10 @@ "deleteNotice": "node notices/notice-delete.js", "mascara": "node ./mascara/example/server", "testMascara": "npm run buildMascara && karma start test/mascara.conf.js", - "buildMascara": "npm run buildMascaraUi && npm run buildMascaraBackground && npm run buildMascaraTests", - "buildMascaraUi": "browserify mascara/test/test-ui.js -o mascara/test/ui-bundle.js", - "buildMascaraBackground": "browserify mascara/src/background.js -o mascara/test/background.js", - "buildMascaraTests": "browserify test/integration/lib/first-time.js -o mascara/test/test-bundle.js" + "buildMascara": "mkdir -p dist/mascara && npm run buildMascaraUi && npm run buildMascaraBackground && npm run buildMascaraTests", + "buildMascaraUi": "browserify mascara/test/test-ui.js -o dist/mascara/ui.js", + "buildMascaraBackground": "browserify mascara/src/background.js -o dist/mascara/background.js", + "buildMascaraTests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js" }, "browserify": { "transform": [ diff --git a/test/mascara.conf.js b/test/mascara.conf.js index 8e8fa2cdf..b4ec5846f 100644 --- a/test/mascara.conf.js +++ b/test/mascara.conf.js @@ -2,13 +2,13 @@ const getBaseConfig = require('./base.conf.js') module.exports = function(config) { const settings = getBaseConfig(config) - settings.files.push('mascara/test/ui-bundle.js') - settings.files.push('mascara/test/test-bundle.js') - // settings.files.push('test/integration/bundle.js') - settings.files.push({ pattern: 'mascara/test/background.js', watched: false, included: false, served: true }), - // /background.js - settings.proxies['/background.js'] = '/base/mascara/test/background.js' + // ui and tests + settings.files.push('dist/mascara/ui.js') + settings.files.push('dist/mascara/tests.js') + // service worker background + settings.files.push({ pattern: 'dist/mascara/background.js', watched: false, included: false, served: true }), + settings.proxies['/background.js'] = '/base/dist/mascara/background.js' config.set(settings) } From 610f09262d8686cf975b25ffb6e2b5371e3d55c0 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Sep 2017 17:17:09 -0700 Subject: [PATCH 13/30] tests - refactor and rename npm scripts --- circle.yml | 2 +- package.json | 47 +++++++++++++------------ test/{together.conf.js => flat.conf.js} | 0 3 files changed, 25 insertions(+), 24 deletions(-) rename test/{together.conf.js => flat.conf.js} (100%) diff --git a/circle.yml b/circle.yml index f5da6857d..6aba5c1be 100644 --- a/circle.yml +++ b/circle.yml @@ -3,7 +3,7 @@ machine: version: 8.1.4 test: override: - - "npm run ci" + - "npm test" dependencies: pre: - sudo apt-get update diff --git a/package.json b/package.json index c4a19a52c..7a022d47a 100644 --- a/package.json +++ b/package.json @@ -6,32 +6,33 @@ "scripts": { "start": "npm run dev", "dev": "gulp dev --debug", - "disc": "gulp disc --debug", - "clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/eth-phishing-detect", - "dist": "npm run clear && npm install && gulp dist", - "test": "npm run lint && npm run test-unit && npm run test-integration", - "test-unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"", - "single-test": "METAMASK_ENV=test mocha --require test/helper.js", - "test-integration": "npm run buildMock && npm run buildCiUnits && karma start test/together.conf.js", - "test-coverage": "nyc npm run test-unit && npm run coveralls-upload", - "coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", - "ci": "npm run lint && npm run test-coverage && npm run test-integration", - "lint": "gulp lint", - "buildCiUnits": "node test/integration/index.js", - "watch": "mocha watch --recursive \"test/unit/**/*.js\"", - "genStates": "node development/genStates.js", - "ui": "npm run genStates && beefy ui-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", + "ui": "npm run test:flat:build:states && beefy ui-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", "mock": "beefy mock-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", - "buildMock": "npm run genStates && browserify ./mock-dev.js -o ./development/bundle.js", + "watch": "mocha watch --recursive \"test/unit/**/*.js\"", + "mascara": "node ./mascara/example/server", + "dist": "npm run dist:clear && npm install && gulp dist", + "dist:clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/eth-phishing-detect", + "test": "npm run lint && npm run test:coverage && npm run test:integration", + "test:unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"", + "test:single": "METAMASK_ENV=test mocha --require test/helper.js", + "test:integration": "npm run test:flat", + "test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload", + "test:coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", + "test:flat": "npm run test:flat:build && karma start test/flat.conf.js", + "test:flat:build": "npm run test:flat:build:ui && npm run test:flat:build:tests", + "test:flat:build:tests": "node test/integration/index.js", + "test:flat:build:states": "node development/genStates.js", + "test:flat:build:ui": "npm run test:flat:build:states && browserify ./mock-dev.js -o ./development/bundle.js", + "test:mascara": "npm run test:mascara:build && karma start test/mascara.conf.js", + "test:mascara:build": "mkdir -p dist/mascara && npm run test:mascara:build:ui && npm run test:mascara:build:background && npm run test:mascara:build:tests", + "test:mascara:build:ui": "browserify mascara/test/test-ui.js -o dist/mascara/ui.js", + "test:mascara:build:background": "browserify mascara/src/background.js -o dist/mascara/background.js", + "test:mascara:build:tests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js", + "lint": "gulp lint", + "disc": "gulp disc --debug", "announce": "node development/announcer.js", "generateNotice": "node notices/notice-generator.js", - "deleteNotice": "node notices/notice-delete.js", - "mascara": "node ./mascara/example/server", - "testMascara": "npm run buildMascara && karma start test/mascara.conf.js", - "buildMascara": "mkdir -p dist/mascara && npm run buildMascaraUi && npm run buildMascaraBackground && npm run buildMascaraTests", - "buildMascaraUi": "browserify mascara/test/test-ui.js -o dist/mascara/ui.js", - "buildMascaraBackground": "browserify mascara/src/background.js -o dist/mascara/background.js", - "buildMascaraTests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js" + "deleteNotice": "node notices/notice-delete.js" }, "browserify": { "transform": [ diff --git a/test/together.conf.js b/test/flat.conf.js similarity index 100% rename from test/together.conf.js rename to test/flat.conf.js From b53d04c40975adc0fadf20bc6ca875bd9c39e595 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Sep 2017 20:25:27 -0700 Subject: [PATCH 14/30] tests - integration - get flat and mascara tests closer to compatible --- development/index.html | 4 +- development/test.html | 5 +- mascara/src/ui.js | 8 +- mascara/test/lib/first-time.js | 119 ----------------------------- mascara/test/test-ui.js | 1 - mock-dev.js | 4 +- test/integration/lib/first-time.js | 12 +-- test/mascara.conf.js | 3 + ui-dev.js | 4 +- 9 files changed, 18 insertions(+), 142 deletions(-) delete mode 100644 mascara/test/lib/first-time.js diff --git a/development/index.html b/development/index.html index 048aa3f35..a0814cb55 100644 --- a/development/index.html +++ b/development/index.html @@ -14,13 +14,13 @@ diff --git a/development/test.html b/development/test.html index 702be7fa0..49084c0a4 100644 --- a/development/test.html +++ b/development/test.html @@ -18,13 +18,14 @@ diff --git a/mascara/src/ui.js b/mascara/src/ui.js index 5662270c1..7506532d2 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -2,8 +2,6 @@ const injectCss = require('inject-css') const SWcontroller = require('client-sw-ready-event/lib/sw-client.js') const SwStream = require('sw-stream/lib/sw-stream.js') const MetaMaskUiCss = require('../../ui/css') -const setupIframe = require('./lib/setup-iframe.js') -const MetamaskInpageProvider = require('../../app/scripts/lib/inpage-provider.js') const MetamascaraPlatform = require('../../app/scripts/platforms/window') const startPopup = require('../../app/scripts/popup-core') @@ -32,7 +30,7 @@ const connectApp = function (readSw) { serviceWorker: background.controller, context: name, }) - startPopup({container, connectionStream}, (err, store) => { + startPopup({ container, connectionStream }, (err, store) => { if (err) return displayCriticalError(err) store.subscribe(() => { const state = store.getState() @@ -49,8 +47,8 @@ background.on('updatefound', windowReload) background.startWorker() .then(() => { setTimeout(() => { - const appContent = document.getElementById(`app-content`) - if (!appContent.children.length) windowReload() + const container = document.getElementById(`app-content`) + if (!container.children.length) windowReload() }, 2000) }) console.log('hello from MetaMascara ui!') diff --git a/mascara/test/lib/first-time.js b/mascara/test/lib/first-time.js deleted file mode 100644 index e42c9e39d..000000000 --- a/mascara/test/lib/first-time.js +++ /dev/null @@ -1,119 +0,0 @@ -const PASSWORD = 'password123' - -QUnit.module('first time usage') - -QUnit.test('render init screen', function (assert) { - var done = assert.async() - let app - - wait(1000).then(function() { - app = $('#app-content').contents() - const recurseNotices = function () { - let button = app.find('button') - if (button.html() === 'Accept') { - let termsPage = app.find('.markdown')[0] - termsPage.scrollTop = termsPage.scrollHeight - return wait().then(() => { - button.click() - return wait() - }).then(() => { - return recurseNotices() - }) - } else { - return wait() - } - } - return recurseNotices() - }).then(function() { - // Scroll through terms - var title = app.find('h1').text() - assert.equal(title, 'MetaMask', 'title screen') - - // enter password - var pwBox = app.find('#password-box')[0] - var confBox = app.find('#password-box-confirm')[0] - pwBox.value = PASSWORD - confBox.value = PASSWORD - - return wait() - }).then(function() { - - // create vault - var createButton = app.find('button.primary')[0] - createButton.click() - - return wait(1500) - }).then(function() { - - var created = app.find('h3')[0] - assert.equal(created.textContent, 'Vault Created', 'Vault created screen') - - // Agree button - var button = app.find('button')[0] - assert.ok(button, 'button present') - button.click() - - return wait(1000) - }).then(function() { - - var detail = app.find('.account-detail-section')[0] - assert.ok(detail, 'Account detail section loaded.') - - var sandwich = app.find('.sandwich-expando')[0] - sandwich.click() - - return wait() - }).then(function() { - - var sandwich = app.find('.menu-droppo')[0] - var children = sandwich.children - var lock = children[children.length - 2] - assert.ok(lock, 'Lock menu item found') - lock.click() - - return wait(1000) - }).then(function() { - - var pwBox = app.find('#password-box')[0] - pwBox.value = PASSWORD - - var createButton = app.find('button.primary')[0] - createButton.click() - - return wait(1000) - }).then(function() { - - var detail = app.find('.account-detail-section')[0] - assert.ok(detail, 'Account detail section loaded again.') - - return wait() - }).then(function (){ - - var qrButton = app.find('.fa.fa-qrcode')[0] - qrButton.click() - - return wait(1000) - }).then(function (){ - - var qrHeader = app.find('.qr-header')[0] - var qrContainer = app.find('#qr-container')[0] - assert.equal(qrHeader.textContent, 'Account 1', 'Should show account label.') - assert.ok(qrContainer, 'QR Container found') - - return wait() - }).then(function (){ - - var networkMenu = app.find('.network-indicator')[0] - networkMenu.click() - - return wait() - }).then(function (){ - - var networkMenu = app.find('.network-indicator')[0] - var children = networkMenu.children - children.length[3] - assert.ok(children, 'All network options present') - - done() - }) -}) diff --git a/mascara/test/test-ui.js b/mascara/test/test-ui.js index ebeffe8cb..201eec601 100644 --- a/mascara/test/test-ui.js +++ b/mascara/test/test-ui.js @@ -7,7 +7,6 @@ window.addEventListener('load', () => { const container = document.createElement('div') container.id = 'app-content' body.appendChild(container) - // start ui require('../src/ui.js') }) diff --git a/mock-dev.js b/mock-dev.js index 452fe37c5..a47f1ed4d 100644 --- a/mock-dev.js +++ b/mock-dev.js @@ -94,7 +94,7 @@ startApp() function startApp(){ const body = document.body const container = document.createElement('div') - container.id = 'app-content' + container.id = 'test-container' body.appendChild(container) render( @@ -112,7 +112,7 @@ function startApp(){ h(Selector, { actions, selectedKey: selectedView, states, store }), - h('.mock-app-root', { + h('#app-content', { style: { height: '500px', width: '360px', diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index 38a94e551..e023351bc 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -10,19 +10,11 @@ QUnit.test('render init screen', (assert) => { }) }) -// QUnit.testDone(({ module, name, total, passed, failed, skipped, todo, runtime }) => { -// if (failed > 0) { -// const app = $('iframe').contents()[0].documentElement -// console.warn('Test failures - dumping DOM:') -// console.log(app.innerHTML) -// } -// }) - async function runFirstTimeUsageTest(assert, done) { await timeout() - const app = $('#app-content .mock-app-root') + const app = $('#app-content') // recurse notices while (true) { @@ -32,10 +24,12 @@ async function runFirstTimeUsageTest(assert, done) { const termsPage = app.find('.markdown')[0] termsPage.scrollTop = termsPage.scrollHeight await timeout() + console.log('Clearing notice') button.click() await timeout() } else { // exit loop + console.log('No more notices...') break } } diff --git a/test/mascara.conf.js b/test/mascara.conf.js index b4ec5846f..97e53fc2b 100644 --- a/test/mascara.conf.js +++ b/test/mascara.conf.js @@ -10,5 +10,8 @@ module.exports = function(config) { settings.files.push({ pattern: 'dist/mascara/background.js', watched: false, included: false, served: true }), settings.proxies['/background.js'] = '/base/dist/mascara/background.js' + // use this to keep the browser open for debugging + settings.browserNoActivityTimeout = 10000000 + config.set(settings) } diff --git a/ui-dev.js b/ui-dev.js index 367b5d546..de5dfd8ef 100644 --- a/ui-dev.js +++ b/ui-dev.js @@ -61,7 +61,7 @@ const actions = { var css = MetaMaskUiCss() injectCss(css) -const container = document.querySelector('#app-content') +const container = document.querySelector('#test-container') // parse opts var store = configureStore(states[selectedView]) @@ -72,7 +72,7 @@ render( h(Selector, { actions, selectedKey: selectedView, states, store }), - h('.mock-app-root', { + h('#app-content', { style: { height: '500px', width: '360px', From 7fb862356873fc4c5dc28e5c7389f71424985b0f Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 15 Sep 2017 11:09:19 -0700 Subject: [PATCH 15/30] dont reload on initial download and wait before passing sw to ui --- mascara/src/ui.js | 41 +++++++++++++++++++----------- mascara/test/test-ui.js | 1 - test/integration/lib/first-time.js | 4 +-- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/mascara/src/ui.js b/mascara/src/ui.js index 7506532d2..05521d095 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -30,30 +30,41 @@ const connectApp = function (readSw) { serviceWorker: background.controller, context: name, }) - startPopup({ container, connectionStream }, (err, store) => { - if (err) return displayCriticalError(err) - store.subscribe(() => { - const state = store.getState() - if (state.appState.shouldClose) window.close() + return new Promise((resolve, reject) => { + startPopup({ container, connectionStream }, (err, store) => { + console.log('hello from MetaMascara ui!') + if (err) reject(err) + store.subscribe(() => { + const state = store.getState() + if (state.appState.shouldClose) window.close() + }) + resolve() }) }) } -background.on('ready', (sw) => { - background.removeListener('updatefound', connectApp) - connectApp(sw) +background.on('ready', async (sw) => { + try { + background.removeListener('updatefound', connectApp) + await timeout(1000) + await connectApp(sw) + console.log('hello from cb ready event!') + } catch (e) { + console.error(e) + } }) background.on('updatefound', windowReload) background.startWorker() -.then(() => { - setTimeout(() => { - const container = document.getElementById(`app-content`) - if (!container.children.length) windowReload() - }, 2000) -}) -console.log('hello from MetaMascara ui!') function windowReload() { if (window.METAMASK_SKIP_RELOAD) return window.location.reload() } + +function timeout (time) { + return new Promise(function (resolve, reject) { + setTimeout(function () { + resolve() + }, time || 1500) + }) +} \ No newline at end of file diff --git a/mascara/test/test-ui.js b/mascara/test/test-ui.js index 201eec601..bf27338d9 100644 --- a/mascara/test/test-ui.js +++ b/mascara/test/test-ui.js @@ -1,6 +1,5 @@ const Helper = require('./util/mascara-test-helper.js') -window.METAMASK_SKIP_RELOAD = true window.addEventListener('load', () => { // inject app container const body = document.body diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index e023351bc..4140dfd78 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -12,7 +12,7 @@ QUnit.test('render init screen', (assert) => { async function runFirstTimeUsageTest(assert, done) { - await timeout() + await timeout(10000) const app = $('#app-content') @@ -123,7 +123,7 @@ async function runFirstTimeUsageTest(assert, done) { assert.ok(children2, 'All network options present') } -function timeout(time) { +function timeout (time) { return new Promise(function (resolve, reject) { setTimeout(function () { resolve() From 7bcca782cbea545fedabf33d73311c0e361690c2 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 15 Sep 2017 11:10:52 -0700 Subject: [PATCH 16/30] remove testem files --- mascara/test/index.html | 21 --------------------- mascara/test/testem.yml | 13 ------------- test/integration/lib/first-time.js | 2 +- 3 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 mascara/test/index.html delete mode 100644 mascara/test/testem.yml diff --git a/mascara/test/index.html b/mascara/test/index.html deleted file mode 100644 index 6495c2cfc..000000000 --- a/mascara/test/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - QUnit Example - - - -
-
- - - - - - -
- - - diff --git a/mascara/test/testem.yml b/mascara/test/testem.yml deleted file mode 100644 index f1f5844bd..000000000 --- a/mascara/test/testem.yml +++ /dev/null @@ -1,13 +0,0 @@ -launch_in_dev: - - Chrome - - Firefox - - Opera -launch_in_ci: - - Chrome - - Firefox - - Opera -framework: - - qunit -before_tests: "npm run mascaraCi" -after_tests: "rm ./background.js ./test-bundle.js ./bundle.js" -test_page: "./index.html" diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index 4140dfd78..3f0fe165b 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -12,7 +12,7 @@ QUnit.test('render init screen', (assert) => { async function runFirstTimeUsageTest(assert, done) { - await timeout(10000) + await timeout() const app = $('#app-content') From c5a2527c17f9c7f47645dc4d99694645d1985022 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 15 Sep 2017 11:33:37 -0700 Subject: [PATCH 17/30] set time if platform is mascara --- mascara/src/ui.js | 1 + test/integration/lib/first-time.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mascara/src/ui.js b/mascara/src/ui.js index 05521d095..d70dca724 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -15,6 +15,7 @@ const container = document.getElementById('app-content') var name = 'popup' window.METAMASK_UI_TYPE = name +window.METAMASK_PLATFORM_TYPE = 'mascara' let intervalDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000 diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index 3f0fe165b..e84a51c64 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -11,8 +11,10 @@ QUnit.test('render init screen', (assert) => { }) async function runFirstTimeUsageTest(assert, done) { - - await timeout() + let waitTime = 0 + window.METAMASK_SKIP_RELOAD = true + if (window.METAMASK_PLATFORM_TYPE === 'mascara') waitTime = 1000 + await timeout(waitTime) const app = $('#app-content') From 779e973b45ac3c5c48d471218ed63848a6653a56 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 15 Sep 2017 12:19:52 -0700 Subject: [PATCH 18/30] tests - integration - mascara - small cleanup and timeout adjustments --- mascara/src/ui.js | 6 ++---- test/integration/lib/first-time.js | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/mascara/src/ui.js b/mascara/src/ui.js index d70dca724..2f940ad1a 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -63,9 +63,7 @@ function windowReload() { } function timeout (time) { - return new Promise(function (resolve, reject) { - setTimeout(function () { - resolve() - }, time || 1500) + return new Promise((resolve) => { + setTimeout(resolve, time || 1500) }) } \ No newline at end of file diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index e84a51c64..8b3997867 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -13,7 +13,7 @@ QUnit.test('render init screen', (assert) => { async function runFirstTimeUsageTest(assert, done) { let waitTime = 0 window.METAMASK_SKIP_RELOAD = true - if (window.METAMASK_PLATFORM_TYPE === 'mascara') waitTime = 1000 + if (window.METAMASK_PLATFORM_TYPE === 'mascara') waitTime = 2000 await timeout(waitTime) const app = $('#app-content') @@ -126,9 +126,7 @@ async function runFirstTimeUsageTest(assert, done) { } function timeout (time) { - return new Promise(function (resolve, reject) { - setTimeout(function () { - resolve() - }, time * 3 || 1500) + return new Promise((resolve, reject) => { + setTimeout(resolve, time || 1500) }) } \ No newline at end of file From d2d6f6a858a1ffa1871830f0fbc39ecc76935321 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 15 Sep 2017 12:20:43 -0700 Subject: [PATCH 19/30] tests - integration - add mascara to integration test run --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a022d47a..4bb410a8d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test": "npm run lint && npm run test:coverage && npm run test:integration", "test:unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"", "test:single": "METAMASK_ENV=test mocha --require test/helper.js", - "test:integration": "npm run test:flat", + "test:integration": "npm run test:flat && npm run test:mascara", "test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload", "test:coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", "test:flat": "npm run test:flat:build && karma start test/flat.conf.js", From 0ab37b52c0540e8877321b40fc742928e96f7ee3 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 15 Sep 2017 13:13:13 -0700 Subject: [PATCH 20/30] mascara - proxy - small cleanup --- mascara/src/proxy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mascara/src/proxy.js b/mascara/src/proxy.js index 5b95175f1..07c5b0e3c 100644 --- a/mascara/src/proxy.js +++ b/mascara/src/proxy.js @@ -1,7 +1,6 @@ const createParentStream = require('iframe-stream').ParentStream const SWcontroller = require('client-sw-ready-event/lib/sw-client.js') const SwStream = require('sw-stream/lib/sw-stream.js') -const SetupUntrustedComunication = ('./lib/setup-untrusted-connection.js') let intervalDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000 const background = new SWcontroller({ @@ -12,7 +11,7 @@ const background = new SWcontroller({ }) const pageStream = createParentStream() -background.on('ready', (_) => { +background.on('ready', () => { let swStream = SwStream({ serviceWorker: background.controller, context: 'dapp', From a9900be08562c16b2f77e41f18cb80076ded09ec Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 15 Sep 2017 13:13:53 -0700 Subject: [PATCH 21/30] test - mascara - move skip reload test flag --- mascara/test/test-ui.js | 1 + test/integration/lib/first-time.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/mascara/test/test-ui.js b/mascara/test/test-ui.js index bf27338d9..b9bc42dff 100644 --- a/mascara/test/test-ui.js +++ b/mascara/test/test-ui.js @@ -1,6 +1,7 @@ const Helper = require('./util/mascara-test-helper.js') window.addEventListener('load', () => { + window.METAMASK_SKIP_RELOAD = true // inject app container const body = document.body const container = document.createElement('div') diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index 8b3997867..c72abf81d 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -12,7 +12,6 @@ QUnit.test('render init screen', (assert) => { async function runFirstTimeUsageTest(assert, done) { let waitTime = 0 - window.METAMASK_SKIP_RELOAD = true if (window.METAMASK_PLATFORM_TYPE === 'mascara') waitTime = 2000 await timeout(waitTime) From 5d01ca10e46953999bf9e626b6aab4b99f27a4c4 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 15 Sep 2017 13:19:31 -0700 Subject: [PATCH 22/30] tests - mascara - increase timeout before test starts --- test/integration/lib/first-time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index c72abf81d..104f22772 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -12,7 +12,7 @@ QUnit.test('render init screen', (assert) => { async function runFirstTimeUsageTest(assert, done) { let waitTime = 0 - if (window.METAMASK_PLATFORM_TYPE === 'mascara') waitTime = 2000 + if (window.METAMASK_PLATFORM_TYPE === 'mascara') waitTime = 4000 await timeout(waitTime) const app = $('#app-content') From c90c904f95aa725ebd48c6f90939c9d9cba55d47 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 18 Sep 2017 11:47:59 -0700 Subject: [PATCH 23/30] Version 3.10.1 --- CHANGELOG.md | 2 ++ app/manifest.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce2327c24..5ef0ce17a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +## 3.10.1 2017-9-18 + - Add ability to export private keys as a file. - Add ability to export seed words as a file. - Changed state logs to a file download than a clipboard copy. diff --git a/app/manifest.json b/app/manifest.json index bd25c1f6f..8febf91aa 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "MetaMask", "short_name": "Metamask", - "version": "3.10.0", + "version": "3.10.1", "manifest_version": 2, "author": "https://metamask.io", "description": "Ethereum Browser Extension", From 784510f89fcb460bcf77ba477fe9a7c144c25f63 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 18 Sep 2017 12:31:44 -0700 Subject: [PATCH 24/30] tests - integration - remove failing mascara integration tests from normal run until fixed --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4bb410a8d..7a022d47a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test": "npm run lint && npm run test:coverage && npm run test:integration", "test:unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"", "test:single": "METAMASK_ENV=test mocha --require test/helper.js", - "test:integration": "npm run test:flat && npm run test:mascara", + "test:integration": "npm run test:flat", "test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload", "test:coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", "test:flat": "npm run test:flat:build && karma start test/flat.conf.js", From 9f665d8eda6d290511d2ee8ca0121d9a8b8c892b Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 18 Sep 2017 13:06:35 -0700 Subject: [PATCH 25/30] test - integration - bump timeout --- test/integration/lib/first-time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index 104f22772..cedb14f6e 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -53,7 +53,7 @@ async function runFirstTimeUsageTest(assert, done) { const createButton = app.find('button.primary')[0] createButton.click() - await timeout(1500) + await timeout(3000) const created = app.find('h3')[0] assert.equal(created.textContent, 'Vault Created', 'Vault created screen') From eaa85f283df55053024f9e561e3a816f033a7755 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 18 Sep 2017 13:17:08 -0700 Subject: [PATCH 26/30] tests - integration - re-add mascara to normal run --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a022d47a..4bb410a8d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test": "npm run lint && npm run test:coverage && npm run test:integration", "test:unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"", "test:single": "METAMASK_ENV=test mocha --require test/helper.js", - "test:integration": "npm run test:flat", + "test:integration": "npm run test:flat && npm run test:mascara", "test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload", "test:coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", "test:flat": "npm run test:flat:build && karma start test/flat.conf.js", From 2b7b1db851e484cda68352a365215d49fa1c30aa Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 18 Sep 2017 14:34:25 -0700 Subject: [PATCH 27/30] Do not mark a retry tx failed that has been broadcast successfully Fixes #2115 If a tx has been braodcast, the only failures we should accept are: - Never mined - On chain failure We had a section of code that would mark a tx failed during any unknown error during a retry. Now no retry > 1 will ever mark a tx failed, since it has been broadcast, and may be mined. --- app/scripts/lib/pending-tx-tracker.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/scripts/lib/pending-tx-tracker.js b/app/scripts/lib/pending-tx-tracker.js index b90851b58..44e9d50fa 100644 --- a/app/scripts/lib/pending-tx-tracker.js +++ b/app/scripts/lib/pending-tx-tracker.js @@ -76,6 +76,9 @@ module.exports = class PendingTransactionTracker extends EventEmitter { Dont marked as failed if the error is a "known" transaction warning "there is already a transaction with the same sender-nonce but higher/same gas price" + + Also don't mark as failed if it has ever been broadcast successfully. + A successful broadcast means it may still be mined. */ const errorMessage = err.message.toLowerCase() const isKnownTx = ( @@ -88,6 +91,7 @@ module.exports = class PendingTransactionTracker extends EventEmitter { // other || errorMessage.includes('gateway timeout') || errorMessage.includes('nonce too low') + || txMeta.retryCount > 1 ) // ignore resubmit warnings, return early if (isKnownTx) return @@ -117,10 +121,12 @@ module.exports = class PendingTransactionTracker extends EventEmitter { // Only auto-submit already-signed txs: if (!('rawTx' in txMeta)) return - // Increment a try counter. - txMeta.retryCount++ const rawTx = txMeta.rawTx - return await this.publishTransaction(rawTx) + const txHash = await this.publishTransaction(rawTx) + + // Increment successful tries: + txMeta.retryCount++ + return txHash } async _checkPendingTx (txMeta) { From 92e738d17c71d43487b4037df766453d6d8c9273 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 18 Sep 2017 14:37:28 -0700 Subject: [PATCH 28/30] Bump changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ef0ce17a..464cbe43c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +- Fix bug that would sometimes display transactions as failed that could be successfully mined. + ## 3.10.1 2017-9-18 - Add ability to export private keys as a file. From 51b40adecd5586e6ede75362fcfc4756a8ec0062 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 18 Sep 2017 22:42:04 -0700 Subject: [PATCH 29/30] v3.10.2 published `v3.10.2` as an emergency rollback to `v3.10.0` --- app/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/manifest.json b/app/manifest.json index 8febf91aa..67fb543b9 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "MetaMask", "short_name": "Metamask", - "version": "3.10.1", + "version": "3.10.2", "manifest_version": 2, "author": "https://metamask.io", "description": "Ethereum Browser Extension", From 0424ab3e48596ec682cc58992879da377dc9dc55 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 18 Sep 2017 22:44:40 -0700 Subject: [PATCH 30/30] v3.10.2 - changelog add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 464cbe43c..c4366db45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Fix bug that would sometimes display transactions as failed that could be successfully mined. +## 3.10.2 2017-9-18 + +rollback to 3.10.0 due to bug + ## 3.10.1 2017-9-18 - Add ability to export private keys as a file.