feature/default_network_editable
Thomas 7 years ago
commit ae4f3366bf
  1. 323
      test/stub/blacklist.json
  2. 1
      test/unit/currency-controller-test.js
  3. 147
      test/unit/metamask-controller-test.js

@ -5,9 +5,68 @@
"metamask.io", "metamask.io",
"myetherwallet.com", "myetherwallet.com",
"cryptokitties.co", "cryptokitties.co",
"mycrypto.com" "mycrypto.com",
"localethereum.com",
"dfinity.org"
], ],
"whitelist": [ "whitelist": [
"ncrypto.com",
"mrcrypto.dk",
"nedfinity.com",
"affinity.me",
"crypto.cat",
"winity.io",
"gfinity.net",
"p-crypto.ru",
"mycryptons.com",
"aicrypto.ai",
"azcrypto.net",
"crypto.com",
"affinity.photography",
"abcrypto.info",
"ucrypto.net",
"vscrypto.com",
"affinity.com",
"affinity.co",
"crypto.news",
"dbcrypto.com",
"ezcrypto.guide",
"gocrypto.me",
"finity.ai",
"weffkemining.com",
"nwcrypto.com",
"cobinhood.com",
"affinity.vc",
"trinity.tech",
"metahusk.com",
"mrcrypto.fr",
"affinity.store",
"affinity.serif.com",
"xfinity.com",
"dfinity.org",
"ggcrypto.net",
"mycrypto.website",
"pqcrypto.org",
"z-crypto.com",
"mpcrypo.com",
"localethereum.com",
"localbitcoins.com",
"huobipro.com",
"ncrypto.tech",
"9crypto.co",
"netmask.hu",
"cryptokittens.club",
"rucrypto.com",
"cryptocities.world",
"mqtcrypto.com",
"crypto.press",
"becrypto.xyz",
"hicrypto.io",
"crypto.nl",
"zycrypto.com",
"mmcrypto.io",
"mycrypter.com",
"crypto.tickets",
"crypto.pro", "crypto.pro",
"ocrypto.org", "ocrypto.org",
"wecrypto.net", "wecrypto.net",
@ -84,7 +143,6 @@
"megamas2.ru", "megamas2.ru",
"metamask.io", "metamask.io",
"myetherwallet.com", "myetherwallet.com",
"myethlerwallet.com",
"ethereum.org", "ethereum.org",
"myetheroll.com", "myetheroll.com",
"myetherapi.com", "myetherapi.com",
@ -128,9 +186,249 @@
"metabase.one", "metabase.one",
"cryptokitties.co", "cryptokitties.co",
"remme.io", "remme.io",
"jibrel.network" "jibrel.network",
"twinity.com"
], ],
"blacklist": [ "blacklist": [
"binance-promo.net",
"trust-cryptopayment.com",
"ethereum-transfer.online",
"icotonsale.com",
"etherbonuses.com",
"ethfreeget.com",
"tongram.me",
"funfaircoin.org",
"coinbase-secure-a2k34j.bitballoon.com",
"ethereumtrans.com",
"xn--condes-8bb1661d.com",
"ethergiveawaytweet.tk",
"eth-giveaway.gq",
"nnyettiervwallat.com",
"nnyettiervwallet.com",
"eth.vote",
"eth-promo.bitballoon.com",
"ethfreepay.com",
"promo-trx.tk",
"paymentaddress.tumblr.com",
"cryptongram.org",
"campaigntoken.blogspot.de",
"coin-promos.com",
"xn--ytherwallet-iw8ex8c.com",
"smartexchangecenter.tk",
"xn--oindesk-15a.com",
"eth-transaction.secure.kissr.com",
"otoeveryday.info",
"ethfreecandy.bitballoon.com",
"etherscanio.github.io",
"ico-gram.net",
"gramtoken.network",
"ethfreegive.com",
"ether-promo.bitballoon.com",
"xn--cindesk-cx4c.com",
"theadsleader.000webhostapp.com",
"myetherwalletico.blogspot.de",
"eth-giveaway.info",
"syncfab.eu",
"eth-giveaway.com",
"icoeth.tk",
"eth-giveaway-706.htmlcomponentservice.com",
"htmlcomponentservice.com",
"mybinance.info",
"xn--myethewallet-kjc.com",
"polyswamr.io",
"polyswarm.me",
"polyswarms.io",
"eth4free.ml",
"ico-telegram-ton.com",
"telegram.tw",
"gramton.info",
"gramsap.enterprises",
"ico-telegram.club",
"telegram.one",
"etharscan.io",
"xn--coindes-jhb.com",
"blocikchair.info",
"eth-cz-319.htmlcomponentservice.com",
"xn--myetherwaet-0t8ea.com",
"eth-giveaway-514.htmlcomponentservice.com",
"xn--mtherwallet-z19ex1a.com",
"xn--eo-e9a.com",
"cosss.io",
"callistonetwork.tech",
"xn--metherwallt-819eo1a.com",
"ethfreepays.com",
"nnyettiervwailet.com",
"xn--hapehift-oh0de.com",
"gram.vc",
"bonus.etherpayout.com",
"etherpayout.com",
"ethereum-giveaway.info",
"xn--bnanc-fsax.com",
"xn--binnce-y0a.com",
"geocities.ws",
"eth-giveaway-209.statichtmlapp.com",
"binance.bitballoon.com",
"binance-give.com",
"ilil.pw",
"myetherwallet.com.send-transaction_8hlg6z8mgt6zyg.ilil.pw",
"telegram.site",
"telegram.auction",
"miroskii.com",
"eth-transactions.neocities.org",
"online-eos.org",
"data-token.org",
"eth953883.htmlcomponentservice.com",
"reeveclancy.wixsite.com",
"transfer-eth.neocities.org",
"eth.secure-transactionssecure.com",
"secure-transactionssecure.com",
"nnyiictehervvailiat.com",
"odachi.neocities.org",
"bittrex-give.com",
"policypal.info",
"changlley.org",
"rnyertherwallet.com",
"xn--thabyss-u8a.com",
"callisto-airdrop.com",
"telegramfoundation.org",
"polymathnetwork.org",
"ethereum-promo.bitballoon.com",
"dfintty.org",
"dftnity.org",
"usermd.net",
"xn--gemn-nzab.com",
"xn--bnance-3va.com",
"xn--binnce-yc8b.com",
"xn--bnance-p9a.com",
"xn--binane-0ua.com",
"binalce.com",
"binince.com",
"xn--conbase-pza.com",
"xn--conbase-sfb.com",
"xn--coinbas-xya.com",
"xn--coinbas-z8a.com",
"xn--coinbse-9wa.com",
"xn--coinbse-lwa.com",
"xn--polonex-vfb.com",
"xn--ploniex-l0a.com",
"xn--plniex-bxab.com",
"xn--havvn-9za.io",
"havvenio.com",
"nucelus.vision",
"metronometoken.io",
"meganfoxloveyou.com",
"xn--yetherwalle-iw8e1s.com",
"tron-online.org",
"myenthereumwallet.com",
"myetherwallet-team.com",
"myetherwallet.usermd.net",
"xn--yetherwalle-tv8ezt.com",
"xn--coindek-873c.com",
"dflinity.org",
"ipsx.promo",
"havven-sale.com",
"tokensale-adhive.com",
"ataritoken.ltd",
"transfer-address-confirmation.droppages.com",
"droppages.com",
"dfinlty.org",
"poloniex.work",
"tokensale-havven.in",
"ico-havven.org",
"secure.poloniex.work",
"vechain-foundation.org",
"telegram.tokyo",
"forkdelta.io",
"ton-sale.com",
"ico-telegram.online",
"telegramtoken.io",
"gonetwork-airdrop.co",
"secure-transaction-confirmation.droppages.com",
"neonexchanges.org",
"eth-transact.secure.droppages.com",
"6khb.payment-checker-ethereum-id-bslyftexjuwcgv8.filesusr.com",
"akasha-world.com",
"address-transfer-confirmation.droppages.com",
"b5z.net",
"p.b5z.net",
"tokensale.xn--havve-7l1b.com",
"xn--coindes-bx3c.com",
"xn--coindek-s73c.com",
"locaeltherum.com",
"myetherwallet.tokenimport.com",
"tokenimport.com",
"leadscoin.network",
"localethereom.com",
"havvens.win",
"xn--metherwalle-jb9ejq.com",
"xn--myetheralle-jb9exm.com",
"tefood.me",
"havventoken.com",
"havven.cc",
"havven.eu",
"havven.top",
"mywalletether.com",
"myetherwallett.site",
"xn--myethewalle-w48erh.com",
"el-petro-coin.com",
"xn--yeterwallet-bm8eym.com",
"sale-orchid.com",
"electrify-asia.info",
"tron-foundation.org",
"dflnlty.org",
"polyswarm.tech",
"tokensale.polyswarm.tech",
"polyswarm.ru",
"dock.click",
"leadcoins.network",
"dock-tokensale.eu",
"polyswarm.pw",
"dock-io.org",
"heavven.io",
"havven.live",
"havven.sale",
"havven.info",
"dock.network",
"blocklancer.me",
"tokensale-havven.io",
"havven.pro",
"tokentelegram.com",
"ico-telegram.me",
"myetherzero.com",
"seele-token.pro",
"tokensale-havven.com",
"polyswarm.in",
"sale-dock.com",
"polyswarm.co",
"polyswarm.bid",
"ton.fund",
"forkdeita.github.io",
"xn--binnce-5nf.com",
"xn--biace-4l1bb.com",
"jiocoins.io",
"xn--polonx-0va26t.com",
"myetlherewallet.org",
"myeithereiuwallet.com",
"fin-trux.com",
"finetrux.com",
"telcoin.pro",
"xn--es-8bb.com",
"xn--myetherallt-pl9elw.com",
"ico-dock.org",
"dock.io-bonus.online",
"docks.site",
"dock-ico.pro",
"dock-ico.eu",
"dock.su",
"tokensale-dock.io",
"dock-ico.site",
"openplatform.tech",
"rightmesh.in",
"waxtoken.in",
"metamaskgiveaway.xyz",
"nebulastoken.in",
"vechain-foundation.com",
"icotoken-current.top",
"xn--myethrwalle-jb9e19a.com", "xn--myethrwalle-jb9e19a.com",
"xn--myetheralle-7b9ezl.com", "xn--myetheralle-7b9ezl.com",
"iconfoundation.co", "iconfoundation.co",
@ -162,6 +460,7 @@
"sale-earn.com", "sale-earn.com",
"bankera.live", "bankera.live",
"originprotocol.io", "originprotocol.io",
"originprotocol.online",
"trx.foundation", "trx.foundation",
"tokensale.adhive.net", "tokensale.adhive.net",
"adhive.net", "adhive.net",
@ -1369,6 +1668,22 @@
"ethzero-wallet.org", "ethzero-wallet.org",
"zeepln.io", "zeepln.io",
"wepowers.network", "wepowers.network",
"wepower.vision" "wepower.vision",
"seele.promo",
"seele-ico.eu",
"seele-ico.pro",
"syncfab.tech",
"tokensale.syncfab.tech",
"havven.promo",
"havven-ico.com",
"havven-ico.eu",
"hawen.io",
"havven.xyz",
"tomo-coin.io",
"tomocoln.io",
"docai.science",
"tomocoin.network",
"celsius-ico.network",
"celsiuss.network"
] ]
} }

