1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00
metamask-extension/app
Elliot Winkler d91eabfd16
Add initial provider API tests for Infura client (#15556)
We are working on migrating the extension to a unified network
controller, but before we do so we want to extract some of the existing
pieces, specifically `createInfuraClient` and `createJsonRpcClient`,
which provide the majority of the behavior exhibited within the provider
API that the existing NetworkController exposes. This necessitates that
we understand and test that behavior as a whole.

With that in mind, this commit starts with the Infura-specific network
client and adds some initial functional tests for `createInfuraClient`,
specifically covering three pieces of middleware provided by
`eth-json-rpc-middleware`: `createNetworkAndChainIdMiddleware`,
`createBlockCacheMiddleware`, and `createBlockRefMiddleware`.

These tests exercise logic that originate from multiple different places
and combine in sometimes surprising ways, and as a result, understanding
the nature of the tests can be tricky. I've tried to explain the logic
(both of the implementation and the tests) via comments. Additionally,
debugging why a certain test is failing is not the most fun thing in the
world, so to aid with this, I've added some logging to the underlying
packages used when a request passes through the middleware stack.
Because some middleware change the request being made, or make new
requests altogether, this greatly helps to peel back the curtain, as
failures from Nock do not supply much meaningful information on their
own. This logging is disabled by default, but can be activated by
setting `DEBUG=metamask:*,eth-query DEBUG_COLORS=1` alongside the `jest`
command.

We use this logging by bumping `eth-block-tracker`, and
`eth-json-rpc-middleware`.
2022-09-16 10:48:33 -02:30
..
_locales Add notification about the merge (#15846) 2022-09-15 12:51:01 -02:30
build-types Dark Mode: Create Theme-friendly top left logo component (#13897) 2022-03-11 10:45:13 -06:00
fonts UI-14395: typography v2 (#15408) 2022-08-18 10:51:53 -07:00
images Header component for transaction confirmation screens (#15614) 2022-08-23 10:52:08 -05:00
manifest Update MV3 CSP to fix build (#15833) 2022-09-14 14:17:50 -05:00
scripts Add initial provider API tests for Infura client (#15556) 2022-09-16 10:48:33 -02:30
vendor/trezor Update postMessage structure for TrezorConnect 8 (#10192) 2021-01-21 11:12:54 -06:00
background.html Add applyLavaMoat build flag (#14583) 2022-04-29 15:56:30 -07:00
home.html chore: Adjust trailing whitespace (#15636) 2022-08-24 14:11:49 -05:00
loading.html refactor & change html pages 2019-05-04 18:57:19 +02:00
notification.html revert indenting change 2022-06-08 14:24:49 -07:00
popup.html Remove junk from previous ticket 2022-06-08 14:24:49 -07:00
trezor-usb-permissions.html chore: Adjust trailing whitespace (#15636) 2022-08-24 14:11:49 -05:00