From 9a3c917a48fe68d43853c2b9c11adcd0fe6897b5 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Wed, 19 Jan 2022 04:38:41 +0530 Subject: [PATCH] Adding support for EIP-1559 in E2E tests (#13282) --- development/run-ganache.sh | 4 +- lavamoat/browserify/beta/policy.json | 8 + lavamoat/browserify/flask/policy.json | 8 + lavamoat/browserify/main/policy.json | 8 + package.json | 5 +- test/e2e/fixtures/send-edit-v2/state.json | 214 +++++++++++++++++ test/e2e/ganache.js | 16 +- test/e2e/helpers.js | 7 +- test/e2e/metamask-ui.spec.js | 2 +- test/e2e/metrics.spec.js | 4 +- .../send-eth-with-private-key.js | 3 - test/e2e/tests/account-details.spec.js | 4 +- test/e2e/tests/add-account.spec.js | 4 +- test/e2e/tests/add-hide-token.spec.js | 6 +- test/e2e/tests/address-book.spec.js | 4 +- test/e2e/tests/contract-interactions.spec.js | 8 +- test/e2e/tests/custom-rpc-history.spec.js | 4 +- test/e2e/tests/from-import-ui.spec.js | 13 +- test/e2e/tests/incremental-security.spec.js | 6 +- test/e2e/tests/localization.spec.js | 4 +- test/e2e/tests/lock-account.spec.js | 4 +- test/e2e/tests/lockdown.spec.js | 4 +- test/e2e/tests/metamask-responsive-ui.spec.js | 6 +- test/e2e/tests/navigate-transactions.spec.js | 4 +- test/e2e/tests/permissions.spec.js | 4 +- test/e2e/tests/personal-sign.spec.js | 4 +- test/e2e/tests/provider-api.spec.js | 4 +- test/e2e/tests/send-edit.spec.js | 113 ++++++++- test/e2e/tests/send-eth.spec.js | 12 +- test/e2e/tests/signature-request.spec.js | 4 +- test/e2e/tests/simple-send.spec.js | 4 +- test/e2e/tests/threebox.spec.js | 4 +- .../advanced-gas-fee-gas-limit.js | 2 + .../base-fee-input/base-fee-input.js | 1 + .../priority-fee-input/priority-fee-input.js | 1 + ...onfirm-page-container-summary.component.js | 2 +- ui/components/ui/form-field/form-field.js | 1 + .../numeric-input/numeric-input.component.js | 3 + yarn.lock | 227 +++++++++++------- 39 files changed, 573 insertions(+), 163 deletions(-) create mode 100644 test/e2e/fixtures/send-edit-v2/state.json diff --git a/development/run-ganache.sh b/development/run-ganache.sh index 0afdad98d..218457663 100755 --- a/development/run-ganache.sh +++ b/development/run-ganache.sh @@ -4,7 +4,7 @@ set -e set -u set -o pipefail -ganache_cli="$(yarn bin)/ganache-cli" +ganache_cli="$(yarn bin)/ganache" seed_phrase="${GANACHE_SEED_PHRASE:-phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent}" _term () { @@ -23,7 +23,7 @@ trap _term SIGTERM trap _int SIGINT # shellcheck disable=SC2086 -$ganache_cli --noVMErrorsOnRPCResponse --networkId 1337 --mnemonic "$seed_phrase" ${GANACHE_ARGS:-} & +$ganache_cli --chain.vmErrorsOnRPCResponse false --networkId 1337 --mnemonic "$seed_phrase" ${GANACHE_ARGS:-} & child=$! wait "$child" diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 0cabec1e1..27fbf0195 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -955,7 +955,10 @@ }, "abstract-leveldown": { "packages": { + "buffer": true, + "immediate": true, "is-buffer": true, + "level-supports": true, "process": true, "xtend": true } @@ -3042,6 +3045,11 @@ "xtend": true } }, + "level-supports": { + "packages": { + "xtend": true + } + }, "levelup": { "packages": { "assert": true, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 0cabec1e1..27fbf0195 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -955,7 +955,10 @@ }, "abstract-leveldown": { "packages": { + "buffer": true, + "immediate": true, "is-buffer": true, + "level-supports": true, "process": true, "xtend": true } @@ -3042,6 +3045,11 @@ "xtend": true } }, + "level-supports": { + "packages": { + "xtend": true + } + }, "levelup": { "packages": { "assert": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 0cabec1e1..27fbf0195 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -955,7 +955,10 @@ }, "abstract-leveldown": { "packages": { + "buffer": true, + "immediate": true, "is-buffer": true, + "level-supports": true, "process": true, "xtend": true } @@ -3042,6 +3045,11 @@ "xtend": true } }, + "level-supports": { + "packages": { + "xtend": true + } + }, "levelup": { "packages": { "assert": true, diff --git a/package.json b/package.json index 82d3d605b..e9531d171 100644 --- a/package.json +++ b/package.json @@ -290,7 +290,7 @@ "fancy-log": "^1.3.3", "fast-glob": "^3.2.2", "fs-extra": "^8.1.0", - "ganache-cli": "^6.12.1", + "ganache": "^v7.0.0-rc.0", "ganache-core": "^2.13.1", "geckodriver": "^1.21.0", "globby": "^11.0.4", @@ -385,7 +385,8 @@ "node-hid": false, "usb": false, "blake-hash": false, - "protobufjs": false + "protobufjs": false, + "@trufflesuite/bigint-buffer": false } } } diff --git a/test/e2e/fixtures/send-edit-v2/state.json b/test/e2e/fixtures/send-edit-v2/state.json new file mode 100644 index 000000000..fe1a4390c --- /dev/null +++ b/test/e2e/fixtures/send-edit-v2/state.json @@ -0,0 +1,214 @@ +{ + "data": { + "AppStateController": { + "mkrMigrationReminderTimestamp": null, + "swapsWelcomeMessageHasBeenShown": true + }, + "CachedBalancesController": { + "cachedBalances": { + "4": {} + } + }, + "CurrencyController": { + "conversionDate": 1575697244.188, + "conversionRate": 149.61, + "currentCurrency": "usd", + "nativeCurrency": "ETH" + }, + "IncomingTransactionsController": { + "incomingTransactions": {}, + "incomingTxLastFetchedBlocksByNetwork": { + "goerli": null, + "kovan": null, + "mainnet": null, + "rinkeby": 5570536 + } + }, + "KeyringController": { + "vault": "{\"data\":\"s6TpYjlUNsn7ifhEFTkuDGBUM1GyOlPrim7JSjtfIxgTt8/6MiXgiR/CtFfR4dWW2xhq85/NGIBYEeWrZThGdKGarBzeIqBfLFhw9n509jprzJ0zc2Rf+9HVFGLw+xxC4xPxgCS0IIWeAJQ+XtGcHmn0UZXriXm8Ja4kdlow6SWinB7sr/WM3R0+frYs4WgllkwggDf2/Tv6VHygvLnhtzp6hIJFyTjh+l/KnyJTyZW1TkZhDaNDzX3SCOHT\",\"iv\":\"FbeHDAW5afeWNORfNJBR0Q==\",\"salt\":\"TxZ+WbCW6891C9LK/hbMAoUsSEW1E8pyGLVBU6x5KR8=\"}" + }, + "NetworkController": { + "network": "1337", + "provider": { + "nickname": "Localhost 8545", + "rpcUrl": "http://localhost:8545", + "chainId": "0x539", + "ticker": "ETH", + "type": "rpc" + } + }, + "NotificationController": { + "notifications": { + "1": { + "isShown": true + }, + "3": { + "isShown": true + }, + "5": { + "isShown": true + }, + "6": { + "isShown": true + }, + "8": { + "isShown": true + } + } + }, + "OnboardingController": { + "onboardingTabs": {}, + "seedPhraseBackedUp": false + }, + "PermissionsMetadata": { + "domainMetadata": { + "metamask.github.io": { + "icon": null, + "name": "M E T A M A S K M E S H T E S T" + } + }, + "permissionsHistory": {}, + "permissionsLog": [ + { + "id": 746677923, + "method": "eth_accounts", + "methodType": "restricted", + "origin": "metamask.github.io", + "request": { + "id": 746677923, + "jsonrpc": "2.0", + "method": "eth_accounts", + "origin": "metamask.github.io", + "params": [] + }, + "requestTime": 1575697241368, + "response": { + "id": 746677923, + "jsonrpc": "2.0", + "result": [] + }, + "responseTime": 1575697241370, + "success": true + } + ] + }, + "PreferencesController": { + "accountTokens": { + "0x5cfe73b6021e818b776b421b1c4db2474086a7e1": { + "rinkeby": [], + "ropsten": [] + } + }, + "assetImages": {}, + "completedOnboarding": true, + "eip1559V2Enabled": true, + "currentLocale": "en", + "featureFlags": { + "showIncomingTransactions": true, + "transactionTime": false + }, + "firstTimeFlowType": "create", + "forgottenPassword": false, + "frequentRpcListDetail": [], + "identities": { + "0x5cfe73b6021e818b776b421b1c4db2474086a7e1": { + "address": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1", + "name": "Account 1" + } + }, + "knownMethodData": {}, + "lostIdentities": {}, + "metaMetricsId": null, + "participateInMetaMetrics": false, + "preferences": { + "useNativeCurrencyAsPrimaryCurrency": true + }, + "selectedAddress": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1", + "suggestedTokens": {}, + "tokens": [], + "useBlockie": false, + "useNonceField": false, + "usePhishDetect": true + }, + "TransactionController": { + "transactions": { + "4046084157914634": { + "chainId": "0x539", + "primaryTransaction": { + "chainId": "0x539", + "id": 4046084157914634, + "loadingDefaults": true, + "metamaskNetworkId": "1337", + "origin": "metamask", + "status": "unapproved", + "time": 1617228030067, + "txParams": { + "from": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1", + "gas": "0x61a8", + "maxFeePerGas": "0x59682f0c", + "maxPriorityFeePerGas": "0x59682f00", + "type": "0x2", + "to": "0x2f318C334780961FB129D2a6c30D0763d9a5C970", + "value": "0xde0b6b3a7640000" + }, + "type": "sentEther" + }, + "history": [ + { + "chainId": "0x539", + "id": 4046084157914634, + "loadingDefaults": true, + "metamaskNetworkId": "1337", + "origin": "metamask", + "status": "unapproved", + "time": 1617228030067, + "txParams": { + "from": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1", + "gas": "0x61a8", + "maxFeePerGas": "0x59682f0c", + "maxPriorityFeePerGas": "0x59682f00", + "type": "0x2", + "to": "0x2f318C334780961FB129D2a6c30D0763d9a5C970", + "value": "0xde0b6b3a7640000" + }, + "type": "simpleSend" + }, + [ + { + "note": "Added new unapproved transaction.", + "op": "replace", + "path": "/loadingDefaults", + "timestamp": 1617228030069, + "value": false + } + ] + ], + "id": 4046084157914634, + "loadingDefaults": false, + "metamaskNetworkId": "1337", + "origin": "metamask", + "status": "unapproved", + "time": 1617228030067, + "txParams": { + "from": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1", + "gas": "0x61a8", + "maxFeePerGas": "0x59682f0c", + "maxPriorityFeePerGas": "0x59682f00", + "type": "0x2", + "to": "0x2f318C334780961FB129D2a6c30D0763d9a5C970", + "value": "0xde0b6b3a7640000" + }, + "type": "simpleSend" + } + } + }, + "config": {}, + "firstTimeInfo": { + "date": 1575697234195, + "version": "7.7.0" + } + }, + "meta": { + "version": 40 + } +} diff --git a/test/e2e/ganache.js b/test/e2e/ganache.js index 8f9974da1..5d45f6208 100644 --- a/test/e2e/ganache.js +++ b/test/e2e/ganache.js @@ -1,5 +1,4 @@ -const { promisify } = require('util'); -const ganache = require('ganache-core'); +const ganache = require('ganache'); const defaultOptions = { blockTime: 2, @@ -8,6 +7,7 @@ const defaultOptions = { 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent', port: 8545, vmErrorsOnRPCResponse: false, + hardfork: 'muirGlacier', }; class Ganache { @@ -15,22 +15,14 @@ class Ganache { const options = { ...defaultOptions, ...opts }; const { port } = options; this._server = ganache.server(options); - - const listen = promisify(this._server.listen).bind(this._server); - const blockchain = await listen(port); - - return { - ...blockchain, - port, - }; + await this._server.listen(port); } async quit() { if (!this._server) { throw new Error('Server not running yet'); } - const close = promisify(this._server.close).bind(this._server); - await close(); + await this._server.close(); } } diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 5eb5ad8fb..76d0976b4 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -1,5 +1,6 @@ const path = require('path'); const sinon = require('sinon'); +const BigNumber = require('bignumber.js'); const createStaticServer = require('../../development/create-static-server'); const { createSegmentServer, @@ -12,9 +13,10 @@ const { ensureXServerIsRunning } = require('./x-server'); const tinyDelayMs = 200; const regularDelayMs = tinyDelayMs * 2; const largeDelayMs = regularDelayMs * 2; - const dappPort = 8080; +const convertToHexValue = (val) => `0x${new BigNumber(val, 10).toString(16)}`; + async function withFixtures(options, testSuite) { const { dapp, @@ -42,7 +44,7 @@ async function withFixtures(options, testSuite) { secondaryGanacheServer = new Ganache(); await secondaryGanacheServer.start({ blockTime: 2, - _chainIdRpc: chainId, + chain: { chainId }, port, vmErrorsOnRPCResponse: false, }); @@ -148,6 +150,7 @@ async function withFixtures(options, testSuite) { } module.exports = { + convertToHexValue, tinyDelayMs, regularDelayMs, largeDelayMs, diff --git a/test/e2e/metamask-ui.spec.js b/test/e2e/metamask-ui.spec.js index e6ec801d5..5ffd36c7f 100644 --- a/test/e2e/metamask-ui.spec.js +++ b/test/e2e/metamask-ui.spec.js @@ -217,7 +217,7 @@ describe('MetaMask', function () { it('balance renders', async function () { await driver.waitForSelector({ css: '[data-testid="wallet-balance"] .list-item__heading', - text: '100 ETH', + text: '1000', }); await driver.delay(regularDelayMs); }); diff --git a/test/e2e/metrics.spec.js b/test/e2e/metrics.spec.js index 498a6ccd0..141b56192 100644 --- a/test/e2e/metrics.spec.js +++ b/test/e2e/metrics.spec.js @@ -1,6 +1,6 @@ const { strict: assert } = require('assert'); const waitUntilCalled = require('../lib/wait-until-called'); -const { withFixtures, tinyDelayMs } = require('./helpers'); +const { convertToHexValue, withFixtures, tinyDelayMs } = require('./helpers'); /** * WARNING: These tests must be run using a build created with `yarn build:test:metrics`, so that it has @@ -15,7 +15,7 @@ describe('Segment metrics', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/send-eth-with-private-key-test/send-eth-with-private-key.js b/test/e2e/send-eth-with-private-key-test/send-eth-with-private-key.js index 5f7291950..4ea215793 100644 --- a/test/e2e/send-eth-with-private-key-test/send-eth-with-private-key.js +++ b/test/e2e/send-eth-with-private-key-test/send-eth-with-private-key.js @@ -12,9 +12,6 @@ sendButton.addEventListener('click', function () { gasPrice: '0x09184e72a000', gasLimit: '0x22710', value: '0xde0b6b3a7640000', - r: '0x25a1bc499cd8799a2ece0fcba0df6e666e54a6e2b4e18c09838e2b621c10db71', - s: '0x6cf83e6e8f6e82a0a1d7bd10bc343fc0ae4b096c1701aa54e6389d447f98ac6f', - v: '0x2d46', to: document.getElementById('address').value, } var tx = new Tx(rawTx); diff --git a/test/e2e/tests/account-details.spec.js b/test/e2e/tests/account-details.spec.js index 82f28ad15..cfdbdf238 100644 --- a/test/e2e/tests/account-details.spec.js +++ b/test/e2e/tests/account-details.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Show account details', function () { const ganacheOptions = { @@ -7,7 +7,7 @@ describe('Show account details', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/add-account.spec.js b/test/e2e/tests/add-account.spec.js index 910402e43..e358660d0 100644 --- a/test/e2e/tests/add-account.spec.js +++ b/test/e2e/tests/add-account.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Add account', function () { const ganacheOptions = { @@ -7,7 +7,7 @@ describe('Add account', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/add-hide-token.spec.js b/test/e2e/tests/add-hide-token.spec.js index 66c6067bb..56fb2840c 100644 --- a/test/e2e/tests/add-hide-token.spec.js +++ b/test/e2e/tests/add-hide-token.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Hide token', function () { const ganacheOptions = { @@ -7,7 +7,7 @@ describe('Hide token', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; @@ -61,7 +61,7 @@ describe('Add existing token using search', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/address-book.spec.js b/test/e2e/tests/address-book.spec.js index 707c72e00..e4d43d347 100644 --- a/test/e2e/tests/address-book.spec.js +++ b/test/e2e/tests/address-book.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Address Book', function () { const ganacheOptions = { @@ -7,7 +7,7 @@ describe('Address Book', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/contract-interactions.spec.js b/test/e2e/tests/contract-interactions.spec.js index 6ef4cc4fb..1e4ddecfa 100644 --- a/test/e2e/tests/contract-interactions.spec.js +++ b/test/e2e/tests/contract-interactions.spec.js @@ -1,5 +1,9 @@ const { strict: assert } = require('assert'); -const { withFixtures, regularDelayMs } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + regularDelayMs, +} = require('../helpers'); describe('Deploy contract and call contract methods', function () { let windowHandles; @@ -11,7 +15,7 @@ describe('Deploy contract and call contract methods', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/custom-rpc-history.spec.js b/test/e2e/tests/custom-rpc-history.spec.js index 6868808ac..d392afbcd 100644 --- a/test/e2e/tests/custom-rpc-history.spec.js +++ b/test/e2e/tests/custom-rpc-history.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Stores custom RPC history', function () { const ganacheOptions = { @@ -7,7 +7,7 @@ describe('Stores custom RPC history', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/from-import-ui.spec.js b/test/e2e/tests/from-import-ui.spec.js index cf3becf05..c68285682 100644 --- a/test/e2e/tests/from-import-ui.spec.js +++ b/test/e2e/tests/from-import-ui.spec.js @@ -1,5 +1,10 @@ const { strict: assert } = require('assert'); -const { withFixtures, regularDelayMs, largeDelayMs } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + regularDelayMs, + largeDelayMs, +} = require('../helpers'); const enLocaleMessages = require('../../../app/_locales/en/messages.json'); describe('Metamask Import UI', function () { @@ -9,7 +14,7 @@ describe('Metamask Import UI', function () { { secretKey: '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; @@ -186,7 +191,7 @@ describe('Metamask Import UI', function () { { secretKey: '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; @@ -292,7 +297,7 @@ describe('Metamask Import UI', function () { { secretKey: '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/incremental-security.spec.js b/test/e2e/tests/incremental-security.spec.js index 90df69560..98f397f78 100644 --- a/test/e2e/tests/incremental-security.spec.js +++ b/test/e2e/tests/incremental-security.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures, tinyDelayMs } = require('../helpers'); +const { convertToHexValue, withFixtures, tinyDelayMs } = require('../helpers'); const enLocaleMessages = require('../../../app/_locales/en/messages.json'); describe('Incremental Security', function () { @@ -8,12 +8,12 @@ describe('Incremental Security', function () { { secretKey: '0x250F458997A364988956409A164BA4E16F0F99F916ACDD73ADCD3A1DE30CF8D1', - balance: 0, + balance: '0x0', }, { secretKey: '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/localization.spec.js b/test/e2e/tests/localization.spec.js index e9d6e0f7e..a4859de68 100644 --- a/test/e2e/tests/localization.spec.js +++ b/test/e2e/tests/localization.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Localization', function () { it('can correctly display Philippine peso symbol and code', async function () { @@ -8,7 +8,7 @@ describe('Localization', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/lock-account.spec.js b/test/e2e/tests/lock-account.spec.js index c8c949a42..345a6ec78 100644 --- a/test/e2e/tests/lock-account.spec.js +++ b/test/e2e/tests/lock-account.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Lock and unlock', function () { const ganacheOptions = { @@ -7,7 +7,7 @@ describe('Lock and unlock', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/lockdown.spec.js b/test/e2e/tests/lockdown.spec.js index a1d0db969..cb38725aa 100644 --- a/test/e2e/tests/lockdown.spec.js +++ b/test/e2e/tests/lockdown.spec.js @@ -4,7 +4,7 @@ const { getGlobalProperties, testIntrinsic, } = require('../../helpers/protect-intrinsics-helpers'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); const { PAGES } = require('../webdriver/driver'); const isFirefox = process.env.SELENIUM_BROWSER === Browser.FIREFOX; @@ -56,7 +56,7 @@ describe('lockdown', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/metamask-responsive-ui.spec.js b/test/e2e/tests/metamask-responsive-ui.spec.js index 1be3d0c9c..cff4f6fb1 100644 --- a/test/e2e/tests/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/metamask-responsive-ui.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures, tinyDelayMs } = require('../helpers'); +const { convertToHexValue, withFixtures, tinyDelayMs } = require('../helpers'); const enLocaleMessages = require('../../../app/_locales/en/messages.json'); describe('Metamask Responsive UI', function () { @@ -183,7 +183,7 @@ describe('Metamask Responsive UI', function () { // balance renders await driver.waitForSelector({ css: '[data-testid="eth-overview__primary-currency"]', - text: '100 ETH', + text: '1000 ETH', }); }, ); @@ -196,7 +196,7 @@ describe('Metamask Responsive UI', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/navigate-transactions.spec.js b/test/e2e/tests/navigate-transactions.spec.js index a5a6a4166..64de4c7e8 100644 --- a/test/e2e/tests/navigate-transactions.spec.js +++ b/test/e2e/tests/navigate-transactions.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Navigate transactions', function () { const ganacheOptions = { @@ -7,7 +7,7 @@ describe('Navigate transactions', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/permissions.spec.js b/test/e2e/tests/permissions.spec.js index 95636934d..16f786718 100644 --- a/test/e2e/tests/permissions.spec.js +++ b/test/e2e/tests/permissions.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Permissions', function () { it('sets permissions and connect to Dapp', async function () { @@ -8,7 +8,7 @@ describe('Permissions', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/personal-sign.spec.js b/test/e2e/tests/personal-sign.spec.js index a1812892d..c479beea4 100644 --- a/test/e2e/tests/personal-sign.spec.js +++ b/test/e2e/tests/personal-sign.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Personal sign', function () { it('can initiate and confirm a personal sign', async function () { @@ -8,7 +8,7 @@ describe('Personal sign', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/provider-api.spec.js b/test/e2e/tests/provider-api.spec.js index c2c5928f7..14a4ff0eb 100644 --- a/test/e2e/tests/provider-api.spec.js +++ b/test/e2e/tests/provider-api.spec.js @@ -1,6 +1,6 @@ const { strict: assert } = require('assert'); const { errorCodes } = require('eth-rpc-errors'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('MetaMask', function () { const ganacheOptions = { @@ -8,7 +8,7 @@ describe('MetaMask', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/send-edit.spec.js b/test/e2e/tests/send-edit.spec.js index 94000b4a8..05562add9 100644 --- a/test/e2e/tests/send-edit.spec.js +++ b/test/e2e/tests/send-edit.spec.js @@ -1,5 +1,6 @@ const { strict: assert } = require('assert'); const { + convertToHexValue, withFixtures, tinyDelayMs, regularDelayMs, @@ -13,7 +14,7 @@ describe('Editing Confirm Transaction', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; @@ -90,4 +91,114 @@ describe('Editing Confirm Transaction', function () { }, ); }); + + if (process.env.EIP_1559_V2 === '1') { + it('goes back from confirm page to edit eth value, baseFee, priorityFee and gas limit - 1559 V2', async function () { + const ganacheOptions = { + hardfork: 'london', + accounts: [ + { + secretKey: + '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', + balance: convertToHexValue(25000000000000000000), + }, + ], + }; + await withFixtures( + { + fixtures: 'send-edit-v2', + ganacheOptions, + title: this.test.title, + }, + async ({ driver }) => { + await driver.navigate(); + + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); + + const transactionAmounts = await driver.findElements( + '.currency-display-component__text', + ); + const transactionAmount = transactionAmounts[0]; + assert.equal(await transactionAmount.getText(), '1'); + + const transactionFee = transactionAmounts[1]; + assert.equal(await transactionFee.getText(), '0.0000375'); + + await driver.clickElement( + '.confirm-page-container-header__back-button', + ); + await driver.fill('.unit-input__input', '2.2'); + + await driver.clickElement({ text: 'Next', tag: 'button' }); + + // open gas fee popover + await driver.clickElement({ text: 'Edit', tag: 'button' }); + + // show gas limit + await driver.clickElement('[data-testid="advanced-gas-fee-edit"]'); + await driver.delay(largeDelayMs); + + // enter max fee + const maxBaseFee = await driver.findElement( + '[data-testid="base-fee-input"]', + ); + await maxBaseFee.clear(); + await maxBaseFee.sendKeys('8'); + await driver.delay(largeDelayMs); + + // enter priority fee + const priorityFee = await driver.findElement( + '[data-testid="priority-fee-input"]', + ); + await priorityFee.clear(); + await priorityFee.sendKeys('8'); + await driver.delay(largeDelayMs); + + // edit gas limit + const gasLimit = await driver.findElement( + '[data-testid="gas-limit-input"]', + ); + await gasLimit.clear(); + await gasLimit.sendKeys('100000'); + await driver.delay(largeDelayMs); + + // save default values + await driver.clickElement('input[type="checkbox"]'); + await driver.delay(largeDelayMs); + + // Submit gas fee changes + await driver.clickElement({ text: 'Save', tag: 'button' }); + + // has correct updated value on the confirm screen the transaction + const editedTransactionAmounts = await driver.findElements( + '.transaction-detail-item__row .transaction-detail-item__detail-values .currency-display-component__text:last-of-type', + ); + const editedTransactionAmount = editedTransactionAmounts[0]; + assert.equal(await editedTransactionAmount.getText(), '0.0008'); + + const editedTransactionFee = editedTransactionAmounts[1]; + assert.equal(await editedTransactionFee.getText(), '2.2008'); + + // confirms the transaction + await driver.clickElement({ text: 'Confirm', tag: 'button' }); + await driver.delay(regularDelayMs); + + await driver.clickElement('[data-testid="home__activity-tab"]'); + await driver.wait(async () => { + const confirmedTxes = await driver.findElements( + '.transaction-list__completed-transactions .transaction-list-item', + ); + return confirmedTxes.length === 1; + }, 10000); + + const txValues = await driver.findElements( + '.transaction-list-item__primary-currency', + ); + assert.equal(txValues.length, 1); + assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText())); + }, + ); + }); + } }); diff --git a/test/e2e/tests/send-eth.spec.js b/test/e2e/tests/send-eth.spec.js index 7d88f121a..abe8082a5 100644 --- a/test/e2e/tests/send-eth.spec.js +++ b/test/e2e/tests/send-eth.spec.js @@ -1,5 +1,9 @@ const { strict: assert } = require('assert'); -const { withFixtures, regularDelayMs } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + regularDelayMs, +} = require('../helpers'); describe('Send ETH from inside MetaMask using default gas', function () { const ganacheOptions = { @@ -7,7 +11,7 @@ describe('Send ETH from inside MetaMask using default gas', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; @@ -93,7 +97,7 @@ describe('Send ETH from inside MetaMask using advanced gas modal', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; @@ -162,7 +166,7 @@ describe('Send ETH from dapp using advanced gas controls', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/signature-request.spec.js b/test/e2e/tests/signature-request.spec.js index bf2a547e2..a2726b860 100644 --- a/test/e2e/tests/signature-request.spec.js +++ b/test/e2e/tests/signature-request.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Signature Request', function () { it('can initiate and confirm a Signature Request', async function () { @@ -8,7 +8,7 @@ describe('Signature Request', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/simple-send.spec.js b/test/e2e/tests/simple-send.spec.js index 21502e836..2d26a1871 100644 --- a/test/e2e/tests/simple-send.spec.js +++ b/test/e2e/tests/simple-send.spec.js @@ -1,4 +1,4 @@ -const { withFixtures } = require('../helpers'); +const { convertToHexValue, withFixtures } = require('../helpers'); describe('Simple send', function () { it('can send a simple transaction from one account to another', async function () { @@ -7,7 +7,7 @@ describe('Simple send', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/test/e2e/tests/threebox.spec.js b/test/e2e/tests/threebox.spec.js index cae0ebca8..ac58e68ab 100644 --- a/test/e2e/tests/threebox.spec.js +++ b/test/e2e/tests/threebox.spec.js @@ -1,5 +1,5 @@ const { strict: assert } = require('assert'); -const { withFixtures, largeDelayMs } = require('../helpers'); +const { convertToHexValue, withFixtures, largeDelayMs } = require('../helpers'); const ThreeboxMockServer = require('../mock-3box/threebox-mock-server'); describe('Threebox', function () { @@ -8,7 +8,7 @@ describe('Threebox', function () { { secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: 25000000000000000000, + balance: convertToHexValue(25000000000000000000), }, ], }; diff --git a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-gas-limit/advanced-gas-fee-gas-limit.js b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-gas-limit/advanced-gas-fee-gas-limit.js index db5a2a6f8..facc3b132 100644 --- a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-gas-limit/advanced-gas-fee-gas-limit.js +++ b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-gas-limit/advanced-gas-fee-gas-limit.js @@ -45,6 +45,7 @@ const AdvancedGasFeeGasLimit = () => { if (isEditing) { return ( { {gasLimit}