1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/test/e2e
Elliot Winkler ed3cc404f2
NetworkController: Split network into networkId and networkStatus (#17556)
The `network` store of the network controller crams two types of data
into one place. It roughly tracks whether we have enough information to
make requests to the network and whether the network is capable of
receiving requests, but it also stores the ID of the network (as
obtained via `net_version`).

Generally we shouldn't be using the network ID for anything, as it has
been completely replaced by chain ID, which all custom RPC endpoints
have been required to support for over a year now. However, as the
network ID is used in various places within the extension codebase,
removing it entirely would be a non-trivial effort. So, minimally, this
commit splits `network` into two stores: `networkId` and
`networkStatus`. But it also expands the concept of network status.

Previously, the network was in one of two states: "loading" and
"not-loading". But now it can be in one of four states:

- `available`: The network is able to receive and respond to requests.
- `unavailable`: The network is not able to receive and respond to
  requests for unknown reasons.
- `blocked`: The network is actively blocking requests based on the
  user's geolocation. (This is specific to Infura.)
- `unknown`: We don't know whether the network can receive and respond
  to requests, either because we haven't checked or we tried to check
  and were unsuccessful.

This commit also changes how the network status is determined —
specifically, how many requests are used to determine that status, when
they occur, and whether they are awaited. Previously, the network
controller would make 2 to 3 requests during the course of running
`lookupNetwork`.

* First, if it was an Infura network, it would make a request for
  `eth_blockNumber` to determine whether Infura was blocking requests or
  not, then emit an appropriate event. This operation was not awaited.
* Then, regardless of the network, it would fetch the network ID via
  `net_version`. This operation was awaited.
* Finally, regardless of the network, it would fetch the latest block
  via `eth_getBlockByNumber`, then use the result to determine whether
  the network supported EIP-1559. This operation was awaited.

Now:

* One fewer request is made, specifically `eth_blockNumber`, as we don't
  need to make an extra request to determine whether Infura is blocking
  requests; we can reuse `eth_getBlockByNumber`;
* All requests are awaited, which makes `lookupNetwork` run fully
  in-band instead of partially out-of-band; and
* Both requests for `net_version` and `eth_getBlockByNumber` are
  performed in parallel to make `lookupNetwork` run slightly faster.
2023-03-30 16:49:12 -06:00
..
import-utc-json E2e test fixtures (#16061) 2022-10-28 09:42:12 +01:00
mock-page-with-disallowed-iframe Fix e2e tests 2022-05-16 18:48:20 -02:30
mock-page-with-iframe Use externally hosted phishing warning page 2022-05-16 14:40:50 -02:30
mv3 [e2e] Setup MV3 specific test folder and add 1 simple testcase introducing Service Worker re-start (#16606) 2022-11-25 12:06:48 +01:00
mv3-perf-stats Capture all Error console.log events (#17710) 2023-02-23 14:27:36 +00:00
nft Remove timeouts without effect (#18342) 2023-03-28 14:59:41 +02:00
restore Toggle option to enable/disable balance and Token rate checking for using third-party API (#16772) 2023-01-17 10:23:04 -05:00
seeder ERC1155 Import & Dapp interaction E2E tests (#17885) 2023-02-27 10:48:41 -06:00
send-eth-with-private-key-test chore: Adjust trailing whitespace (#15636) 2022-08-24 14:11:49 -05:00
snaps [FLASK] snaps-monorepo@0.32.2 (#18371) 2023-03-30 23:57:28 +02:00
swaps Fixed test instability (#18174) 2023-03-16 11:06:33 +01:00
tests NetworkController: Split network into networkId and networkStatus (#17556) 2023-03-30 16:49:12 -06:00
webdriver Capture all Error console.log events (#17710) 2023-02-23 14:27:36 +00:00
.mocharc.js allow importing of typescript in E2E test suite (#17141) 2023-01-12 08:38:12 -06:00
benchmark.js allow importing of typescript in E2E test suite (#17141) 2023-01-12 08:38:12 -06:00
e2e-mocha-setup.js allow importing of typescript in E2E test suite (#17141) 2023-01-12 08:38:12 -06:00
e2e-process-report.js e2e multiple reports (#17715) 2023-02-10 19:34:01 +00:00
fixture-builder.js NetworkController: Split network into networkId and networkStatus (#17556) 2023-03-30 16:49:12 -06:00
fixture-server.js Use deployed contracts in fixtures (#18107) 2023-03-13 14:31:14 +00:00
ganache.js [e2e] Using ganache requests to getBalance and getAccounts (#18215) 2023-03-20 10:29:18 +01:00
helpers.js [e2e] Using ganache requests to getBalance and getAccounts (#18215) 2023-03-20 10:29:18 +01:00
lavamoat-stats.js E2e test fixtures (#16061) 2022-10-28 09:42:12 +01:00
metamask-ui.spec.js Remove timeouts without effect (#18342) 2023-03-28 14:59:41 +02:00
mock-e2e.js delay chain validation (#17413) 2023-03-08 16:33:27 +00:00
mv3-stats.js E2e test fixtures (#16061) 2022-10-28 09:42:12 +01:00
phishing-warning-page-server.js Use externally hosted phishing warning page 2022-05-16 14:40:50 -02:30
run-all.js Move nft e2e tests to main e2e test job (#18055) 2023-03-14 15:21:24 +00:00
run-e2e-test.js Add desktop support (#17683) 2023-02-20 17:13:12 +00:00
user-actions-benchmark.js Convert Transaction constants to typescript (#17149) 2023-01-18 08:47:29 -06:00
x-server.js Fix 'yarn setup' on M1 Macs (#11887) 2021-09-01 10:40:40 -06:00