1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00
metamask-extension/app/scripts
Elliot Winkler 24eae1d3c6
Use fake provider for NetworkController unit tests (#18628)
* Use fake provider for NetworkController unit tests

In the unit tests for NetworkController, it's important to prevent
network requests from occurring. Currently we do that by using Nock.
However, the `core` version of NetworkController uses a fake provider
object. This is arguably a better approach for unit tests because it
prevents us from having to think about the behavior that a specific
middleware may have. For instance, the Infura middleware intercepts
`eth_chainId` to return a static result, and the block cache middleware
replaces the `latest` block tag with the latest block number, making an
extra call to `eth_blockNumber` in doing so. We have to account for
these kinds of behaviors when using Nock, but we do not need to do this
when using a fake provider.

This should make it easier to compare the difference between the unit
tests in this repo vs. in the `core` repo, which should ultimately help
us merge the two controllers together.

* Rename fake-provider-engine to fake-provider

* Rearrange imports

* Move fake-provider and fake-block-tracker into a directory and exclude it from coverage

* Make FakeBlockTracker inert, and fix JSDocs

* Remove generics from FakeProvider

* Call beforeCompleting (and beforeResolving) using async/await

* Fix signature of sendAsync; align other signatures within FakeProvider

* No need to check whether error is not a string

* Don't exclude the provider-api-tests directory from coverage

* Make sure to mock both net_version and eth_getBlockByNumber when testing network status

* Fix FakeProvider so that none of the methods have optional callbacks
2023-04-20 15:21:41 -02:30
..
account-import-strategies Upgrading the Import Account modal (#17763) 2023-03-06 09:48:28 -08:00
constants Convert app/scripts/constants -> Typescript (#17327) 2023-01-20 13:33:01 -07:00
controllers Use fake provider for NetworkController unit tests (#18628) 2023-04-20 15:21:41 -02:30
lib Adopt security provider request from core (#18520) 2023-04-18 08:33:32 +01:00
migrations Rename migration 83 to 84 and rename migration 84 to 83 (#18655) 2023-04-19 11:38:16 -02:30
platforms fix(18194): Redirect to extension expanded view when click back to sa… (#18376) 2023-03-31 10:00:44 +01:00
app-init.js Fix firsttimeloaded logic (#18344) 2023-04-06 12:13:01 -02:30
background.js UX: Multichain: App header (#18363) 2023-04-13 22:24:03 +05:30
contentscript.js Update the PhishingController to v2 and update phishing warning page (#17835) 2023-02-24 11:39:00 -03:30
detect-multiple-instances.js Warn about multiple MetaMask instances running (#13836) 2022-04-27 20:14:10 +02:00
detect-multiple-instances.test.js [MMI] Prevent multiple instances of MM at the same browser (#17856) 2023-03-02 10:17:45 -06:00
disable-console.js Update Eslint and deps (#15293) 2022-07-26 13:10:51 -05:00
first-time-state.js Migrate network configurations (previously frequentRpcListDetail) from PreferencesController to NetworkController (#17421) 2023-03-09 15:00:28 -06:00
init-globals.js MV3: fix injection of applyLavamoat variable in service worker (#14920) 2022-06-18 12:40:30 +05:30
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 Activate LavaMoat scuttling security feature (#17276) 2023-01-24 19:00:35 +02:00
lockdown-run.js lockdown - breakout making globalThis properties non-writable (#12258) 2021-10-01 08:53:12 -10:00
metamask-controller.actions.test.js Migrate network configurations (previously frequentRpcListDetail) from PreferencesController to NetworkController (#17421) 2023-03-09 15:00:28 -06:00
metamask-controller.js Remove mobile sync feature (#18692) 2023-04-20 14:29:30 -02:30
metamask-controller.test.js Fix firsttimeloaded logic (#18344) 2023-04-06 12:13:01 -02:30
sentry-install.js refactor sentryHooks object (#16435) 2022-11-09 19:28:32 +00:00
ui.js Move desktop code to flask build type (#17960) 2023-03-06 19:35:00 +00:00
use-snow.js Integrating snow into metamask (#15580) 2022-11-24 02:36:19 +02:00