aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-07-28 06:10:02 +0800
committerDan Finlay <dan@danfinlay.com>2017-07-28 06:10:02 +0800
commitf8cadbcb323f2d41d6a2cad78479917f20b113bd (patch)
tree3f1dc1e4d399b26ef929d4a0d51ded3c11c814fc /test
parent8ba32d5ea8cbd30b85cade9fccaaa6c0f3f5cd04 (diff)
parente3b5bb2052d59afbf9c2761af883de719261062e (diff)
downloadtangerine-wallet-browser-f8cadbcb323f2d41d6a2cad78479917f20b113bd.tar
tangerine-wallet-browser-f8cadbcb323f2d41d6a2cad78479917f20b113bd.tar.gz
tangerine-wallet-browser-f8cadbcb323f2d41d6a2cad78479917f20b113bd.tar.bz2
tangerine-wallet-browser-f8cadbcb323f2d41d6a2cad78479917f20b113bd.tar.lz
tangerine-wallet-browser-f8cadbcb323f2d41d6a2cad78479917f20b113bd.tar.xz
tangerine-wallet-browser-f8cadbcb323f2d41d6a2cad78479917f20b113bd.tar.zst
tangerine-wallet-browser-f8cadbcb323f2d41d6a2cad78479917f20b113bd.zip
Merge branch 'master' into NewUI
Diffstat (limited to 'test')
-rw-r--r--test/unit/blacklister-test.js24
-rw-r--r--test/unit/network-contoller-test.js36
-rw-r--r--test/unit/nonce-tracker-test.js8
-rw-r--r--test/unit/tx-controller-test.js8
4 files changed, 56 insertions, 20 deletions
diff --git a/test/unit/blacklister-test.js b/test/unit/blacklister-test.js
new file mode 100644
index 000000000..d9290795c
--- /dev/null
+++ b/test/unit/blacklister-test.js
@@ -0,0 +1,24 @@
+const assert = require('assert')
+const Blacklister = require('../../app/scripts/blacklister')
+
+
+describe('blacklister', function () {
+ describe('#isPhish', function () {
+ it('should not flag whitelisted values', function () {
+ var result = Blacklister('www.metamask.io')
+ assert(!result)
+ })
+ it('should flag explicit values', function () {
+ var result = Blacklister('metamask.com')
+ assert(result)
+ })
+ it('should flag levenshtein values', function () {
+ var result = Blacklister('metmask.io')
+ assert(result)
+ })
+ it('should not flag not-even-close values', function () {
+ var result = Blacklister('example.com')
+ assert(!result)
+ })
+ })
+})
diff --git a/test/unit/network-contoller-test.js b/test/unit/network-contoller-test.js
index 0c7ee9d70..87c2ee7a3 100644
--- a/test/unit/network-contoller-test.js
+++ b/test/unit/network-contoller-test.js
@@ -3,6 +3,9 @@ const NetworkController = require('../../app/scripts/controllers/network')
describe('# Network Controller', function () {
let networkController
+ const networkControllerProviderInit = {
+ getAccounts: () => {},
+ }
beforeEach(function () {
networkController = new NetworkController({
@@ -10,26 +13,13 @@ describe('# Network Controller', function () {
type: 'rinkeby',
},
})
- // stub out provider
- networkController._provider = new Proxy({}, {
- get: (obj, name) => {
- return () => {}
- },
- })
- networkController.providerInit = {
- getAccounts: () => {},
- }
- networkController.ethQuery = new Proxy({}, {
- get: (obj, name) => {
- return () => {}
- },
- })
+ networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
})
describe('network', function () {
describe('#provider', function () {
it('provider should be updatable without reassignment', function () {
- networkController.initializeProvider(networkController.providerInit)
+ networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
const provider = networkController.provider
networkController._provider = {test: true}
assert.ok(provider.test)
@@ -75,3 +65,19 @@ describe('# Network Controller', function () {
})
})
})
+
+function dummyProviderConstructor() {
+ return {
+ // provider
+ sendAsync: noop,
+ // block tracker
+ start: noop,
+ stop: noop,
+ on: noop,
+ addListener: noop,
+ once: noop,
+ removeAllListeners: noop,
+ }
+}
+
+function noop() {} \ No newline at end of file
diff --git a/test/unit/nonce-tracker-test.js b/test/unit/nonce-tracker-test.js
index 16cd6d008..b0283e159 100644
--- a/test/unit/nonce-tracker-test.js
+++ b/test/unit/nonce-tracker-test.js
@@ -18,11 +18,13 @@ describe('Nonce Tracker', function () {
getPendingTransactions = () => pendingTxs
- provider = { sendAsync: (_, cb) => { cb(undefined, {result: '0x0'}) } }
- nonceTracker = new NonceTracker({
- blockTracker: {
+ provider = {
+ sendAsync: (_, cb) => { cb(undefined, {result: '0x0'}) },
+ _blockTracker: {
getCurrentBlock: () => '0x11b568',
},
+ }
+ nonceTracker = new NonceTracker({
provider,
getPendingTransactions,
})
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index 7b86cfe14..31908569a 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -343,13 +343,17 @@ describe('Transaction Controller', function () {
// Adding the fake tx:
txController.addTx(clone(txMeta))
- txController._resubmitTx(txMeta, function (err) {
- assert.ifError(err, 'should not throw an error')
+ txController._resubmitTx(txMeta)
+ .then(() => {
const updatedMeta = txController.getTx(txMeta.id)
assert.notEqual(updatedMeta.status, txMeta.status, 'status changed.')
assert.equal(updatedMeta.status, 'failed', 'tx set to failed.')
done()
})
+ .catch((err) => {
+ assert.ifError(err, 'should not throw an error')
+ done()
+ })
})
})
})