From df3169d1c7250d13bb8bc123dc91f7913ad75a81 Mon Sep 17 00:00:00 2001 From: Frankie Date: Tue, 29 Jan 2019 08:13:51 -1000 Subject: I#5956 fix2 dont overwrite existing rpc settings (#6044) * mm-controller - dont overwrite existing rpc settings * ui-networkDropdown - dont pass old network as chainId * add methods preferencesController.updateRpc and metamaskController.updateAndSetCustomRpc * use updateAndSetCustomRpc in settings to allow rpcs to be updated * use new rpc as nickname if no nick name has been supplied * fix update rpc method --- test/unit/app/controllers/preferences-controller-test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/unit/app/controllers') diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index 67d1875c1..558597ae7 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -511,6 +511,18 @@ describe('preferences controller', function () { }) }) + describe('#updateRpc', function () { + it('should update the rpcDetails properly', () => { + preferencesController.store.updateState({frequentRpcListDetail: [{}, { rpcUrl: 'test' }, {}]}) + preferencesController.updateRpc({ rpcUrl: 'test', chainId: 1 }) + preferencesController.updateRpc({ rpcUrl: 'test/1', chainId: 1 }) + preferencesController.updateRpc({ rpcUrl: 'test/2', chainId: 1 }) + preferencesController.updateRpc({ rpcUrl: 'test/3', chainId: 1 }) + const list = preferencesController.getFrequentRpcListDetail() + assert.deepEqual(list[1], { rpcUrl: 'test', chainId: 1 }) + }) + }) + describe('on updateFrequentRpcList', function () { it('should add custom RPC url to state', function () { preferencesController.addToFrequentRpcList('rpc_url', 1) -- cgit