mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
Fix NetworkController destroy
before initialization (#17136)
The NetworkController `destroy` method has been updated to ensure that it no longer throws if called before initialization. This method was added recently in #17032, but we forgot to handle the case where the controller was not initialized.
This commit is contained in:
parent
e8e0cf5786
commit
6482848610
@ -132,7 +132,7 @@ export default class NetworkController extends EventEmitter {
|
|||||||
* In-progress requests will not be aborted.
|
* In-progress requests will not be aborted.
|
||||||
*/
|
*/
|
||||||
async destroy() {
|
async destroy() {
|
||||||
await this._blockTracker.destroy();
|
await this._blockTracker?.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
async initializeProvider() {
|
async initializeProvider() {
|
||||||
|
@ -91,6 +91,12 @@ describe('NetworkController', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('destroy', () => {
|
describe('destroy', () => {
|
||||||
|
it('should not throw if called before initialization', async () => {
|
||||||
|
await expect(
|
||||||
|
async () => await networkController.destroy(),
|
||||||
|
).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
it('should stop the block tracker for the current selected network', async () => {
|
it('should stop the block tracker for the current selected network', async () => {
|
||||||
nock('http://localhost:8545')
|
nock('http://localhost:8545')
|
||||||
.persist()
|
.persist()
|
||||||
|
Loading…
Reference in New Issue
Block a user