mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
8ee733c0d5
* adds listeners for signatureControll and adds the handleSigningEvents method * clean up * updates signature request containers files * adds necessary methods * wip * signing flow with core methods * yarn lint * updates logic to fit latest signatureCOntroller * updates mmi extension package * updates signature-controller and message-manager packages * checkout develop lock file and run yarn * checkout develop lock file and package.json to test circleci * test fix * adds signature-controller new version * updates mmi extension package * tx-list update and runs lavamoat auto * lint fix * runs lavamoat auto * resets lavamoat/build-system/policy.jsono to develop * Update LavaMoat policies * adds back the dispatch * lint * clean up * clean up * applies patch for signature controller * clean patch file --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
145 lines
4.6 KiB
JavaScript
145 lines
4.6 KiB
JavaScript
/* eslint-disable */
|
|
import { KeyringController } from '@metamask/eth-keyring-controller';
|
|
import { MmiConfigurationController } from '@metamask-institutional/custody-keyring';
|
|
import { TransactionUpdateController } from '@metamask-institutional/transaction-update';
|
|
import { SignatureController } from '@metamask/signature-controller';
|
|
|
|
import MMIController from './mmi-controller';
|
|
import TransactionController from './transactions';
|
|
import PreferencesController from './preferences';
|
|
import AppStateController from './app-state';
|
|
|
|
describe('MMIController', function () {
|
|
let mmiController;
|
|
|
|
beforeEach(function () {
|
|
mmiController = new MMIController({
|
|
mmiConfigurationController: new MmiConfigurationController(),
|
|
keyringController: new KeyringController({
|
|
initState: {},
|
|
}),
|
|
transactionUpdateController: new TransactionUpdateController({
|
|
getCustodyKeyring: jest.fn(),
|
|
}),
|
|
txController: new TransactionController({
|
|
initState: {},
|
|
provider: {
|
|
chainId: 'fail',
|
|
nickname: '',
|
|
rpcTarget: 'https://api.myetherwallet.com/eth',
|
|
ticker: 'ETH',
|
|
type: 'rinkeby',
|
|
},
|
|
getCurrentChainId: jest.fn(),
|
|
getNetworkId: jest.fn(),
|
|
onNetworkStateChange: jest.fn(),
|
|
}),
|
|
signatureController: new SignatureController({
|
|
messenger: {
|
|
registerActionHandler: jest.fn(),
|
|
publish: jest.fn(),
|
|
call: jest.fn(),
|
|
},
|
|
keyringController: new KeyringController({
|
|
initState: {},
|
|
}),
|
|
isEthSignEnabled: jest.fn(),
|
|
getAllState: jest.fn(),
|
|
securityProviderRequest: jest.fn(),
|
|
getCurrentChainId: jest.fn(),
|
|
}),
|
|
preferencesController: new PreferencesController({
|
|
initState: {},
|
|
onInfuraIsBlocked: jest.fn(),
|
|
onInfuraIsUnblocked: jest.fn(),
|
|
provider: {},
|
|
}),
|
|
appStateController: new AppStateController({
|
|
addUnlockListener: jest.fn(),
|
|
isUnlocked: jest.fn(() => true),
|
|
initState: {},
|
|
onInactiveTimeout: jest.fn(),
|
|
showUnlockRequest: jest.fn(),
|
|
preferencesStore: {
|
|
subscribe: jest.fn(),
|
|
getState: jest.fn(() => ({
|
|
preferences: {
|
|
autoLockTimeLimit: 0,
|
|
},
|
|
})),
|
|
},
|
|
qrHardwareStore: {
|
|
subscribe: jest.fn(),
|
|
},
|
|
messenger: {
|
|
call: jest.fn(() => ({
|
|
catch: jest.fn(),
|
|
})),
|
|
},
|
|
}),
|
|
custodianEventHandlerFactory: jest.fn(),
|
|
});
|
|
});
|
|
|
|
describe('mmiController constructor', function () {
|
|
it('should instantiate correctly', function () {
|
|
expect(mmiController).toBeInstanceOf(MMIController);
|
|
});
|
|
|
|
it('should have all required properties', function () {
|
|
expect(mmiController.opts).toBeDefined();
|
|
expect(mmiController.mmiConfigurationController).toBeDefined();
|
|
expect(mmiController.preferencesController).toBeDefined();
|
|
expect(mmiController.transactionUpdateController).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('persistKeyringsAfterRefreshTokenChange', function () {
|
|
it('should call keyringController.persistAllKeyrings', async function () {
|
|
mmiController.keyringController.persistAllKeyrings = jest.fn();
|
|
|
|
await mmiController.persistKeyringsAfterRefreshTokenChange();
|
|
|
|
expect(
|
|
mmiController.keyringController.persistAllKeyrings,
|
|
).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('trackTransactionEventFromCustodianEvent', function () {
|
|
it('should call txController._trackTransactionMetricsEvent', function () {
|
|
const txMeta = {};
|
|
const event = 'event';
|
|
mmiController.txController._trackTransactionMetricsEvent = jest.fn();
|
|
|
|
mmiController.trackTransactionEventFromCustodianEvent(txMeta, event);
|
|
|
|
expect(
|
|
mmiController.txController._trackTransactionMetricsEvent,
|
|
).toHaveBeenCalledWith(txMeta, event);
|
|
});
|
|
});
|
|
|
|
describe('custodianEventHandlerFactory', function () {
|
|
it('should call custodianEventHandlerFactory', async function () {
|
|
mmiController.custodianEventHandlerFactory = jest.fn();
|
|
|
|
mmiController.custodianEventHandlerFactory();
|
|
|
|
expect(mmiController.custodianEventHandlerFactory).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('storeCustodianSupportedChains', function () {
|
|
it('should call storeCustodianSupportedChains', async function () {
|
|
mmiController.storeCustodianSupportedChains = jest.fn();
|
|
|
|
mmiController.storeCustodianSupportedChains('0x1');
|
|
|
|
expect(mmiController.storeCustodianSupportedChains).toHaveBeenCalledWith(
|
|
'0x1',
|
|
);
|
|
});
|
|
});
|
|
});
|