Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Fix e2e tests (MetaMask#56)
Browse files Browse the repository at this point in the history
* Add: arrow-parens eslint rule

* Attempt ENS resolution on any valid domain name (MetaMask#8059)

ENS currently supports a variety of tlds in addition to `.eth`, and
more will be supported in the future. Rather than hard-code a list of
supported ENS tlds, all valid domain names will now be interpreted as
potential ENS addresses in our address input component.

Closes MetaMask#7978

* Remove unused sinon sandboxes (MetaMask#8063)

These sandboxes were created, then not utilized at all.

* Enable core ESLint no-mixed-operators rule

* Update redux-related dependencies (MetaMask#8068)

* Add optional chaining (MetaMask#8052)

* Add plugin-proposal-optional-chaining

* Use optional chaining to provide error fallback

* Remove redux-test-utils dependency (MetaMask#8070)

* Remove usages of redux-test-utils
* Remove redux-test-utils dependency

* Use [email protected] (MetaMask#8069)

* Implementation encrypt/decrypt feature (MetaMask#7831)

Implement `eth_decrypt` and `eth_getEncryptionPublicKey`. This allows decryption backed by the user's private key. The message decryption uses a confirmation flow similar to the messaging signing flow, where the message to be decrypted is also able to be decrypted inline for the user to read directly before confirming.

* Fix: handle getCode error

* Fix: e2e WIP

* Add: tmp for dev

* Fix: getCode error

* Fix: remove max gas limit

* Add: use new version of conflux-local-network-lite

* Fix: raise gas for create token contract

* Fix: hide edit button when use advanced gas inputs only

* Fix: more e2e fix WIP

* Fix: hide more currency

* Fix: more e2e

* Fix: lint

* Fix: second e2e test

* Fix: responsive ui e2e test

* Fix: rest e2e test

* Fix: lint

* Fix: more delay to get the right gas limit

* Fix: respect max gas limit, set nonce in estimate gas params

* Fix: more gas

* Fix: lint

* Fix: estimate gas, disable infura controller

* Fix: remove debugger

* Fix: modal block clickable element

* Fix: e2e, locate reject button

* Fix: disable ens resolution

* Fix: e2e confirm and reject together

* Fix: tiny deplay before input state check

* Fix: sentry url

* Fix: getCode cb error

* Fix: currency input remove onblur

* Fix: lint, remove currency input onBlur code

* Add: e2e test back to all test pass

Co-authored-by: Mark Stacey <[email protected]>
Co-authored-by: Whymarrh Whitby <[email protected]>
Co-authored-by: ricky <[email protected]>
Co-authored-by: Konstantin <[email protected]>
  • Loading branch information
5 people committed Mar 27, 2020
1 parent da531f6 commit 4860e5f
Show file tree
Hide file tree
Showing 516 changed files with 8,228 additions and 4,513 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ workflows:
- test-unit
- test-unit-global
- test-mozilla-lint
# - test-e2e-chrome
# - test-e2e-firefox
- test-e2e-chrome
- test-e2e-firefox
- test-integration-flat-chrome
- test-integration-flat-firefox
- benchmark:
Expand All @@ -72,7 +72,7 @@ workflows:
requires:
- prep-deps
- prep-build
# - benchmark
- benchmark
- all-tests-pass
- job-publish-release:
filters:
Expand Down
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ module.exports = {
},

rules: {
'arrow-parens': 'error',
'no-mixed-operators': 'error',
'import/default': 'error',
'import/export': 'error',
'import/named': 'error',
Expand Down
33 changes: 30 additions & 3 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,6 @@
"gasLimitTooLow": {
"message": "Gas limit must be at least 21000"
},
"gasLimitTooHigh": {
"message": "Gas limit must be at most 1000000"
},
"gasUsed": {
"message": "Gas Used"
},
Expand Down Expand Up @@ -1618,5 +1615,35 @@
},
"zeroGasPriceOnSpeedUpError": {
"message": "Zero gas price on speed up"
},
"decryptRequest": {
"message": "Decrypt request"
},
"decrypt": {
"message": "Decrypt"
},
"decryptMessageNotice": {
"message": "$1 would like to read this message to complete your action",
"description": "$1 is website or dapp name"
},
"decryptMetamask": {
"message": "Decrypt message"
},
"decryptCopy": {
"message": "Copy encrypted message"
},
"decryptInlineError": {
"message": "This message cannot be decrypted due to error: $1",
"description": "$1 is error message"
},
"provide": {
"message": "Provide"
},
"encryptionPublicKeyRequest": {
"message": "Request encryption public key"
},
"encryptionPublicKeyNotice": {
"message": "$1 would like your public encryption key. By consenting, this site will be able to compose encrypted messages to you.",
"description": "$1 is website or dapp name"
}
}
42 changes: 41 additions & 1 deletion app/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
"customRPC": {
"message": "Пользовательский RPC"
},
"dataBackupFoundInfo": {
"message": "Некоторые данные вашей учетной записи были экспортированы во время предыдущей установки MetaMask. Это может включать ваши настройки, контакты и токены. Вы хотите импортировать эти данные сейчас?"
},
"decimalsMustZerotoTen": {
"message": "Количество десятичных разрядов должно быть минимум 0 и максимум 36."
},
Expand Down Expand Up @@ -962,8 +965,11 @@
"noConversionRateAvailable": {
"message": "Курсы валют недоступны"
},
"noThanks": {
"message": "Нет, спасибо"
},
"notEnoughGas": {
"message": "Нехватает газа"
"message": "Не хватает газа"
},
"noWebcamFoundTitle": {
"message": "Веб-камера не найдена"
Expand Down Expand Up @@ -1046,6 +1052,10 @@
"restoreAccountWithSeed": {
"message": "Восстановите свой аккаунт с помощью секретной фразы"
},
"restoreWalletPreferences": {
"message": "Были найдены данные экспортированные от $1. Вы желаете восстановить настройки вашего кошелька?",
"description": "$1 is the date at which the data was backed up"
},
"requestsAwaitingAcknowledgement": {
"message": "запросы, ожидающие подтверждения"
},
Expand Down Expand Up @@ -1339,5 +1349,35 @@
},
"yourPrivateSeedPhrase": {
"message": "Ваша сид-фраза"
},
"decryptRequest": {
"message": "Запрос расшифровки"
},
"decrypt": {
"message": "Расшифровать"
},
"decryptMessageNotice": {
"message": "Для $1 необходимо прочитать это сообщение, чтобы завершить Ваше действие",
"description": "$1 is website or dapp name"
},
"decryptMetamask": {
"message": "Расшифровать сообщение"
},
"decryptCopy": {
"message": "Скопировать расшифрованное сообщение"
},
"decryptInlineError": {
"message": "Это сообщение не может быть дешифровано из-за ошибки: $1",
"description": "$1 is error message"
},
"provide": {
"message": "Предоставить"
},
"encryptionPublicKeyRequest": {
"message": "Запрос публичного ключа шифрования"
},
"encryptionPublicKeyNotice": {
"message": "$1 запрашивает ваш открытый ключ шифрования. По согласованию, этот сайт сможет создавать для Вас зашифрованные сообщения.",
"description": "$1 is website or dapp name"
}
}
3 changes: 0 additions & 3 deletions app/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,6 @@
"gasLimitTooLow": {
"message": "Gas Limit 至少要 21000"
},
"gasLimitTooHigh": {
"message": "Gas Limit 不能超过 1000000"
},
"gasUsed": {
"message": "已使用然气量"
},
Expand Down
3 changes: 0 additions & 3 deletions app/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,6 @@
"gasLimitTooLow": {
"message": "Gas 上限至少為 21000"
},
"gasLimitTooHigh": {
"message": "Gas 上限至多為 1000000"
},
"gasUsed": {
"message": "Gas 用量"
},
Expand Down
38 changes: 8 additions & 30 deletions app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@
},
"default_locale": "en",
"background": {
"scripts": [
"chromereload.js",
"bg-libs.js",
"background.js"
],
"scripts": ["chromereload.js", "bg-libs.js", "background.js"],
"persistent": true
},
"browser_action": {
Expand All @@ -54,24 +50,14 @@
},
"content_scripts": [
{
"matches": [
"file://*/*",
"http://*/*",
"https://*/*"
],
"js": [
"contentscript.js"
],
"matches": ["file://*/*", "http://*/*", "https://*/*"],
"js": ["contentscript.js"],
"run_at": "document_start",
"all_frames": true
},
{
"matches": [
"*://connect.trezor.io/*/popup.html"
],
"js": [
"vendor/trezor/content-script.js"
]
"matches": ["*://connect.trezor.io/*/popup.html"],
"js": ["vendor/trezor/content-script.js"]
}
],
"permissions": [
Expand All @@ -86,17 +72,9 @@
"*://*.eth/",
"notifications"
],
"web_accessible_resources": [
"inpage.js",
"phishing.html"
],
"web_accessible_resources": ["inpage.js", "phishing.html"],
"externally_connectable": {
"matches": [
"https://metamask.io/*",
"https://conflux-chain.org/*"
],
"ids": [
"*"
]
"matches": ["https://metamask.io/*", "https://conflux-chain.org/*"],
"ids": ["*"]
}
}
2 changes: 1 addition & 1 deletion app/scripts/account-import-strategies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const accountImporter = {
},

strategies: {
'Private Key': privateKey => {
'Private Key': (privateKey) => {
if (!privateKey) {
throw new Error('Cannot import an empty key.')
}
Expand Down
33 changes: 23 additions & 10 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ initialize().catch(log.error)
* @property {number} unapprovedMsgCount - The number of messages in unapprovedMsgs.
* @property {Object} unapprovedPersonalMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options.
* @property {number} unapprovedPersonalMsgCount - The number of messages in unapprovedPersonalMsgs.
* @property {Object} EncryptionPublicKeyMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options.
* @property {number} unapprovedEncryptionPublicKeyMsgCount - The number of messages in EncryptionPublicKeyMsgs.
* @property {Object} unapprovedDecryptMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options.
* @property {number} unapprovedDecryptMsgCount - The number of messages in unapprovedDecryptMsgs.
* @property {Object} unapprovedTypedMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options.
* @property {number} unapprovedTypedMsgCount - The number of messages in unapprovedTypedMsgs.
* @property {string[]} keyringTypes - An array of unique keyring identifying strings, representing available strategies for creating accounts.
Expand Down Expand Up @@ -191,7 +195,7 @@ async function loadStateFromPersistence () {
}

// report migration errors to sentry
migrator.on('error', err => {
migrator.on('error', (err) => {
// get vault structure without secrets
const vaultStructure = getObjStructure(versionedData)
sentry.captureException(err, {
Expand Down Expand Up @@ -283,7 +287,7 @@ function setupController (initState, initLangCode) {
debounce(1000),
storeTransform(versionifyData),
createStreamSink(persistData),
error => {
(error) => {
log.error('Conflux Portal - Persistence pipeline failed', error)
}
)
Expand Down Expand Up @@ -396,7 +400,7 @@ function setupController (initState, initLangCode) {
const url = new URL(remotePort.sender.url)
const origin = url.hostname

remotePort.onMessage.addListener(msg => {
remotePort.onMessage.addListener((msg) => {
if (msg.data && msg.data.method === 'eth_requestAccounts') {
requestAccountTabIds[origin] = tabId
}
Expand All @@ -420,6 +424,8 @@ function setupController (initState, initLangCode) {
controller.txController.on('update:badge', updateBadge)
controller.messageManager.on('updateBadge', updateBadge)
controller.personalMessageManager.on('updateBadge', updateBadge)
controller.decryptMessageManager.on('updateBadge', updateBadge)
controller.encryptionPublicKeyManager.on('updateBadge', updateBadge)
controller.typedMessageManager.on('updateBadge', updateBadge)
controller.permissionsController.permissions.subscribe(updateBadge)

Expand All @@ -431,18 +437,25 @@ function setupController (initState, initLangCode) {
let label = ''
const unapprovedTxCount = controller.txController.getUnapprovedTxCount()
const unapprovedMsgCount = controller.messageManager.unapprovedMsgCount
const unapprovedPersonalMsgs =
const unapprovedPersonalMsgCount =
controller.personalMessageManager.unapprovedPersonalMsgCount
const unapprovedTypedMsgs =
const unapprovedDecryptMsgCount =
controller.decryptMessageManager.unapprovedDecryptMsgCount
const unapprovedEncryptionPublicKeyMsgCount =
controller.encryptionPublicKeyManager
.unapprovedEncryptionPublicKeyMsgCount
const unapprovedTypedMessagesCount =
controller.typedMessageManager.unapprovedTypedMessagesCount
const pendingPermissionRequests = Object.keys(
controller.permissionsController.permissions.state.permissionsRequests
).length
const count =
unapprovedTxCount +
unapprovedMsgCount +
unapprovedPersonalMsgs +
unapprovedTypedMsgs +
unapprovedPersonalMsgCount +
unapprovedDecryptMsgCount +
unapprovedEncryptionPublicKeyMsgCount +
unapprovedTypedMessagesCount +
pendingPermissionRequests
if (count) {
label = String(count)
Expand All @@ -462,9 +475,9 @@ function setupController (initState, initLangCode) {
* Opens the browser popup for user confirmation
*/
function triggerUi () {
extension.tabs.query({ active: true }, tabs => {
extension.tabs.query({ active: true }, (tabs) => {
const currentlyActiveMetamaskTab = Boolean(
tabs.find(tab => openMetamaskTabsIDs[tab.id])
tabs.find((tab) => openMetamaskTabsIDs[tab.id])
)
if (!popupIsOpen && !currentlyActiveMetamaskTab && !notificationIsOpen) {
notificationManager.showPopup()
Expand All @@ -479,7 +492,7 @@ function triggerUi () {
*/
function openPopup () {
triggerUi()
return new Promise(resolve => {
return new Promise((resolve) => {
const interval = setInterval(() => {
if (!notificationIsOpen) {
clearInterval(interval)
Expand Down
16 changes: 10 additions & 6 deletions app/scripts/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import PortStream from 'extension-port-stream'
const fs = require('fs')
const path = require('path')

const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js'), 'utf8')
const inpageSuffix = '//# sourceURL=' + extension.runtime.getURL('inpage.js') + '\n'
const inpageContent = fs.readFileSync(
path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js'),
'utf8'
)
const inpageSuffix =
'//# sourceURL=' + extension.runtime.getURL('inpage.js') + '\n'
const inpageBundle = inpageContent + inpageSuffix

// Eventually this streaming injection could be replaced with:
Expand Down Expand Up @@ -73,10 +77,10 @@ async function setupStreams () {
const extensionMux = new ObjectMultiplex()
extensionMux.setMaxListeners(25)

pump(pageMux, pageStream, pageMux, err =>
pump(pageMux, pageStream, pageMux, (err) =>
logStreamDisconnectWarning('MetaMask Inpage Multiplex', err)
)
pump(extensionMux, extensionStream, extensionMux, err =>
pump(extensionMux, extensionStream, extensionMux, (err) =>
logStreamDisconnectWarning('MetaMask Background Multiplex', err)
)

Expand All @@ -96,7 +100,7 @@ async function setupStreams () {
function forwardTrafficBetweenMuxers (channelName, muxA, muxB) {
const channelA = muxA.createStream(channelName)
const channelB = muxB.createStream(channelName)
pump(channelA, channelB, channelA, err =>
pump(channelA, channelB, channelA, (err) =>
logStreamDisconnectWarning(
`MetaMask muxed traffic for channel "${channelName}" failed.`,
err
Expand Down Expand Up @@ -232,7 +236,7 @@ async function domIsReady () {
return
}
// wait for load
return new Promise(resolve =>
return new Promise((resolve) =>
window.addEventListener('DOMContentLoaded', resolve, { once: true })
)
}
2 changes: 1 addition & 1 deletion app/scripts/controllers/ConfluxWeb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class Web3 extends Conflux {

get eth () {
return {
contract: abi => new FakeContract(this, abi),
contract: (abi) => new FakeContract(this, abi),
}
}
}
2 changes: 1 addition & 1 deletion app/scripts/controllers/app-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppStateController {
)
this.timer = null

preferencesStore.subscribe(state => {
preferencesStore.subscribe((state) => {
this._setInactiveTimeout(state.preferences.autoLockTimeLimit)
})

Expand Down
Loading

0 comments on commit 4860e5f

Please sign in to comment.