diff options
author | Kevin Serrano <kevin.serrano@consensys.net> | 2017-05-25 00:55:32 +0800 |
---|---|---|
committer | Kevin Serrano <kevin.serrano@consensys.net> | 2017-05-25 00:55:32 +0800 |
commit | 45285a5a2f0776787bd1e7ecd9b49c5d5456cd06 (patch) | |
tree | b7cc0da01f95478a943fe074870277fcc76d5b88 /test/unit | |
parent | 60281f72506c6b1775e75e8426a09d91893ab6ac (diff) | |
parent | d06a812004a5acc0a26fcdd5c29254b17fca25a0 (diff) | |
download | tangerine-wallet-browser-45285a5a2f0776787bd1e7ecd9b49c5d5456cd06.tar tangerine-wallet-browser-45285a5a2f0776787bd1e7ecd9b49c5d5456cd06.tar.gz tangerine-wallet-browser-45285a5a2f0776787bd1e7ecd9b49c5d5456cd06.tar.bz2 tangerine-wallet-browser-45285a5a2f0776787bd1e7ecd9b49c5d5456cd06.tar.lz tangerine-wallet-browser-45285a5a2f0776787bd1e7ecd9b49c5d5456cd06.tar.xz tangerine-wallet-browser-45285a5a2f0776787bd1e7ecd9b49c5d5456cd06.tar.zst tangerine-wallet-browser-45285a5a2f0776787bd1e7ecd9b49c5d5456cd06.zip |
Merge branch 'master' into i1412-decimalizethegas
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/network-contoller-test.js | 77 | ||||
-rw-r--r-- | test/unit/tx-controller-test.js | 4 | ||||
-rw-r--r-- | test/unit/tx-utils-test.js | 6 |
3 files changed, 85 insertions, 2 deletions
diff --git a/test/unit/network-contoller-test.js b/test/unit/network-contoller-test.js new file mode 100644 index 000000000..76452b303 --- /dev/null +++ b/test/unit/network-contoller-test.js @@ -0,0 +1,77 @@ +const assert = require('assert') +const NetworkController = require('../../app/scripts/controllers/network') + +describe('# Network Controller', function () { + let networkController + + beforeEach(function () { + networkController = new NetworkController({ + provider: { + type: 'rinkeby', + }, + }) + // stub out provider + networkController._provider = new Proxy({}, { + get: (obj, name) => { + return () => {} + }, + }) + networkController.providerInit = { + getAccounts: () => {}, + } + + networkController.ethQuery = new Proxy({}, { + get: (obj, name) => { + return () => {} + }, + }) + }) + describe('network', function () { + describe('#provider', function() { + it('provider should be updatable without reassignment', function () { + networkController.initializeProvider(networkController.providerInit) + const provider = networkController.provider + networkController._provider = {test: true} + assert.ok(provider.test) + }) + }) + describe('#getNetworkState', function () { + it('should return loading when new', function () { + let networkState = networkController.getNetworkState() + assert.equal(networkState, 'loading', 'network is loading') + }) + }) + + describe('#setNetworkState', function () { + it('should update the network', function () { + networkController.setNetworkState(1) + let networkState = networkController.getNetworkState() + assert.equal(networkState, 1, 'network is 1') + }) + }) + + describe('#getRpcAddressForType', function () { + it('should return the right rpc address', function () { + let rpcTarget = networkController.getRpcAddressForType('mainnet') + assert.equal(rpcTarget, 'https://mainnet.infura.io/metamask', 'returns the right rpcAddress') + }) + }) + describe('#setProviderType', function () { + it('should update provider.type', function () { + networkController.setProviderType('mainnet') + const type = networkController.getProviderConfig().type + assert.equal(type, 'mainnet', 'provider type is updated') + }) + it('should set the network to loading', function () { + networkController.setProviderType('mainnet') + const loading = networkController.isNetworkLoading() + assert.ok(loading, 'network is loading') + }) + it('should set the right rpcTarget', function () { + networkController.setProviderType('mainnet') + const rpcTarget = networkController.getProviderConfig().rpcTarget + assert.equal(rpcTarget, 'https://mainnet.infura.io/metamask', 'returns the right rpcAddress') + }) + }) + }) +}) diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index d4e8d79f0..711e1ea79 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -2,6 +2,7 @@ const assert = require('assert') const EventEmitter = require('events') const ethUtil = require('ethereumjs-util') const EthTx = require('ethereumjs-tx') +const EthQuery = require('eth-query') const ObservableStore = require('obs-store') const clone = require('clone') const sinon = require('sinon') @@ -16,9 +17,10 @@ describe('Transaction Controller', function () { beforeEach(function () { txController = new TransactionController({ - networkStore: new ObservableStore({ network: currentNetworkId }), + networkStore: new ObservableStore(currentNetworkId), txHistoryLimit: 10, blockTracker: new EventEmitter(), + ethQuery: new EthQuery(new EventEmitter()), signTransaction: (ethTx) => new Promise((resolve) => { ethTx.sign(privKey) resolve() diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js index 57d4638a0..7ace1f587 100644 --- a/test/unit/tx-utils-test.js +++ b/test/unit/tx-utils-test.js @@ -9,7 +9,11 @@ describe('txUtils', function () { let txUtils before(function () { - txUtils = new TxUtils() + txUtils = new TxUtils(new Proxy({}, { + get: (obj, name) => { + return () => {} + }, + })) }) describe('chain Id', function () { |