1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts
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
..
account-import-strategies
constants Adding Sepolia as a default test network (#15787) 2022-09-14 13:26:45 -05:00
controllers Add initial provider API tests for Infura client (#15556) 2022-09-16 10:48:33 -02:30
lib Adding Sepolia as a default test network (#15787) 2022-09-14 13:26:45 -05:00
migrations migrate network constants to typescript (#15610) 2022-09-14 09:55:31 -05:00
platforms update prettier (#15360) 2022-07-31 13:26:40 -05:00
app-init.js Fix #14846 - Inject provider for MV3 via app-init (#15448) 2022-08-15 11:26:13 -05:00
background.js Replace lavamoat-runtime.js patch (#15682) 2022-08-24 09:50:45 -02:30
contentscript.js MV3: contentscript.js - re-activate streams when Service Worker terminates and then resets (#15494) 2022-09-13 14:20:08 -07:00
detect-multiple-instances.js
detect-multiple-instances.test.js
disable-console.js
first-time-state.js remove exclusions for mismatched object jsdoc type casing (#15351) 2022-07-27 08:28:05 -05:00
init-globals.js
inpage.js MV3: contentscript.js - re-activate streams when Service Worker terminates and then resets (#15494) 2022-09-13 14:20:08 -07:00
lockdown-more.js remove exclusions for mismatched object jsdoc type casing (#15351) 2022-07-27 08:28:05 -05:00
lockdown-run.js
metamask-controller.actions.test.js Make updateTransactionSendFlowHistory background method idempotent (#15585) 2022-09-06 14:39:12 +05:30
metamask-controller.js migrate network constants to typescript (#15610) 2022-09-14 09:55:31 -05:00
metamask-controller.test.js migrate network constants to typescript (#15610) 2022-09-14 09:55:31 -05:00
sentry-install.js Replace lavamoat-runtime.js patch (#15682) 2022-08-24 09:50:45 -02:30
ui.js MV3: add retry logic to actions (#15337) 2022-09-05 20:25:34 +05:30