From db982cf795d30dd32b4722249daea9296430b5b9 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Wed, 24 May 2017 11:52:18 -0400 Subject: [PATCH 1/2] stop polling when switching networks --- app/scripts/controllers/network.js | 1 + test/unit/network-contoller-test.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/network.js b/app/scripts/controllers/network.js index 4fdd92921..c07f13b8d 100644 --- a/app/scripts/controllers/network.js +++ b/app/scripts/controllers/network.js @@ -53,6 +53,7 @@ module.exports = class NetworkController extends EventEmitter { this.providerInit = newInit this._provider.removeAllListeners() + this._provider.stop() this.provider = MetaMaskProvider(newInit) // apply the listners created by other controllers Object.keys(this._providerListeners).forEach((key) => { diff --git a/test/unit/network-contoller-test.js b/test/unit/network-contoller-test.js index 183e69cab..46f473af2 100644 --- a/test/unit/network-contoller-test.js +++ b/test/unit/network-contoller-test.js @@ -12,7 +12,11 @@ describe('# Network Controller', function () { }, }) // stub out provider - networkController._provider = new EventEmitter() + networkController._provider = new Proxy(new EventEmitter(), { + get: (obj, name) => { + return () => {} + }, + }) networkController.providerInit = { getAccounts: () => {}, } From e23c0f98faef3282d684bba48a53a1f48425b52d Mon Sep 17 00:00:00 2001 From: frankiebee Date: Wed, 24 May 2017 11:57:31 -0400 Subject: [PATCH 2/2] clean up test --- test/unit/network-contoller-test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/unit/network-contoller-test.js b/test/unit/network-contoller-test.js index 46f473af2..76452b303 100644 --- a/test/unit/network-contoller-test.js +++ b/test/unit/network-contoller-test.js @@ -1,4 +1,3 @@ -const EventEmitter = require('events') const assert = require('assert') const NetworkController = require('../../app/scripts/controllers/network') @@ -12,7 +11,7 @@ describe('# Network Controller', function () { }, }) // stub out provider - networkController._provider = new Proxy(new EventEmitter(), { + networkController._provider = new Proxy({}, { get: (obj, name) => { return () => {} },