mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Adding unit test case to for idempotent behaviour of importAccountWithStrategy idempotent (#15583)
This commit is contained in:
parent
29e252e162
commit
637d4bcf2c
@ -32,6 +32,9 @@ const createLoggerMiddlewareMock = () => (req, res, next) => {
|
|||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const TEST_SEED =
|
||||||
|
'debris dizzy just program just float decrease vacant alarm reduce speak stadium';
|
||||||
|
|
||||||
const MetaMaskController = proxyquire('./metamask-controller', {
|
const MetaMaskController = proxyquire('./metamask-controller', {
|
||||||
'./lib/createLoggerMiddleware': { default: createLoggerMiddlewareMock },
|
'./lib/createLoggerMiddleware': { default: createLoggerMiddlewareMock },
|
||||||
}).default;
|
}).default;
|
||||||
@ -106,6 +109,63 @@ describe('MetaMaskController', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#importAccountWithStrategy', function () {
|
||||||
|
it('two sequential calls with same strategy give same result', async function () {
|
||||||
|
let keyringControllerState1;
|
||||||
|
let keyringControllerState2;
|
||||||
|
const importPrivkey =
|
||||||
|
'4cfd3e90fc78b0f86bf7524722150bb8da9c60cd532564d7ff43f5716514f553';
|
||||||
|
|
||||||
|
await metamaskController.createNewVaultAndKeychain('test@123');
|
||||||
|
await Promise.all([
|
||||||
|
metamaskController.importAccountWithStrategy('Private Key', [
|
||||||
|
importPrivkey,
|
||||||
|
]),
|
||||||
|
Promise.resolve(1).then(() => {
|
||||||
|
keyringControllerState1 = JSON.stringify(
|
||||||
|
metamaskController.keyringController.memStore.getState(),
|
||||||
|
);
|
||||||
|
metamaskController.importAccountWithStrategy('Private Key', [
|
||||||
|
importPrivkey,
|
||||||
|
]);
|
||||||
|
}),
|
||||||
|
Promise.resolve(2).then(() => {
|
||||||
|
keyringControllerState2 = JSON.stringify(
|
||||||
|
metamaskController.keyringController.memStore.getState(),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
assert.deepEqual(keyringControllerState1, keyringControllerState2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#createNewVaultAndRestore', function () {
|
||||||
|
it('two successive calls with same inputs give same result', async function () {
|
||||||
|
const result1 = await metamaskController.createNewVaultAndRestore(
|
||||||
|
'test@123',
|
||||||
|
TEST_SEED,
|
||||||
|
);
|
||||||
|
const result2 = await metamaskController.createNewVaultAndRestore(
|
||||||
|
'test@123',
|
||||||
|
TEST_SEED,
|
||||||
|
);
|
||||||
|
assert.deepEqual(result1, result2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#createNewVaultAndKeychain', function () {
|
||||||
|
it('two successive calls with same inputs give same result', async function () {
|
||||||
|
const result1 = await metamaskController.createNewVaultAndKeychain(
|
||||||
|
'test@123',
|
||||||
|
);
|
||||||
|
const result2 = await metamaskController.createNewVaultAndKeychain(
|
||||||
|
'test@123',
|
||||||
|
);
|
||||||
|
assert.notEqual(result1, undefined);
|
||||||
|
assert.deepEqual(result1, result2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#addToken', function () {
|
describe('#addToken', function () {
|
||||||
const address = '0x514910771af9ca656af840dff83e8264ecf986ca';
|
const address = '0x514910771af9ca656af840dff83e8264ecf986ca';
|
||||||
const symbol = 'LINK';
|
const symbol = 'LINK';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user