aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorEsteban MIno <efmino@uc.cl>2018-07-13 08:43:43 +0800
committerEsteban MIno <efmino@uc.cl>2018-07-13 08:43:43 +0800
commit2fffe098736e2461b9238c7dcd91f9ef3d61dcc1 (patch)
tree14bf2a51d61723d3cbb6cc7acedd851c1cb0d84e /test/unit
parent910713c6b3c5b8f865fdcb989bfe3ee0b14eb364 (diff)
downloadtangerine-wallet-browser-2fffe098736e2461b9238c7dcd91f9ef3d61dcc1.tar
tangerine-wallet-browser-2fffe098736e2461b9238c7dcd91f9ef3d61dcc1.tar.gz
tangerine-wallet-browser-2fffe098736e2461b9238c7dcd91f9ef3d61dcc1.tar.bz2
tangerine-wallet-browser-2fffe098736e2461b9238c7dcd91f9ef3d61dcc1.tar.lz
tangerine-wallet-browser-2fffe098736e2461b9238c7dcd91f9ef3d61dcc1.tar.xz
tangerine-wallet-browser-2fffe098736e2461b9238c7dcd91f9ef3d61dcc1.tar.zst
tangerine-wallet-browser-2fffe098736e2461b9238c7dcd91f9ef3d61dcc1.zip
detect tokens through infura
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/app/controllers/detect-tokens-test.js26
1 files changed, 17 insertions, 9 deletions
diff --git a/test/unit/app/controllers/detect-tokens-test.js b/test/unit/app/controllers/detect-tokens-test.js
index dca48c6bb..860ed7050 100644
--- a/test/unit/app/controllers/detect-tokens-test.js
+++ b/test/unit/app/controllers/detect-tokens-test.js
@@ -1,8 +1,8 @@
const assert = require('assert')
const sinon = require('sinon')
const DetectTokensController = require('../../../../app/scripts/controllers/detect-tokens')
+const NetworkController = require('../../../../app/scripts/controllers/network/network')
const PreferencesController = require('../../../../app/scripts/controllers/preferences')
-const ObservableStore = require('obs-store')
describe('DetectTokensController', () => {
const sandbox = sinon.createSandbox()
@@ -22,7 +22,8 @@ describe('DetectTokensController', () => {
it('should be called on every polling period', async () => {
clock = sandbox.useFakeTimers()
- const network = new ObservableStore({provider: {type: 'mainnet'}})
+ const network = new NetworkController()
+ network.setProviderType('mainnet')
const preferences = new PreferencesController()
const controller = new DetectTokensController({preferences: preferences, network: network})
controller.isActive = true
@@ -40,7 +41,8 @@ describe('DetectTokensController', () => {
})
it('should not check tokens while in test network', async () => {
- var network = new ObservableStore({provider: {type: 'rinkeby'}})
+ const network = new NetworkController()
+ network.setProviderType('rinkeby')
const preferences = new PreferencesController()
const controller = new DetectTokensController({preferences: preferences, network: network})
controller.isActive = true
@@ -54,14 +56,17 @@ describe('DetectTokensController', () => {
})
it('should only check and add tokens while in main network', async () => {
- const network = new ObservableStore({provider: {type: 'mainnet'}})
+ const network = new NetworkController()
+ network.setProviderType('mainnet')
const preferences = new PreferencesController()
const controller = new DetectTokensController({preferences: preferences, network: network})
controller.isActive = true
sandbox.stub(controller, 'detectTokenBalance')
- .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4').returns(true)
- .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388').returns(true)
+ .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4')
+ .returns(preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8))
+ .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388')
+ .returns(preferences.addToken('0xbc86727e770de68b1060c91f6bb6945c73e10388', 'XNK', 18))
await controller.exploreNewTokens()
assert.deepEqual(preferences.store.getState().tokens, [{address: '0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', decimals: 8, symbol: 'J8T'},
@@ -69,15 +74,18 @@ describe('DetectTokensController', () => {
})
it('should not detect same token while in main network', async () => {
- const network = new ObservableStore({provider: {type: 'mainnet'}})
+ const network = new NetworkController()
+ network.setProviderType('mainnet')
const preferences = new PreferencesController()
preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8)
const controller = new DetectTokensController({preferences: preferences, network: network})
controller.isActive = true
sandbox.stub(controller, 'detectTokenBalance')
- .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4').returns(true)
- .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388').returns(true)
+ .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4')
+ .returns(preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8))
+ .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388')
+ .returns(preferences.addToken('0xbc86727e770de68b1060c91f6bb6945c73e10388', 'XNK', 18))
await controller.exploreNewTokens()
assert.deepEqual(preferences.store.getState().tokens, [{address: '0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', decimals: 8, symbol: 'J8T'},