1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Add test case to ensure that action addCustomNetwork is idempotent (#15602)

This commit is contained in:
Jyoti Puri 2022-08-19 01:09:04 +05:30 committed by GitHub
parent f2514c88cf
commit f15d8e2f9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,10 +90,8 @@ describe('MetaMaskController', function () {
it('two successive calls with same accountCount give same result', async function () {
await metamaskController.createNewVaultAndKeychain('test@123');
const [addNewAccountResult1, addNewAccountResult2] = await Promise.all([
metamaskController.addNewAccount(1),
Promise.resolve(1).then(() => metamaskController.addNewAccount(1)),
]);
const addNewAccountResult1 = await metamaskController.addNewAccount(1);
const addNewAccountResult2 = await metamaskController.addNewAccount(1);
assert.deepEqual(
Object.keys(addNewAccountResult1.identities),
Object.keys(addNewAccountResult2.identities),
@ -107,4 +105,25 @@ describe('MetaMaskController', function () {
assert.notDeepEqual(addNewAccountResult1, addNewAccountResult2);
});
});
describe('#addCustomNetwork', function () {
const customRpc = {
chainId: '0x1',
chainName: 'DUMMY_CHAIN_NAME',
rpcUrl: 'DUMMY_RPCURL',
ticker: 'DUMMY_TICKER',
blockExplorerUrl: 'DUMMY_EXPLORER',
};
it('two calls with same accountCount give same result', async function () {
await metamaskController.addCustomNetwork(customRpc);
const rpcList1Length =
metamaskController.preferencesController.store.getState()
.frequentRpcListDetail.length;
await metamaskController.addCustomNetwork(customRpc);
const rpcList2Length =
metamaskController.preferencesController.store.getState()
.frequentRpcListDetail.length;
assert.equal(rpcList1Length, rpcList2Length);
});
});
});