mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove unecessary code from the network controller tests (#17137)
The `initializeProvider` parameters were removed recently in #16863, but they were still being set in tests. They have now been removed. An unused property was also being set in the tests, which has now also been removed.
This commit is contained in:
parent
5061eac2e7
commit
e8e0cf5786
@ -58,10 +58,6 @@ describe('NetworkController', () => {
|
||||
let networkController;
|
||||
let getLatestBlockStub;
|
||||
let setProviderTypeAndWait;
|
||||
const noop = () => undefined;
|
||||
const networkControllerProviderConfig = {
|
||||
getAccounts: noop,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
networkController = new NetworkController({ infuraProjectId: 'foo' });
|
||||
@ -85,7 +81,7 @@ describe('NetworkController', () => {
|
||||
|
||||
describe('#provider', () => {
|
||||
it('provider should be updatable without reassignment', () => {
|
||||
networkController.initializeProvider(networkControllerProviderConfig);
|
||||
networkController.initializeProvider();
|
||||
const providerProxy =
|
||||
networkController.getProviderAndBlockTracker().provider;
|
||||
expect(providerProxy.test).toBeUndefined();
|
||||
@ -102,9 +98,7 @@ describe('NetworkController', () => {
|
||||
.reply(200, () =>
|
||||
JSON.stringify(constructSuccessfulRpcResponse(BLOCK)),
|
||||
);
|
||||
await networkController.initializeProvider(
|
||||
networkControllerProviderConfig,
|
||||
);
|
||||
await networkController.initializeProvider();
|
||||
const { blockTracker } = networkController.getProviderAndBlockTracker();
|
||||
// The block tracker starts running after a listener is attached
|
||||
blockTracker.addListener('latest', () => {
|
||||
@ -127,14 +121,14 @@ describe('NetworkController', () => {
|
||||
|
||||
describe('#setProviderType', () => {
|
||||
it('should update provider.type', () => {
|
||||
networkController.initializeProvider(networkControllerProviderConfig);
|
||||
networkController.initializeProvider();
|
||||
networkController.setProviderType('mainnet');
|
||||
const { type } = networkController.getProviderConfig();
|
||||
expect(type).toStrictEqual('mainnet');
|
||||
});
|
||||
|
||||
it('should set the network to loading', () => {
|
||||
networkController.initializeProvider(networkControllerProviderConfig);
|
||||
networkController.initializeProvider();
|
||||
|
||||
const spy = sinon.spy(networkController, '_setNetworkState');
|
||||
networkController.setProviderType('mainnet');
|
||||
@ -146,14 +140,14 @@ describe('NetworkController', () => {
|
||||
|
||||
describe('#getEIP1559Compatibility', () => {
|
||||
it('should return false when baseFeePerGas is not in the block header', async () => {
|
||||
networkController.initializeProvider(networkControllerProviderConfig);
|
||||
networkController.initializeProvider();
|
||||
const supportsEIP1559 =
|
||||
await networkController.getEIP1559Compatibility();
|
||||
expect(supportsEIP1559).toStrictEqual(false);
|
||||
});
|
||||
|
||||
it('should return true when baseFeePerGas is in block header', async () => {
|
||||
networkController.initializeProvider(networkControllerProviderConfig);
|
||||
networkController.initializeProvider();
|
||||
getLatestBlockStub.callsFake(() =>
|
||||
Promise.resolve({ baseFeePerGas: '0xa ' }),
|
||||
);
|
||||
@ -163,7 +157,7 @@ describe('NetworkController', () => {
|
||||
});
|
||||
|
||||
it('should store EIP1559 support in state to reduce calls to _getLatestBlock', async () => {
|
||||
networkController.initializeProvider(networkControllerProviderConfig);
|
||||
networkController.initializeProvider();
|
||||
getLatestBlockStub.callsFake(() =>
|
||||
Promise.resolve({ baseFeePerGas: '0xa ' }),
|
||||
);
|
||||
@ -175,8 +169,7 @@ describe('NetworkController', () => {
|
||||
});
|
||||
|
||||
it('should clear stored EIP1559 support when changing networks', async () => {
|
||||
networkController.initializeProvider(networkControllerProviderConfig);
|
||||
networkController.consoleThis = true;
|
||||
networkController.initializeProvider();
|
||||
getLatestBlockStub.callsFake(() =>
|
||||
Promise.resolve({ baseFeePerGas: '0xa ' }),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user