aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tmashuang@gmail.com>2018-04-25 04:33:31 +0800
committerThomas <tmashuang@gmail.com>2018-04-25 04:33:31 +0800
commit629457ea5460a1841d4682a234d6a6fb330517f9 (patch)
treee1344633500b54fb1cab73ca2aa8e76071ff53af
parent010092312998e90688e1bfb004eb55c67a337429 (diff)
downloadtangerine-wallet-browser-629457ea5460a1841d4682a234d6a6fb330517f9.tar.gz
tangerine-wallet-browser-629457ea5460a1841d4682a234d6a6fb330517f9.tar.zst
tangerine-wallet-browser-629457ea5460a1841d4682a234d6a6fb330517f9.zip
setupUntrustedCommunication and setupTrustedCommunication
-rw-r--r--package.json2
-rw-r--r--test/unit/metamask-controller-test.js45
2 files changed, 46 insertions, 1 deletions
diff --git a/package.json b/package.json
index 2c5b05547..da9f1b14d 100644
--- a/package.json
+++ b/package.json
@@ -181,7 +181,6 @@
"sw-controller": "^1.0.3",
"sw-stream": "^2.0.2",
"textarea-caret": "^3.0.1",
- "through2": "^2.0.3",
"valid-url": "^1.0.9",
"vreme": "^3.0.2",
"web3": "^0.20.1",
@@ -272,6 +271,7 @@
"stylelint-config-standard": "^18.2.0",
"tape": "^4.5.1",
"testem": "^2.0.0",
+ "through2": "^2.0.3",
"uglifyify": "^4.0.5",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
diff --git a/test/unit/metamask-controller-test.js b/test/unit/metamask-controller-test.js
index c9d041f01..acf105d4d 100644
--- a/test/unit/metamask-controller-test.js
+++ b/test/unit/metamask-controller-test.js
@@ -2,6 +2,7 @@ const assert = require('assert')
const sinon = require('sinon')
const clone = require('clone')
const nock = require('nock')
+const createThoughStream = require('through2').obj
const MetaMaskController = require('../../app/scripts/metamask-controller')
const blacklistJSON = require('../stub/blacklist')
const firstTimeState = require('../../app/scripts/first-time-state')
@@ -187,6 +188,10 @@ describe('MetaMaskController', function () {
rpcTarget = metamaskController.setCustomRpc(customRPC)
})
+ afterEach(function () {
+ nock.cleanAll()
+ })
+
it('returns custom RPC that when called', async function () {
assert.equal(await rpcTarget, customRPC)
})
@@ -484,6 +489,46 @@ describe('MetaMaskController', function () {
})
})
+ describe('#setupUntrustedCommunication', function () {
+ let streamTest
+
+ const phishingUrl = 'decentral.market'
+
+ afterEach(function () {
+ streamTest.end()
+ })
+
+ it('sets up phishing stream for untrusted communication ', async function () {
+ await metamaskController.blacklistController.updatePhishingList()
+
+ streamTest = createThoughStream((chunk, enc, cb) => {
+ assert.equal(chunk.name, 'phishing')
+ assert.equal(chunk.data.hostname, phishingUrl)
+ cb()
+ })
+ // console.log(streamTest)
+ metamaskController.setupUntrustedCommunication(streamTest, phishingUrl)
+ })
+ })
+
+ describe('#setupTrustedCommunication', function () {
+ let streamTest
+
+ afterEach(function () {
+ streamTest.end()
+ })
+
+ it('sets up controller dnode api for trusted communication', function (done) {
+ streamTest = createThoughStream((chunk, enc, cb) => {
+ assert.equal(chunk.name, 'controller')
+ cb()
+ done()
+ })
+
+ metamaskController.setupTrustedCommunication(streamTest, 'mycrypto.com')
+ })
+ })
+
describe('#markAccountsFound', function () {
it('adds lost accounts to config manager data', function () {
metamaskController.markAccountsFound(noop)