From 206e4537d151e85139b248fc4593ebc22da998a7 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 31 May 2023 11:50:32 -0600 Subject: [PATCH] NetworkController tests: Sync withController helper (#19313) This reduces the diff in the NetworkController tests between this repo and core in order to make them easier to merge. --- .../network/network-controller.test.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/app/scripts/controllers/network/network-controller.test.ts b/app/scripts/controllers/network/network-controller.test.ts index 5ef3571cb..6fd383522 100644 --- a/app/scripts/controllers/network/network-controller.test.ts +++ b/app/scripts/controllers/network/network-controller.test.ts @@ -79,13 +79,6 @@ const POST_1559_BLOCK: Block = { */ const BLOCK: Block = POST_1559_BLOCK; -/** - * A dummy value for the `projectId` option that `createInfuraClient` needs. - * (Infura should not be hit during tests, but just in case, this should not - * refer to a real project ID.) - */ -const DEFAULT_INFURA_PROJECT_ID = 'fake-infura-project-id'; - /** * The networks that NetworkController recognizes as built-in Infura networks, * along with information we expect to be true for those networks. @@ -6172,22 +6165,21 @@ type WithControllerArgs = * * @param args - Either a function, or an options bag + a function. The options * bag is equivalent to the options that NetworkController takes (although - * `messenger` is filled in if not given); the function will be called with the - * built controller. + * `messenger` and `infuraProjectId` are filled in if not given); the function + * will be called with the built controller. * @returns Whatever the callback returns. */ async function withController( ...args: WithControllerArgs ): Promise { - const [givenNetworkControllerOptions, fn] = - args.length === 2 ? args : [{}, args[0]]; + const [{ ...rest }, fn] = args.length === 2 ? args : [{}, args[0]]; const messenger = buildMessenger(); const restrictedMessenger = buildNetworkControllerMessenger(messenger); const controller = new NetworkController({ - infuraProjectId: DEFAULT_INFURA_PROJECT_ID, messenger: restrictedMessenger, trackMetaMetricsEvent: jest.fn(), - ...givenNetworkControllerOptions, + infuraProjectId: 'infura-project-id', + ...rest, }); try { return await fn({ controller, messenger });