diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-07-12 06:52:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-12 06:52:19 +0800 |
commit | 6811fb26793ca71989df2f0c0604e72cbf03ca23 (patch) | |
tree | de84f20d9ac31151c27be26af0670c09dc5ae192 /test | |
parent | de967d2dfd2119d2468263ecb9646fd0a92df195 (diff) | |
parent | 91ef01be4c2c0a39107e1200c5f94fa5fc7defb7 (diff) | |
download | tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.gz tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.bz2 tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.lz tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.xz tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.zst tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.zip |
Merge branch 'master' into 3.8.5
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/infura-controller-test.js | 66 | ||||
-rw-r--r-- | test/unit/tx-utils-test.js | 38 |
2 files changed, 71 insertions, 33 deletions
diff --git a/test/unit/infura-controller-test.js b/test/unit/infura-controller-test.js index 7a2a114f9..912867764 100644 --- a/test/unit/infura-controller-test.js +++ b/test/unit/infura-controller-test.js @@ -1,34 +1,34 @@ // polyfill fetch -global.fetch = function () {return Promise.resolve({ - json: () => { return Promise.resolve({"mainnet": "ok", "ropsten": "degraded", "kovan": "down", "rinkeby": "ok"}) }, - }) -} -const assert = require('assert') -const InfuraController = require('../../app/scripts/controllers/infura') - -describe('infura-controller', function () { - var infuraController - - beforeEach(function () { - infuraController = new InfuraController() - }) - - describe('network status queries', function () { - describe('#checkInfuraNetworkStatus', function () { - it('should return an object reflecting the network statuses', function (done) { - this.timeout(15000) - infuraController.checkInfuraNetworkStatus() - .then(() => { - const networkStatus = infuraController.store.getState().infuraNetworkStatus - assert.equal(Object.keys(networkStatus).length, 4) - assert.equal(networkStatus.mainnet, 'ok') - assert.equal(networkStatus.ropsten, 'degraded') - assert.equal(networkStatus.kovan, 'down') - }) - .then(() => done()) - .catch(done) - - }) - }) - }) -}) +// global.fetch = function () {return Promise.resolve({ +// json: () => { return Promise.resolve({"mainnet": "ok", "ropsten": "degraded", "kovan": "down", "rinkeby": "ok"}) }, +// }) +// } +// const assert = require('assert') +// const InfuraController = require('../../app/scripts/controllers/infura') +// +// describe('infura-controller', function () { +// var infuraController +// +// beforeEach(function () { +// infuraController = new InfuraController() +// }) +// +// describe('network status queries', function () { +// describe('#checkInfuraNetworkStatus', function () { +// it('should return an object reflecting the network statuses', function (done) { +// this.timeout(15000) +// infuraController.checkInfuraNetworkStatus() +// .then(() => { +// const networkStatus = infuraController.store.getState().infuraNetworkStatus +// assert.equal(Object.keys(networkStatus).length, 4) +// assert.equal(networkStatus.mainnet, 'ok') +// assert.equal(networkStatus.ropsten, 'degraded') +// assert.equal(networkStatus.kovan, 'down') +// }) +// .then(() => done()) +// .catch(done) +// +// }) +// }) +// }) +// }) diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js index 7ace1f587..a43bcfb35 100644 --- a/test/unit/tx-utils-test.js +++ b/test/unit/tx-utils-test.js @@ -16,6 +16,44 @@ describe('txUtils', function () { })) }) + describe('#sufficientBalance', function () { + it('returns true if max tx cost is equal to balance.', function () { + const tx = { + 'value': '0x1', + 'gas': '0x2', + 'gasPrice': '0x3', + } + const balance = '0x8' + + const result = txUtils.sufficientBalance(tx, balance) + assert.ok(result, 'sufficient balance found.') + }) + + it('returns true if max tx cost is less than balance.', function () { + const tx = { + 'value': '0x1', + 'gas': '0x2', + 'gasPrice': '0x3', + } + const balance = '0x9' + + const result = txUtils.sufficientBalance(tx, balance) + assert.ok(result, 'sufficient balance found.') + }) + + it('returns false if max tx cost is more than balance.', function () { + const tx = { + 'value': '0x1', + 'gas': '0x2', + 'gasPrice': '0x3', + } + const balance = '0x6' + + const result = txUtils.sufficientBalance(tx, balance) + assert.ok(!result, 'insufficient balance found.') + }) + }) + describe('chain Id', function () { it('prepares a transaction with the provided chainId', function () { const txParams = { |