aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-05-23 14:12:28 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-05-24 07:49:57 +0800
commit243eeff7cb0d4c5d613a9250d234f81fdccbbf15 (patch)
tree406aa8da0a12fa542cf85c2838cbf94cc324ddaf /test
parent529304c005318852b60bb93846a58d6eb3da2066 (diff)
downloadtangerine-wallet-browser-243eeff7cb0d4c5d613a9250d234f81fdccbbf15.tar
tangerine-wallet-browser-243eeff7cb0d4c5d613a9250d234f81fdccbbf15.tar.gz
tangerine-wallet-browser-243eeff7cb0d4c5d613a9250d234f81fdccbbf15.tar.bz2
tangerine-wallet-browser-243eeff7cb0d4c5d613a9250d234f81fdccbbf15.tar.lz
tangerine-wallet-browser-243eeff7cb0d4c5d613a9250d234f81fdccbbf15.tar.xz
tangerine-wallet-browser-243eeff7cb0d4c5d613a9250d234f81fdccbbf15.tar.zst
tangerine-wallet-browser-243eeff7cb0d4c5d613a9250d234f81fdccbbf15.zip
Fix for tests
Diffstat (limited to 'test')
-rw-r--r--test/unit/network-contoller-test.js74
-rw-r--r--test/unit/tx-controller-test.js4
-rw-r--r--test/unit/tx-utils-test.js6
3 files changed, 82 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..183e69cab
--- /dev/null
+++ b/test/unit/network-contoller-test.js
@@ -0,0 +1,74 @@
+const EventEmitter = require('events')
+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 EventEmitter()
+ 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 () {