@ -45,7 +45,6 @@ describe('currency-controller', function () {
currencyController.updateConversionRate() currencyController.updateConversionRate()
.then(function () { .then(function () {
var result = currencyController.getConversionRate() var result = currencyController.getConversionRate()
console.log('currencyController.getConversionRate:', result)
assert.equal(typeof result, 'number') assert.equal(typeof result, 'number')
done() done()
}).catch(function (err) { }).catch(function (err) {

@ -9,7 +9,7 @@ const firstTimeState = require('../../app/scripts/first-time-state')
describe('MetaMaskController', function () { describe('MetaMaskController', function () {
let metamaskController let metamaskController
const sandbox = sinon.sandbox.create() const sandbox = sinon.sandbox.create()
const noop = () => { } const noop = () => {}
beforeEach(function () { beforeEach(function () {
@ -18,6 +18,14 @@ describe('MetaMaskController', function () {
.get('/v2/blacklist') .get('/v2/blacklist')
.reply(200, blacklistJSON) .reply(200, blacklistJSON)
nock('https://api.infura.io')
.get('/v1/ticker/ethusd')
.reply(200, '{"base": "ETH", "quote": "USD", "bid": 288.45, "ask": 288.46, "volume": 112888.17569277, "exchange": "bitfinex", "total_volume": 272175.00106721005, "num_exchanges": 8, "timestamp": 1506444677}')
nock('https://api.infura.io')
.get('/v1/ticker/ethjpy')
.reply(200, '{"base": "ETH", "quote": "JPY", "bid": 32300.0, "ask": 32400.0, "volume": 247.4616071, "exchange": "kraken", "total_volume": 247.4616071, "num_exchanges": 1, "timestamp": 1506444676}')
nock('https://api.infura.io') nock('https://api.infura.io')
.persist() .persist()
.get(/.*/) .get(/.*/)
@ -46,6 +54,7 @@ describe('MetaMaskController', function () {
}) })
describe('#getGasPrice', function () { describe('#getGasPrice', function () {
it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () { it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () {
const realRecentBlocksController = metamaskController.recentBlocksController const realRecentBlocksController = metamaskController.recentBlocksController
metamaskController.recentBlocksController = { metamaskController.recentBlocksController = {
@ -100,4 +109,140 @@ describe('MetaMaskController', function () {
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice) assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
}) })
}) })
describe('#getApi', function () {
let getApi, state
beforeEach(function () {
getApi = metamaskController.getApi()
})
it('getState', function (done) {
getApi.getState((err, res) => {
if (err) {
done(err)
} else {
state = res
}
})
assert.deepEqual(state, metamaskController.getState())
done()
})
})
describe('preferencesController', function () {
it('defaults useBlockie to false', function () {
assert.equal(metamaskController.preferencesController.store.getState().useBlockie, false)
})
it('setUseBlockie to true', async function () {
metamaskController.setUseBlockie(true, noop)
assert.equal(metamaskController.preferencesController.store.getState().useBlockie, true)
})
})
describe('#selectFirstIdentity', function () {
let identities, address
beforeEach(function () {
address = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'
identities = {
identities: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
'address': '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
'name': 'Account 1',
},
},
}
metamaskController.selectFirstIdentity(identities)
})
it('changes preferences controller select address', function () {
const preferenceControllerState = metamaskController.preferencesController.store.getState()
assert.equal(preferenceControllerState.selectedAddress, address)
})
it('changes metamask controller selected address', function () {
const metamaskState = metamaskController.getState()
assert.equal(metamaskState.selectedAddress, address)
})
})
describe('#setCustomRpc', function () {
const customRPC = 'https://custom.rpc/'
let rpcTarget
beforeEach(function () {
nock('https://custom.rpc')
.post('/')
.reply(200)
rpcTarget = metamaskController.setCustomRpc(customRPC)
})
it('returns custom RPC that when called', async function () {
assert.equal(await rpcTarget, customRPC)
})
it('changes the network controller rpc', function () {
const networkControllerState = metamaskController.networkController.store.getState()
assert.equal(networkControllerState.provider.rpcTarget, customRPC)
})
})
describe('#setCurrentCurrency', function () {
let defaultMetaMaskCurrency
beforeEach(function () {
defaultMetaMaskCurrency = metamaskController.currencyController.getCurrentCurrency()
})
it('defaults to usd', function () {
assert.equal(defaultMetaMaskCurrency, 'usd')
})
it('sets currency to JPY', function () {
metamaskController.setCurrentCurrency('JPY', noop)
assert.equal(metamaskController.currencyController.getCurrentCurrency(), 'JPY')
})
})
describe('#createShapeshifttx', function () {
let depositAddress, depositType, shapeShiftTxList
beforeEach(function () {
nock('https://shapeshift.io')
.get('/txStat/3EevLFfB4H4XMWQwYCgjLie1qCAGpd2WBc')
.reply(200, '{"status": "no_deposits", "address": "3EevLFfB4H4XMWQwYCgjLie1qCAGpd2WBc"}')
depositAddress = '3EevLFfB4H4XMWQwYCgjLie1qCAGpd2WBc'
depositType = 'ETH'
shapeShiftTxList = metamaskController.shapeshiftController.store.getState().shapeShiftTxList
})
it('creates', async function () {
metamaskController.createShapeShiftTx(depositAddress, depositType)
assert.equal(shapeShiftTxList[0].depositAddress, depositAddress)
})
})
describe('#addNewAccount', function () {
let addNewAccount
beforeEach(function () {
addNewAccount = metamaskController.addNewAccount()
})
it('errors when an primary keyring is does not exist', async function () {
try {
await addNewAccount
assert.equal(1 === 0)
} catch (e) {
assert.equal(e.message, 'MetamaskController - No HD Key Tree found')
}
})
})
}) })

Loading…
Cancel
Save