Skip to content

Commit

Permalink
Fix unmocked block tracker warning in GasFeeController tests
Browse files Browse the repository at this point in the history
When running the tests for GasFeeController, we were seeing a warning in
the tests that a request from the block tracker was not properly mocked.
This commit adds that mock so the warning goes away.
  • Loading branch information
mcmire committed Feb 6, 2025
1 parent 694e6ff commit 3cc1a6f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/gas-fee-controller/src/GasFeeController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
NetworkState,
} from '@metamask/network-controller';
import type { Hex } from '@metamask/utils';
import nock from 'nock';
import * as sinon from 'sinon';

import {
Expand Down Expand Up @@ -76,12 +77,30 @@ const setupNetworkController = async ({
allowedEvents: [],
});

const infuraProjectId = '123';

const networkController = new NetworkController({
messenger: restrictedMessenger,
state,
infuraProjectId: '123',
infuraProjectId,
fetch,
btoa,
});

nock('https://mainnet.infura.io')
.post(`/v3/${infuraProjectId}`, {
id: /^\d+$/u,
jsonrpc: '2.0',
method: 'eth_blockNumber',
params: [],
})
.reply(200, {
id: 1,
jsonrpc: '2.0',
result: '0x1',
})
.persist();

if (initializeProvider) {
// Call this without awaiting to simulate what the extension or mobile app
// might do
Expand Down Expand Up @@ -291,7 +310,7 @@ describe('GasFeeController', () => {
);
});

afterEach(() => {
afterEach(async () => {
gasFeeController.destroy();
const { blockTracker } = networkController.getProviderAndBlockTracker();
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
Expand Down

0 comments on commit 3cc1a6f

Please sign in to comment.