Skip to content

Commit

Permalink
Simplify the setFakeProvider test helper (#1317)
Browse files Browse the repository at this point in the history
The `setFakeProvider` test helper used for the network controller unit
tests had a return value that was unused, and an unnecessary waiting
step. These have both been removed.

This reduces the scope of #1116
  • Loading branch information
Gudahtt authored May 3, 2023
1 parent 6d75f76 commit 0a12132
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 57 deletions.
11 changes: 1 addition & 10 deletions packages/network-controller/tests/NetworkController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Patch } from 'immer';
import { v4 } from 'uuid';
import { ethErrors } from 'eth-rpc-errors';
import { BUILT_IN_NETWORKS, NetworkType } from '@metamask/controller-utils';
import { waitForResult } from '../../../tests/helpers';
import {
NetworkController,
NetworkControllerActions,
Expand Down Expand Up @@ -7145,7 +7144,7 @@ async function setFakeProvider(
stubLookupNetworkWhileSetting?: boolean;
stubGetEIP1559CompatibilityWhileSetting?: boolean;
} = {},
): Promise<Provider> {
): Promise<void> {
const fakeProvider = buildFakeProvider(stubs);
const fakeNetworkClient = buildFakeClient(fakeProvider);
createNetworkClientMock.mockReturnValue(fakeNetworkClient);
Expand All @@ -7163,10 +7162,6 @@ async function setFakeProvider(
}

await controller.initializeProvider();
await waitForResult(
true,
() => controller.getProviderAndBlockTracker().provider !== undefined,
);
assert(controller.getProviderAndBlockTracker().provider);

if (stubLookupNetworkWhileSetting) {
Expand All @@ -7175,10 +7170,6 @@ async function setFakeProvider(
if (stubGetEIP1559CompatibilityWhileSetting) {
lookupGetEIP1559CompatibilityMock.mockRestore();
}

const { provider } = controller.getProviderAndBlockTracker();
assert(provider);
return provider;
}

/**
Expand Down
47 changes: 0 additions & 47 deletions tests/helpers.ts

This file was deleted.

0 comments on commit 0a12132

Please sign in to comment.