aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-07-12 06:52:19 +0800
committerGitHub <noreply@github.com>2017-07-12 06:52:19 +0800
commit6811fb26793ca71989df2f0c0604e72cbf03ca23 (patch)
treede84f20d9ac31151c27be26af0670c09dc5ae192 /test
parentde967d2dfd2119d2468263ecb9646fd0a92df195 (diff)
parent91ef01be4c2c0a39107e1200c5f94fa5fc7defb7 (diff)
downloadtangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.gz
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.js66
-rw-r--r--test/unit/tx-utils-test.js38
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 = {