1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/app/scripts/controllers/network
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
..
middleware @metamask/eslint config@5.0.0 (#10358) 2021-02-04 10:15:23 -08:00
provider-api-tests Add initial provider API tests for Infura client (#15556) 2022-09-16 10:48:33 -02:30
createInfuraClient.js Update eth-json-rpc-infura (#15845) 2022-09-15 14:41:18 -02:30
createInfuraClient.test.js Add initial provider API tests for Infura client (#15556) 2022-09-16 10:48:33 -02:30
createJsonRpcClient.js Fix isMainnet propType error (#12951) 2021-12-02 14:46:46 -03:30
createMetamaskMiddleware.js eth-json-rpc-middleware@8.0.0 (#10738) 2021-11-11 12:26:49 -08:00
index.js cancel unapproved confirmations on network change (#10357) 2021-02-08 17:22:30 -06:00
network-controller.test.js Adding Sepolia as a default test network (#15787) 2022-09-14 13:26:45 -05:00
network.js migrate network constants to typescript (#15610) 2022-09-14 09:55:31 -05:00
pending-middleware.test.js update prettier (#15360) 2022-07-31 13:26:40 -05:00
util.js Ensure createPendingTxMiddleware returns gasPrice for EIP-1559 transactions (#11685) 2021-07-30 18:10:19 -02:30
util.test.js update prettier (#15360) 2022-07-31 13:26:40 -05:00