1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Shorten network type references in NC tests (#19430)

Update NetworkController tests to replace `NETWORK_TYPES.<NETWORK NAME>`
with `NetworkType.<network name>`. This makes it easier to visually
compare differences in the tests between core and this repo.
This commit is contained in:
Elliot Winkler 2023-06-21 10:31:08 -07:00 committed by GitHub
parent 2958c2230b
commit bdd638400c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,6 +55,13 @@ type Block = {
const createNetworkClientMock = jest.mocked(createNetworkClient);
const uuidV4Mock = jest.mocked(v4);
const NetworkType = {
mainnet: NETWORK_TYPES.MAINNET,
goerli: NETWORK_TYPES.GOERLI,
sepolia: NETWORK_TYPES.SEPOLIA,
rpc: NETWORK_TYPES.RPC,
} as const;
/**
* A dummy block that matches the pre-EIP-1559 format (i.e. it doesn't have the
* `baseFeePerGas` property).
@ -84,19 +91,19 @@ const BLOCK: Block = POST_1559_BLOCK;
*/
const INFURA_NETWORKS = [
{
networkType: NETWORK_TYPES.MAINNET,
networkType: NetworkType.mainnet,
chainId: toHex(1),
ticker: 'ETH',
blockExplorerUrl: 'https://etherscan.io',
},
{
networkType: NETWORK_TYPES.GOERLI,
networkType: NetworkType.goerli,
chainId: toHex(5),
ticker: 'GoerliETH',
blockExplorerUrl: 'https://goerli.etherscan.io',
},
{
networkType: NETWORK_TYPES.SEPOLIA,
networkType: NetworkType.sepolia,
chainId: toHex(11155111),
ticker: 'SepoliaETH',
blockExplorerUrl: 'https://sepolia.etherscan.io',
@ -346,7 +353,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'http://example.com',
},
@ -392,11 +399,11 @@ describe('NetworkController', () => {
lookupNetworkTests({
expectedProviderConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
}),
initialState: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
}),
},
operation: async (controller: NetworkController) => {
@ -411,7 +418,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: undefined,
}),
},
@ -435,7 +442,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: undefined,
}),
},
@ -467,7 +474,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: undefined,
}),
},
@ -491,7 +498,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: undefined,
}),
},
@ -680,7 +687,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -737,11 +744,8 @@ describe('NetworkController', () => {
});
});
[
NETWORK_TYPES.MAINNET,
NETWORK_TYPES.GOERLI,
NETWORK_TYPES.SEPOLIA,
].forEach((networkType) => {
[NetworkType.mainnet, NetworkType.goerli, NetworkType.sepolia].forEach(
(networkType) => {
describe(`when the provider config in state contains a network type of "${networkType}"`, () => {
describe('if the network was switched after the net_version request started but before it completed', () => {
it('stores the network status of the second network, not the first', async () => {
@ -1185,8 +1189,12 @@ describe('NetworkController', () => {
},
});
await expect(promiseForInfuraIsUnblockedEvents).toBeFulfilled();
await expect(promiseForNoInfuraIsBlockedEvents).toBeFulfilled();
await expect(
promiseForInfuraIsUnblockedEvents,
).toBeFulfilled();
await expect(
promiseForNoInfuraIsBlockedEvents,
).toBeFulfilled();
},
);
});
@ -1634,8 +1642,12 @@ describe('NetworkController', () => {
},
});
await expect(promiseForInfuraIsUnblockedEvents).toBeFulfilled();
await expect(promiseForNoInfuraIsBlockedEvents).toBeFulfilled();
await expect(
promiseForInfuraIsUnblockedEvents,
).toBeFulfilled();
await expect(
promiseForNoInfuraIsBlockedEvents,
).toBeFulfilled();
},
);
});
@ -1651,7 +1663,8 @@ describe('NetworkController', () => {
},
});
});
});
},
);
describe(`when the provider config in state contains a network type of "rpc"`, () => {
describe('if the network was switched after the net_version request started but before it completed', () => {
@ -1660,7 +1673,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'https://mock-rpc-url',
}),
@ -1692,7 +1705,7 @@ describe('NetworkController', () => {
beforeCompleting: () => {
// Intentionally not awaited because don't want this to
// block the `net_version` request
controller.setProviderType(NETWORK_TYPES.GOERLI);
controller.setProviderType(NetworkType.goerli);
},
},
{
@ -1724,7 +1737,7 @@ describe('NetworkController', () => {
})
.mockReturnValue(fakeNetworkClients[0])
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -1752,7 +1765,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'https://mock-rpc-url',
}),
@ -1788,7 +1801,7 @@ describe('NetworkController', () => {
beforeCompleting: async () => {
// Intentionally not awaited because don't want this to
// block the `net_version` request
controller.setProviderType(NETWORK_TYPES.GOERLI);
controller.setProviderType(NetworkType.goerli);
},
},
{
@ -1822,7 +1835,7 @@ describe('NetworkController', () => {
})
.mockReturnValue(fakeNetworkClients[0])
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -1854,7 +1867,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'https://mock-rpc-url',
}),
@ -1892,7 +1905,7 @@ describe('NetworkController', () => {
beforeCompleting: () => {
// Intentionally not awaited because don't want this to
// block the `net_version` request
controller.setProviderType(NETWORK_TYPES.GOERLI);
controller.setProviderType(NetworkType.goerli);
},
},
{
@ -1936,7 +1949,7 @@ describe('NetworkController', () => {
})
.mockReturnValue(fakeNetworkClients[0])
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -1970,7 +1983,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'https://mock-rpc-url',
}),
@ -2002,7 +2015,7 @@ describe('NetworkController', () => {
beforeCompleting: () => {
// Intentionally not awaited because don't want this to
// block the `net_version` request
controller.setProviderType(NETWORK_TYPES.GOERLI);
controller.setProviderType(NetworkType.goerli);
},
},
{
@ -2040,7 +2053,7 @@ describe('NetworkController', () => {
})
.mockReturnValue(fakeNetworkClients[0])
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -2078,7 +2091,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'https://mock-rpc-url',
}),
@ -2116,7 +2129,7 @@ describe('NetworkController', () => {
beforeCompleting: () => {
// Intentionally not awaited because don't want this to
// block the `net_version` request
controller.setProviderType(NETWORK_TYPES.GOERLI);
controller.setProviderType(NetworkType.goerli);
},
},
]),
@ -2142,7 +2155,7 @@ describe('NetworkController', () => {
})
.mockReturnValue(fakeNetworkClients[0])
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -2170,7 +2183,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'https://mock-rpc-url',
}),
@ -2212,7 +2225,7 @@ describe('NetworkController', () => {
beforeCompleting: async () => {
// Intentionally not awaited because don't want this to
// block the `net_version` request
controller.setProviderType(NETWORK_TYPES.GOERLI);
controller.setProviderType(NetworkType.goerli);
},
},
]),
@ -2240,7 +2253,7 @@ describe('NetworkController', () => {
})
.mockReturnValue(fakeNetworkClients[0])
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -2272,7 +2285,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'https://mock-rpc-url',
}),
@ -2318,7 +2331,7 @@ describe('NetworkController', () => {
beforeCompleting: () => {
// Intentionally not awaited because don't want this to
// block the `net_version` request
controller.setProviderType(NETWORK_TYPES.GOERLI);
controller.setProviderType(NetworkType.goerli);
},
},
]),
@ -2354,7 +2367,7 @@ describe('NetworkController', () => {
})
.mockReturnValue(fakeNetworkClients[0])
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -2388,7 +2401,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: toHex(1337),
rpcUrl: 'https://mock-rpc-url',
}),
@ -2426,7 +2439,7 @@ describe('NetworkController', () => {
beforeCompleting: () => {
// Intentionally not awaited because don't want this to
// block the `net_version` request
controller.setProviderType(NETWORK_TYPES.GOERLI);
controller.setProviderType(NetworkType.goerli);
},
},
]),
@ -2458,7 +2471,7 @@ describe('NetworkController', () => {
})
.mockReturnValue(fakeNetworkClients[0])
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -2492,10 +2505,10 @@ describe('NetworkController', () => {
lookupNetworkTests({
expectedProviderConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
}),
initialState: {
providerConfig: buildProviderConfig({ type: NETWORK_TYPES.RPC }),
providerConfig: buildProviderConfig({ type: NetworkType.rpc }),
},
operation: async (controller) => {
await controller.lookupNetwork();
@ -2565,7 +2578,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'http://somethingexisting.com',
chainId: toHex(99999),
ticker: 'something existing',
@ -2575,7 +2588,7 @@ describe('NetworkController', () => {
},
async ({ controller }) => {
await expect(() =>
controller.setProviderType(NETWORK_TYPES.RPC),
controller.setProviderType(NetworkType.rpc),
).rejects.toThrow(
'NetworkController - cannot call "setProviderType" with type "rpc". Use "setActiveNetwork"',
);
@ -2590,7 +2603,7 @@ describe('NetworkController', () => {
createNetworkClientMock.mockReturnValue(fakeNetworkClient);
try {
await controller.setProviderType(NETWORK_TYPES.RPC);
await controller.setProviderType(NetworkType.rpc);
} catch {
// catch the rejection (it is tested above)
}
@ -2619,7 +2632,7 @@ describe('NetworkController', () => {
createNetworkClientMock.mockReturnValue(fakeNetworkClient);
try {
await controller.setProviderType(NETWORK_TYPES.RPC);
await controller.setProviderType(NetworkType.rpc);
} catch {
// catch the rejection (it is tested above)
}
@ -2653,7 +2666,7 @@ describe('NetworkController', () => {
nickname: 'something existing',
id: 'testNetworkConfigurationId',
rpcPrefs: undefined,
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
},
initialState: {
networkConfigurations: {
@ -2711,7 +2724,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(111),
ticker: 'TEST',
@ -2766,7 +2779,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(111),
ticker: 'TEST',
@ -3132,11 +3145,8 @@ describe('NetworkController', () => {
});
describe('resetConnection', () => {
[
NETWORK_TYPES.MAINNET,
NETWORK_TYPES.GOERLI,
NETWORK_TYPES.SEPOLIA,
].forEach((networkType) => {
[NetworkType.mainnet, NetworkType.goerli, NetworkType.sepolia].forEach(
(networkType) => {
describe(`when the type in the provider configuration is "${networkType}"`, () => {
refreshNetworkTests({
expectedProviderConfig: buildProviderConfig({ type: networkType }),
@ -3148,15 +3158,16 @@ describe('NetworkController', () => {
},
});
});
});
},
);
describe(`when the type in the provider configuration is "rpc"`, () => {
refreshNetworkTests({
expectedProviderConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
}),
initialState: {
providerConfig: buildProviderConfig({ type: NETWORK_TYPES.RPC }),
providerConfig: buildProviderConfig({ type: NetworkType.rpc }),
},
operation: async (controller) => {
await controller.resetConnection();
@ -3171,7 +3182,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.MAINNET,
type: NetworkType.mainnet,
}),
},
},
@ -3182,7 +3193,7 @@ describe('NetworkController', () => {
expect(providerConfig).toStrictEqual(
buildProviderConfig({
type: NETWORK_TYPES.MAINNET,
type: NetworkType.mainnet,
}),
);
},
@ -3451,7 +3462,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(111),
ticker: 'TEST',
@ -3726,7 +3737,7 @@ describe('NetworkController', () => {
it('should add the given network and not set it to active if the setActive option is not passed (or a falsy value is passed)', async () => {
uuidV4Mock.mockImplementationOnce(() => 'networkConfigurationId');
const originalProvider = {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(111),
ticker: 'TEST',
@ -3773,7 +3784,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(111),
ticker: 'TEST',
@ -3829,7 +3840,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(111),
ticker: 'TEST',
@ -4615,7 +4626,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
}),
},
},
@ -4623,7 +4634,7 @@ describe('NetworkController', () => {
const fakeProvider = buildFakeProvider();
const fakeNetworkClient = buildFakeClient(fakeProvider);
mockCreateNetworkClient().mockReturnValue(fakeNetworkClient);
await controller.setProviderType(NETWORK_TYPES.GOERLI);
await controller.setProviderType(NetworkType.goerli);
const networkWillChange = waitForPublishedEvents({
messenger,
@ -4645,7 +4656,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
}),
},
},
@ -4653,7 +4664,7 @@ describe('NetworkController', () => {
const fakeProvider = buildFakeProvider();
const fakeNetworkClient = buildFakeClient(fakeProvider);
mockCreateNetworkClient().mockReturnValue(fakeNetworkClient);
await controller.setProviderType(NETWORK_TYPES.GOERLI);
await controller.setProviderType(NetworkType.goerli);
const networkDidChange = waitForPublishedEvents({
messenger,
@ -4675,7 +4686,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(1337),
nickname: 'network',
@ -4695,7 +4706,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -4741,7 +4752,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(1337),
}),
@ -4772,7 +4783,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -4812,7 +4823,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(1337),
}),
@ -4839,7 +4850,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -4885,7 +4896,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(1337),
}),
@ -4912,7 +4923,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -4947,7 +4958,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(1337),
}),
@ -4962,7 +4973,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -4991,7 +5002,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(1337),
}),
@ -5006,7 +5017,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -5037,7 +5048,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(1337),
}),
@ -5075,7 +5086,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -5102,7 +5113,7 @@ describe('NetworkController', () => {
{
state: {
providerConfig: buildProviderConfig({
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
rpcUrl: 'https://mock-rpc-url',
chainId: toHex(1337),
}),
@ -5138,7 +5149,7 @@ describe('NetworkController', () => {
];
mockCreateNetworkClient()
.calledWith({
network: NETWORK_TYPES.GOERLI,
network: NetworkType.goerli,
infuraProjectId: 'some-infura-project-id',
type: NetworkClientType.Infura,
})
@ -5439,7 +5450,7 @@ function refreshNetworkTests({
);
});
if (expectedProviderConfig.type === NETWORK_TYPES.RPC) {
if (expectedProviderConfig.type === NetworkType.rpc) {
it('sets the provider to a custom RPC provider initialized with the RPC target and chain ID', async () => {
await withController(
{
@ -5543,7 +5554,7 @@ function refreshNetworkTests({
const initializationNetworkClientOptions: Parameters<
typeof createNetworkClient
>[0] =
providerType === NETWORK_TYPES.RPC
providerType === NetworkType.rpc
? {
chainId: controller.store.getState().providerConfig.chainId,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@ -5558,7 +5569,7 @@ function refreshNetworkTests({
const operationNetworkClientOptions: Parameters<
typeof createNetworkClient
>[0] =
expectedProviderConfig.type === NETWORK_TYPES.RPC
expectedProviderConfig.type === NetworkType.rpc
? {
chainId: toHex(expectedProviderConfig.chainId),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@ -5827,7 +5838,7 @@ function lookupNetworkTests({
);
});
if (expectedProviderConfig.type === NETWORK_TYPES.RPC) {
if (expectedProviderConfig.type === NetworkType.rpc) {
it('emits infuraIsUnblocked', async () => {
await withController(
{
@ -5920,7 +5931,7 @@ function lookupNetworkTests({
});
describe('if a country blocked error is encountered while retrieving the version of the current network', () => {
if (expectedProviderConfig.type === NETWORK_TYPES.RPC) {
if (expectedProviderConfig.type === NetworkType.rpc) {
it('updates the network in state to "unknown"', async () => {
await withController(
{
@ -6111,7 +6122,7 @@ function lookupNetworkTests({
);
});
if (expectedProviderConfig.type === NETWORK_TYPES.RPC) {
if (expectedProviderConfig.type === NetworkType.rpc) {
it('emits infuraIsUnblocked', async () => {
await withController(
{
@ -6227,7 +6238,7 @@ function lookupNetworkTests({
);
});
if (expectedProviderConfig.type === NETWORK_TYPES.RPC) {
if (expectedProviderConfig.type === NetworkType.rpc) {
it('emits infuraIsUnblocked', async () => {
await withController(
{
@ -6346,7 +6357,7 @@ function lookupNetworkTests({
);
});
if (expectedProviderConfig.type === NETWORK_TYPES.RPC) {
if (expectedProviderConfig.type === NetworkType.rpc) {
it('emits infuraIsUnblocked', async () => {
await withController(
{
@ -6448,7 +6459,7 @@ function lookupNetworkTests({
});
describe('if a country blocked error is encountered while retrieving the network details of the current network', () => {
if (expectedProviderConfig.type === NETWORK_TYPES.RPC) {
if (expectedProviderConfig.type === NetworkType.rpc) {
it('updates the network in state to "unknown"', async () => {
await withController(
{
@ -6659,7 +6670,7 @@ function lookupNetworkTests({
);
});
if (expectedProviderConfig.type === NETWORK_TYPES.RPC) {
if (expectedProviderConfig.type === NetworkType.rpc) {
it('emits infuraIsUnblocked', async () => {
await withController(
{
@ -6862,7 +6873,7 @@ async function withController<ReturnValue>(
function buildProviderConfig(
config: Partial<ProviderConfiguration> = {},
): ProviderConfiguration {
if (config.type && config.type !== NETWORK_TYPES.RPC) {
if (config.type && config.type !== NetworkType.rpc) {
const networkConfig = INFURA_NETWORKS.find(
({ networkType }) => networkType === config.type,
);
@ -6879,7 +6890,7 @@ function buildProviderConfig(
};
}
return {
type: NETWORK_TYPES.RPC,
type: NetworkType.rpc,
chainId: '0x42',
nickname: undefined,
rpcUrl: 'http://doesntmatter.com',