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:
parent
f2514c88cf
commit
f15d8e2f9b
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user