Skip to content

Commit

Permalink
Improve types used for network client test helpers (#1305)
Browse files Browse the repository at this point in the history
The types used for the network client test helpers have been made more
specific; the network type passed in is now required at a type-level to
be an Infura network.

This was a type-only change because we were already only passing in
Infura neworks for this option. This was done to make a later refactor
PR simpler.

Relates to #1116
  • Loading branch information
Gudahtt authored and MajorLift committed Oct 11, 2023
1 parent 142c952 commit 9287a94
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/network-controller/tests/provider-api-tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
JSONRPCResponseResult,
} from '@json-rpc-specification/meta-schema';
import { ControllerMessenger } from '@metamask/base-controller';
import { NetworkType } from '@metamask/controller-utils';
import { InfuraNetworkType } from '@metamask/controller-utils';
import {
NetworkController,
NetworkControllerMessenger,
Expand Down Expand Up @@ -289,7 +289,7 @@ export type ProviderType = 'infura' | 'custom';

export type MockOptions = {
providerType: ProviderType;
infuraNetwork?: NetworkType;
infuraNetwork?: InfuraNetworkType;
customRpcUrl?: string;
};

Expand All @@ -298,13 +298,13 @@ export type MockCommunications = {
mockAllBlockTrackerRequests: (options?: any) => void;
mockRpcCall: (arg0: CurriedMockRpcCallOptions) => MockRpcCallResult;
rpcUrl: string;
infuraNetwork: NetworkType;
infuraNetwork: InfuraNetworkType;
};

export const withMockedCommunications = async (
{
providerType,
infuraNetwork = NetworkType.mainnet,
infuraNetwork = InfuraNetworkType.mainnet,
customRpcUrl = MOCK_RPC_URL,
}: MockOptions,
fn: (comms: MockCommunications) => Promise<void>,
Expand Down Expand Up @@ -387,7 +387,7 @@ export const waitForPromiseToBeFulfilledAfterRunningAllTimers = async (
export const withNetworkClient = async (
{
providerType,
infuraNetwork = NetworkType.mainnet,
infuraNetwork = InfuraNetworkType.mainnet,
customRpcUrl = MOCK_RPC_URL,
}: MockOptions,
fn: (client: MockNetworkClient) => Promise<any>,
Expand Down

0 comments on commit 9287a94

Please sign in to comment.