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

Remove unnecessary log from accept approval (#20233)

This commit is contained in:
Vinicius Stevam 2023-07-31 11:06:18 +01:00 committed by GitHub
parent e6a4c63d51
commit 252c7c1d6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 51 deletions

View File

@ -452,7 +452,6 @@ export default class AppStateController extends EventEmitter {
_acceptApproval() { _acceptApproval() {
if (!this._approvalRequestId) { if (!this._approvalRequestId) {
log.error('Attempted to accept missing unlock approval request');
return; return;
} }
try { try {
@ -461,7 +460,7 @@ export default class AppStateController extends EventEmitter {
this._approvalRequestId, this._approvalRequestId,
); );
} catch (error) { } catch (error) {
log.error('Failed to accept transaction approval request', error); log.error('Failed to unlock approval request', error);
} }
this._approvalRequestId = null; this._approvalRequestId = null;

View File

@ -1,10 +1,7 @@
import { ObservableStore } from '@metamask/obs-store'; import { ObservableStore } from '@metamask/obs-store';
import log from 'loglevel';
import { ORIGIN_METAMASK } from '../../../shared/constants/app'; import { ORIGIN_METAMASK } from '../../../shared/constants/app';
import AppStateController from './app-state'; import AppStateController from './app-state';
jest.mock('loglevel');
let appStateController, mockStore; let appStateController, mockStore;
describe('AppStateController', () => { describe('AppStateController', () => {
@ -147,52 +144,6 @@ describe('AppStateController', () => {
expect.any(String), 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', () => { describe('setDefaultHomeActiveTabName', () => {