From 252c7c1d6d3e7625e2ca7c09d1f1d70b844bb5e7 Mon Sep 17 00:00:00 2001 From: Vinicius Stevam <45455812+vinistevam@users.noreply.github.com> Date: Mon, 31 Jul 2023 11:06:18 +0100 Subject: [PATCH] Remove unnecessary log from accept approval (#20233) --- app/scripts/controllers/app-state.js | 3 +- app/scripts/controllers/app-state.test.js | 49 ----------------------- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/app/scripts/controllers/app-state.js b/app/scripts/controllers/app-state.js index 1bbf4a4f8..cd477fd8d 100644 --- a/app/scripts/controllers/app-state.js +++ b/app/scripts/controllers/app-state.js @@ -452,7 +452,6 @@ export default class AppStateController extends EventEmitter { _acceptApproval() { if (!this._approvalRequestId) { - log.error('Attempted to accept missing unlock approval request'); return; } try { @@ -461,7 +460,7 @@ export default class AppStateController extends EventEmitter { this._approvalRequestId, ); } catch (error) { - log.error('Failed to accept transaction approval request', error); + log.error('Failed to unlock approval request', error); } this._approvalRequestId = null; diff --git a/app/scripts/controllers/app-state.test.js b/app/scripts/controllers/app-state.test.js index b96d39a4c..4716e30cd 100644 --- a/app/scripts/controllers/app-state.test.js +++ b/app/scripts/controllers/app-state.test.js @@ -1,10 +1,7 @@ import { ObservableStore } from '@metamask/obs-store'; -import log from 'loglevel'; import { ORIGIN_METAMASK } from '../../../shared/constants/app'; import AppStateController from './app-state'; -jest.mock('loglevel'); - let appStateController, mockStore; describe('AppStateController', () => { @@ -147,52 +144,6 @@ describe('AppStateController', () => { expect.any(String), ); }); - - it('logs if rejecting approval request throws', async () => { - appStateController._approvalRequestId = 'mock-approval-request-id'; - appStateController = new AppStateController({ - addUnlockListener: jest.fn(), - isUnlocked: jest.fn(() => true), - onInactiveTimeout: jest.fn(), - showUnlockRequest: jest.fn(), - preferencesStore: { - subscribe: jest.fn(), - getState: jest.fn(() => ({ - preferences: { - autoLockTimeLimit: 0, - }, - })), - }, - qrHardwareStore: { - subscribe: jest.fn(), - }, - messenger: { - call: jest.fn(() => { - throw new Error('mock error'); - }), - }, - }); - - appStateController.handleUnlock(); - - expect(log.error).toHaveBeenCalledTimes(1); - expect(log.error).toHaveBeenCalledWith( - 'Attempted to accept missing unlock approval request', - ); - }); - - it('returns without call messenger if no approval request in pending', async () => { - const emitSpy = jest.spyOn(appStateController, 'emit'); - - appStateController.handleUnlock(); - - expect(emitSpy).toHaveBeenCalledTimes(0); - expect(appStateController.messagingSystem.call).toHaveBeenCalledTimes(0); - expect(log.error).toHaveBeenCalledTimes(1); - expect(log.error).toHaveBeenCalledWith( - 'Attempted to accept missing unlock approval request', - ); - }); }); describe('setDefaultHomeActiveTabName', () => {