1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts/controllers
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
..
ens Fix/use etherjs specific imports (#15461) 2023-01-24 08:10:36 -06:00
network Use fake provider for NetworkController unit tests (#18628) 2023-04-20 15:21:41 -02:30
permissions [FLASK] Remove unused snaps code (#18565) 2023-04-17 12:55:08 +02:00
transactions Trigger transaction popup using ApprovalController (#18400) 2023-04-11 14:18:43 +01:00
alert.js feature: convert level 32 files to typescript (#17390) 2023-01-27 18:28:03 +00:00
app-state.js Updating Terms of Use, Adding popover and onboarding flow check (#18221) 2023-04-14 12:51:13 -04:00
app-state.test.js Trigger unlock popup in appStateController using ApprovalController (#18386) 2023-04-14 05:50:17 +01:00
backup.js Migrate network configurations (previously frequentRpcListDetail) from PreferencesController to NetworkController (#17421) 2023-03-09 15:00:28 -06:00
backup.test.js Migrate network configurations (previously frequentRpcListDetail) from PreferencesController to NetworkController (#17421) 2023-03-09 15:00:28 -06:00
cached-balances.js remove exclusions for mismatched object jsdoc type casing (#15351) 2022-07-27 08:28:05 -05:00
cached-balances.test.js Deprecating the Rinkeby, Ropsten, and Kovan test networks (#15989) 2022-09-28 20:26:01 -07:00
detect-tokens.js Convert shared/constants/metametrics to TS (#18353) 2023-04-03 09:31:04 -06:00
detect-tokens.test.js Make setProviderType async (#18604) 2023-04-17 15:45:01 -02:30
encryption-public-key.test.ts Refactor eth_getEncryptionPublicKey handling (#18319) 2023-04-13 09:24:59 +01:00
encryption-public-key.ts Refactor eth_getEncryptionPublicKey handling (#18319) 2023-04-13 09:24:59 +01:00
incoming-transactions.js Additional incoming transactions support (#14219) 2023-02-14 12:35:42 -06:00
incoming-transactions.test.js Additional incoming transactions support (#14219) 2023-02-14 12:35:42 -06:00
metametrics.js Convert shared/constants/metametrics to TS (#18353) 2023-04-03 09:31:04 -06:00
metametrics.test.js Convert shared/constants/metametrics to TS (#18353) 2023-04-03 09:31:04 -06:00
onboarding.js Use async/await instead of Promise.resolve (#16221) 2023-01-20 14:20:18 -06:00
preferences.js Remove openPopup from preferences controller (#18343) 2023-04-05 08:39:58 +01:00
preferences.test.js Make network controller internal fields private (#18607) 2023-04-17 12:45:33 -02:30
sign.test.ts Adopt security provider request from core (#18520) 2023-04-18 08:33:32 +01:00
sign.ts Adopt security provider request from core (#18520) 2023-04-18 08:33:32 +01:00
swaps.js Fix swaps controller: update provider after networkIdStore state update (#18670) 2023-04-19 18:15:26 -02:30
swaps.test.js Fix swaps controller: update provider after networkIdStore state update (#18670) 2023-04-19 18:15:26 -02:30