feature/default_network_editable
Thomas Huang 8 years ago
parent 8f5334e4ac
commit 0b13429daf
  1. 2
      test/helper.js
  2. 6
      test/integration/index.js
  3. 4
      test/lib/mock-config-manager.js
  4. 2
      test/unit/account-link-test.js
  5. 11
      test/unit/actions/config_test.js
  6. 15
      test/unit/actions/save_account_label_test.js
  7. 13
      test/unit/actions/set_selected_account_test.js
  8. 34
      test/unit/actions/tx_test.js
  9. 9
      test/unit/actions/view_info_test.js
  10. 7
      test/unit/actions/warning_test.js
  11. 11
      test/unit/address-book-controller.js
  12. 2
      test/unit/components/binary-renderer-test.js
  13. 15
      test/unit/config-manager-test.js
  14. 13
      test/unit/currency-controller-test.js
  15. 1
      test/unit/explorer-link-test.js
  16. 27
      test/unit/keyring-controller-test.js
  17. 4
      test/unit/linting_test.js
  18. 6
      test/unit/message-manager-test.js
  19. 8
      test/unit/metamask-controller-test.js
  20. 4
      test/unit/migrations-test.js
  21. 3
      test/unit/nameForAccount_test.js
  22. 4
      test/unit/nodeify-test.js
  23. 43
      test/unit/notice-controller-test.js
  24. 7
      test/unit/personal-message-manager-test.js
  25. 11
      test/unit/reducers/unlock_vault_test.js
  26. 30
      test/unit/tx-manager-test.js
  27. 2
      test/unit/tx-utils-test.js
  28. 13
      test/unit/util_test.js

@ -20,8 +20,6 @@ window.localStorage = {}
if (!window.crypto) window.crypto = {}
if (!window.crypto.getRandomValues) window.crypto.getRandomValues = require('polyfill-crypto.getrandomvalues')
function enableFailureOnUnhandledPromiseRejection () {
// overwrite node's promise with the stricter Bluebird promise
global.Promise = require('bluebird')

@ -1,10 +1,10 @@
var fs = require('fs')
var path = require('path')
var browserify = require('browserify');
var browserify = require('browserify')
var tests = fs.readdirSync(path.join(__dirname, 'lib'))
var bundlePath = path.join(__dirname, 'bundle.js')
var b = browserify();
var b = browserify()
// Remove old bundle
try {
@ -17,5 +17,5 @@ tests.forEach(function(fileName) {
b.add(path.join(__dirname, 'lib', fileName))
})
b.bundle().pipe(writeStream);
b.bundle().pipe(writeStream)

@ -2,9 +2,9 @@ const ObservableStore = require('obs-store')
const clone = require('clone')
const ConfigManager = require('../../app/scripts/lib/config-manager')
const firstTimeState = require('../../app/scripts/first-time-state')
const STORAGE_KEY = 'metamask-config'
// const STORAGE_KEY = 'metamask-config'
module.exports = function () {
let store = new ObservableStore(clone(firstTimeState))
const store = new ObservableStore(clone(firstTimeState))
return new ConfigManager({ store })
}

@ -2,7 +2,6 @@ var assert = require('assert')
var linkGen = require('../../ui/lib/account-link')
describe('account-link', function () {
it('adds ropsten prefix to ropsten test network', function () {
var result = linkGen('account', '3')
assert.notEqual(result.indexOf('ropsten'), -1, 'ropsten included')
@ -14,5 +13,4 @@ describe('account-link', function() {
assert.notEqual(result.indexOf('kovan'), -1, 'kovan included')
assert.notEqual(result.indexOf('account'), -1, 'account included')
})
})

@ -1,4 +1,4 @@
var jsdom = require('mocha-jsdom')
// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
@ -7,17 +7,16 @@ var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actio
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
describe('config view actions', function () {
var initialState = {
metamask: {
rpcTarget: 'foo',
frequentRpcList: []
frequentRpcList: [],
},
appState: {
currentView: {
name: 'accounts',
}
}
},
},
}
freeze(initialState)
@ -29,7 +28,6 @@ describe ('config view actions', function() {
})
describe('SET_RPC_TARGET', function () {
it('sets the state.metamask.rpcTarget property of the state to the action.value', function () {
const action = {
type: actions.SET_RPC_TARGET,
@ -41,5 +39,4 @@ describe ('config view actions', function() {
assert.equal(result.metamask.provider.rpcTarget, 'foo')
})
})
})

@ -1,4 +1,4 @@
var jsdom = require('mocha-jsdom')
// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
@ -7,16 +7,15 @@ var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actio
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
describe('SAVE_ACCOUNT_LABEL', function () {
it('updates the state.metamask.identities[:i].name property of the state to the action.value.label', function () {
var initialState = {
metamask: {
identities: {
foo: {
name: 'bar'
}
name: 'bar',
},
},
},
}
}
freeze(initialState)
@ -24,13 +23,13 @@ describe('SAVE_ACCOUNT_LABEL', function() {
type: actions.SAVE_ACCOUNT_LABEL,
value: {
account: 'foo',
label: 'baz'
label: 'baz',
},
}
freeze(action)
var resultingState = reducers(initialState, action)
assert.equal(resultingState.metamask.identities.foo.name, action.value.label)
});
});
})
})

@ -1,4 +1,4 @@
var jsdom = require('mocha-jsdom')
// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
@ -7,12 +7,11 @@ var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actio
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
describe('SET_SELECTED_ACCOUNT', function () {
it('sets the state.appState.activeAddress property of the state to the action.value', function () {
var initialState = {
appState: {
activeAddress: 'foo',
}
},
}
freeze(initialState)
@ -24,15 +23,15 @@ describe('SET_SELECTED_ACCOUNT', function() {
var resultingState = reducers(initialState, action)
assert.equal(resultingState.appState.activeAddress, action.value)
});
});
})
})
describe('SHOW_ACCOUNT_DETAIL', function () {
it('updates metamask state', function () {
var initialState = {
metamask: {
selectedAddress: 'foo'
}
selectedAddress: 'foo',
},
}
freeze(initialState)

@ -1,4 +1,4 @@
var jsdom = require('mocha-jsdom')
// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
@ -8,14 +8,13 @@ var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actio
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
describe('tx confirmation screen', function () {
beforeEach(function () {
this.sinon = sinon.sandbox.create();
});
this.sinon = sinon.sandbox.create()
})
afterEach(function () {
this.sinon.restore();
});
this.sinon.restore()
})
var initialState, result
@ -23,7 +22,6 @@ describe('tx confirmation screen', function() {
var firstTxId = 1457634084250832
beforeEach(function () {
initialState = {
appState: {
currentView: {
@ -34,17 +32,16 @@ describe('tx confirmation screen', function() {
unapprovedTxs: {
'1457634084250832': {
id: 1457634084250832,
status: "unconfirmed",
status: 'unconfirmed',
time: 1457634084250,
}
},
}
},
},
}
freeze(initialState)
})
describe('cancelTx', function () {
before(function (done) {
actions._setBackgroundConnection({
approveTransaction (txId, cb) { cb('An error!') },
@ -52,7 +49,7 @@ describe('tx confirmation screen', function() {
clearSeedWordCache (cb) { cb() },
})
let action = actions.cancelTx({value: firstTxId})
const action = actions.cancelTx({value: firstTxId})
result = reducers(initialState, action)
done()
})
@ -71,10 +68,7 @@ describe('tx confirmation screen', function() {
var result
describe('when there is an error', function () {
before(function (done) {
alert = () => {/* noop */}
actions._setBackgroundConnection({
approveTransaction (txId, cb) { cb({message: 'An error!'}) },
})
@ -122,16 +116,16 @@ describe('tx confirmation screen', function() {
unapprovedTxs: {
'1457634084250832': {
id: firstTxId,
status: "unconfirmed",
status: 'unconfirmed',
time: 1457634084250,
},
'1457634084250833': {
id: 1457634084250833,
status: "unconfirmed",
status: 'unconfirmed',
time: 1457634084255,
},
},
}
},
}
freeze(initialState)
@ -140,7 +134,7 @@ describe('tx confirmation screen', function() {
approveTransaction (firstTxId, cb) { cb() },
})
let action = actions.sendTx({id: firstTxId})(function(action) {
actions.sendTx({id: firstTxId})(function (action) {
result = reducers(initialState, action)
})
done()
@ -155,7 +149,7 @@ describe('tx confirmation screen', function() {
})
})
})
});
})
function getUnconfirmedTxCount (state) {
var txs = state.metamask.unapprovedTxs

@ -1,4 +1,4 @@
var jsdom = require('mocha-jsdom')
// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
@ -7,17 +7,16 @@ var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actio
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
describe('SHOW_INFO_PAGE', function () {
it('sets the state.appState.currentView.name property to info', function () {
var initialState = {
appState: {
activeAddress: 'foo',
}
},
}
freeze(initialState)
const action = actions.showInfoPage()
var resultingState = reducers(initialState, action)
assert.equal(resultingState.appState.currentView.name, 'info')
});
});
})
})

@ -1,4 +1,4 @@
var jsdom = require('mocha-jsdom')
// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
@ -7,7 +7,6 @@ var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actio
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
describe('action DISPLAY_WARNING', function () {
it('sets appState.warning to provided value', function () {
var initialState = {
appState: {},
@ -20,5 +19,5 @@ describe('action DISPLAY_WARNING', function() {
const resultingState = reducers(initialState, action)
assert.equal(resultingState.appState.warning, warningText, 'warning text set')
});
});
})
})

@ -1,5 +1,5 @@
const assert = require('assert')
const extend = require('xtend')
// const extend = require('xtend')
const AddressBookController = require('../../app/scripts/controllers/address-book')
const mockKeyringController = {
@ -10,13 +10,12 @@ const mockKeyringController = {
'0x0aaa': {
address: '0x0aaa',
name: 'owned',
},
},
}
},
},
}
}
}
}
}
describe('address-book-controller', function () {
var addressBookController

@ -2,7 +2,6 @@ var assert = require('assert')
var BinaryRenderer = require('../../../ui/app/components/binary-renderer')
describe('BinaryRenderer', function () {
let binaryRenderer
const message = 'Hello, world!'
const buffer = new Buffer(message, 'utf8')
@ -17,7 +16,6 @@ describe('BinaryRenderer', function() {
assert.equal(result, message)
})
it('recovers message with hex prefix', function () {
const result = binaryRenderer.hexToText('0x' + hex)
assert.equal(result, message)

@ -2,9 +2,9 @@
global.fetch = global.fetch || require('isomorphic-fetch')
const assert = require('assert')
const extend = require('xtend')
const rp = require('request-promise')
const nock = require('nock')
// const extend = require('xtend')
// const rp = require('request-promise')
// const nock = require('nock')
const configManagerGen = require('../lib/mock-config-manager')
describe('config-manager', function () {
@ -15,13 +15,12 @@ describe('config-manager', function() {
})
describe('#setConfig', function () {
it('should set the config key', function () {
var testConfig = {
provider: {
type: 'rpc',
rpcTarget: 'foobar'
}
rpcTarget: 'foobar',
},
}
configManager.setConfig(testConfig)
var result = configManager.getData()
@ -34,13 +33,13 @@ describe('config-manager', function() {
var testConfig = {
provider: {
type: 'rpc',
rpcTarget: 'foobar'
rpcTarget: 'foobar',
},
}
configManager.setConfig(testConfig)
var testWallet = {
name: 'this is my fake wallet'
name: 'this is my fake wallet',
}
configManager.setWallet(testWallet)

@ -2,8 +2,8 @@
global.fetch = global.fetch || require('isomorphic-fetch')
const assert = require('assert')
const extend = require('xtend')
const rp = require('request-promise')
// const extend = require('xtend')
// const rp = require('request-promise')
const nock = require('nock')
const CurrencyController = require('../../app/scripts/controllers/currency')
@ -15,7 +15,6 @@ describe('currency-controller', function() {
})
describe('currency conversions', function () {
describe('#setCurrentCurrency', function () {
it('should return USD as default', function () {
assert.equal(currencyController.getCurrentCurrency(), 'USD')
@ -39,7 +38,7 @@ describe('currency-controller', function() {
describe('#updateConversionRate', function () {
it('should retrieve an update for ETH to USD and set it in memory', function (done) {
this.timeout(15000)
var usdMock = nock('https://www.cryptonator.com')
nock('https://www.cryptonator.com')
.get('/api/ticker/eth-USD')
.reply(200, '{"ticker":{"base":"ETH","target":"USD","price":"11.02456145","volume":"44948.91745289","change":"-0.01472534"},"timestamp":1472072136,"success":true,"error":""}')
@ -54,14 +53,13 @@ describe('currency-controller', function() {
}).catch(function (err) {
done(err)
})
})
it('should work for JPY as well.', function () {
this.timeout(15000)
assert.equal(currencyController.getConversionRate(), 0)
var jpyMock = nock('https://www.cryptonator.com')
nock('https://www.cryptonator.com')
.get('/api/ticker/eth-JPY')
.reply(200, '{"ticker":{"base":"ETH","target":"JPY","price":"11.02456145","volume":"44948.91745289","change":"-0.01472534"},"timestamp":1472072136,"success":true,"error":""}')
@ -77,11 +75,10 @@ describe('currency-controller', function() {
promise.then(function () {
var result = currencyController.getConversionRate()
assert.equal(typeof result, 'number')
}).catch(function(err) {
}).catch(function (done, err) {
done(err)
})
})
})
})
})

@ -2,7 +2,6 @@ var assert = require('assert')
var linkGen = require('../../ui/lib/explorer-link')
describe('explorer-link', function () {
it('adds ropsten prefix to ropsten test network', function () {
var result = linkGen('hash', '3')
assert.notEqual(result.indexOf('ropsten'), -1, 'ropsten injected')

@ -3,19 +3,18 @@ const KeyringController = require('../../app/scripts/keyring-controller')
const configManagerGen = require('../lib/mock-config-manager')
const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN
const async = require('async')
// const async = require('async')
const mockEncryptor = require('../lib/mock-encryptor')
const MockSimpleKeychain = require('../lib/mock-simple-keychain')
// const MockSimpleKeychain = require('../lib/mock-simple-keychain')
const sinon = require('sinon')
describe('KeyringController', function () {
let keyringController, state
let password = 'password123'
let seedWords = 'puzzle seed penalty soldier say clay field arctic metal hen cage runway'
let addresses = ['eF35cA8EbB9669A35c31b5F6f249A9941a812AC1'.toLowerCase()]
let accounts = []
let originalKeystore
let keyringController
const password = 'password123'
const seedWords = 'puzzle seed penalty soldier say clay field arctic metal hen cage runway'
const addresses = ['eF35cA8EbB9669A35c31b5F6f249A9941a812AC1'.toLowerCase()]
const accounts = []
// let originalKeystore
beforeEach(function (done) {
this.sinon = sinon.sandbox.create()
@ -25,7 +24,7 @@ describe('KeyringController', function() {
configManager: configManagerGen(),
txManager: {
getTxList: () => [],
getUnapprovedTxList: () => []
getUnapprovedTxList: () => [],
},
ethStore: {
addAccount (acct) { accounts.push(ethUtil.addHexPrefix(acct)) },
@ -38,7 +37,7 @@ describe('KeyringController', function() {
keyringController.createNewVaultAndKeychain(password)
.then(function (newState) {
state = newState
newState
done()
})
.catch((err) => {
@ -70,14 +69,13 @@ describe('KeyringController', function() {
})
describe('#restoreKeyring', function () {
it(`should pass a keyring's serialized data back to the correct type.`, function (done) {
const mockSerialized = {
type: 'HD Key Tree',
data: {
mnemonic: seedWords,
numberOfAccounts: 1,
}
},
}
const mock = this.sinon.mock(keyringController)
@ -151,14 +149,13 @@ describe('KeyringController', function() {
describe('#addGasBuffer', function () {
it('adds 100k gas buffer to estimates', function () {
const gas = '0x04ee59' // Actual estimated gas example
const tooBigOutput = '0x80674f9' // Actual bad output
const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
const correctBuffer = new BN('100000', 10)
const correct = bnGas.add(correctBuffer)
const tooBig = new BN(tooBigOutput, 16)
// const tooBig = new BN(tooBigOutput, 16)
const result = keyringController.addGasBuffer(gas)
const bnResult = new BN(ethUtil.stripHexPrefix(result), 16)

@ -1,6 +1,6 @@
// LINTING:
const lint = require('mocha-eslint');
const lintPaths = ['app/**/*.js', 'ui/**/*.js', '!node_modules/**', '!dist/**', '!docs/**', '!app/scripts/chromereload.js']
const lint = require('mocha-eslint')
const lintPaths = ['app/**/*.js', 'ui/**/*.js', 'test/**/*.js', '!node_modules/**', '!dist/**', '!docs/**', '!app/scripts/chromereload.js']
const lintOptions = {
strict: false,

@ -1,6 +1,6 @@
const assert = require('assert')
const extend = require('xtend')
const EventEmitter = require('events')
// const extend = require('xtend')
// const EventEmitter = require('events')
const MessageManger = require('../../app/scripts/lib/message-manager')
@ -71,7 +71,7 @@ describe('Transaction Manager', function() {
it('returns unapproved Msgs in a hash', function () {
messageManager.addMsg({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' })
messageManager.addMsg({ id: '2', status: 'approved', metamaskNetworkId: 'unit test' })
let result = messageManager.getUnapprovedMsgs()
const result = messageManager.getUnapprovedMsgs()
assert.equal(typeof result, 'object')
assert.equal(result['1'].status, 'unapproved')
assert.equal(result['2'], undefined)

@ -4,11 +4,11 @@ const clone = require('clone')
const MetaMaskController = require('../../app/scripts/metamask-controller')
const firstTimeState = require('../../app/scripts/first-time-state')
const STORAGE_KEY = 'metamask-config'
// const STORAGE_KEY = 'metamask-config'
describe('MetaMaskController', function () {
const noop = () => {}
let controller = new MetaMaskController({
const metamaskController = new MetaMaskController({
showUnconfirmedMessage: noop,
unlockAccountMessage: noop,
showUnapprovedTx: noop,
@ -26,4 +26,8 @@ describe('MetaMaskController', function() {
this.sinon.restore()
})
describe('Metamask Controller', function () {
assert(metamaskController)
})
})

@ -3,7 +3,7 @@ const path = require('path')
const wallet1 = require(path.join('..', 'lib', 'migrations', '001.json'))
const vault4 = require(path.join('..', 'lib', 'migrations', '004.json'))
let vault5, vault6, vault7, vault8, vault9, vault10, vault11
let vault5, vault6, vault7, vault8, vault9 // vault10, vault11
const migration2 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '002'))
const migration3 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '003'))
@ -23,7 +23,6 @@ const newTestRpc = 'https://testrpc.metamask.io/'
describe('wallet1 is migrated successfully', () => {
it('should convert providers', () => {
wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null }
return migration2.migrate(wallet1)
@ -99,6 +98,5 @@ describe('wallet1 is migrated successfully', () => {
assert.equal(twelfthResult.data.NoticeController.noticesList[0].body, '', 'notices that have been read should have an empty body.')
assert.equal(twelfthResult.data.NoticeController.noticesList[1].body, 'nonempty', 'notices that have not been read should not have an empty body.')
})
})
})

@ -5,7 +5,6 @@ var path = require('path')
var contractNamer = require(path.join(__dirname, '..', '..', 'ui', 'lib', 'contract-namer.js'))
describe('contractNamer', function () {
beforeEach(function () {
this.sinon = sinon.sandbox.create()
})
@ -15,7 +14,6 @@ describe('contractNamer', function() {
})
describe('naming a contract', function () {
it('should return nothing for an unknown random account', function () {
const input = '0x2386F26FC10000'
const output = contractNamer(input)
@ -39,6 +37,5 @@ describe('contractNamer', function() {
const output = contractNamer(input.toUpperCase(), identities)
assert.deepEqual(output, expected)
})
})
})

@ -2,13 +2,12 @@ const assert = require('assert')
const nodeify = require('../../app/scripts/lib/nodeify')
describe('nodeify', function () {
var obj = {
foo: 'bar',
promiseFunc: function (a) {
var solution = this.foo + a
return Promise.resolve(solution)
}
},
}
it('should retain original context', function (done) {
@ -18,5 +17,4 @@ describe('nodeify', function() {
done()
})
})
})

@ -1,17 +1,17 @@
const assert = require('assert')
const extend = require('xtend')
const rp = require('request-promise')
const nock = require('nock')
// const extend = require('xtend')
// const rp = require('request-promise')
// const nock = require('nock')
const configManagerGen = require('../lib/mock-config-manager')
const NoticeController = require('../../app/scripts/notice-controller')
const STORAGE_KEY = 'metamask-persistence-key'
// const STORAGE_KEY = 'metamask-persistence-key'
describe('notice-controller', function () {
var noticeController
beforeEach(function () {
// simple localStorage polyfill
let configManager = configManagerGen()
const configManager = configManagerGen()
noticeController = new NoticeController({
configManager: configManager,
})
@ -20,11 +20,11 @@ describe('notice-controller', function() {
describe('notices', function () {
describe('#getNoticesList', function () {
it('should return an empty array when new', function (done) {
var testList = [{
id:0,
read:false,
title:"Futuristic Notice"
}]
// const testList = [{
// id: 0,
// read: false,
// title: 'Futuristic Notice',
// }]
var result = noticeController.getNoticesList()
assert.equal(result.length, 0)
done()
@ -36,7 +36,7 @@ describe('notice-controller', function() {
var testList = [{
id: 0,
read: false,
title:"Futuristic Notice"
title: 'Futuristic Notice',
}]
noticeController.setNoticesList(testList)
var testListId = noticeController.getNoticesList()[0].id
@ -50,7 +50,7 @@ describe('notice-controller', function() {
var testList = [{
id: 55,
read: false,
title:"Futuristic Notice"
title: 'Futuristic Notice',
}]
noticeController.setNoticesList(testList)
noticeController.updateNoticesList().then(() => {
@ -64,12 +64,12 @@ describe('notice-controller', function() {
var testList = [{
id: 0,
read: false,
title:"Futuristic Notice"
title: 'Futuristic Notice',
}]
noticeController.setNoticesList(testList)
var newList = noticeController.getNoticesList()
assert.equal(newList[0].id, 0)
assert.equal(newList[0].title, "Futuristic Notice")
assert.equal(newList[0].title, 'Futuristic Notice')
assert.equal(newList.length, 1)
done()
})
@ -80,7 +80,7 @@ describe('notice-controller', function() {
var testList = [{
id: 0,
read: false,
title:"Futuristic Notice"
title: 'Futuristic Notice',
}]
noticeController.setNoticesList(testList)
noticeController.markNoticeRead(testList[0])
@ -93,9 +93,9 @@ describe('notice-controller', function() {
describe('#getLatestUnreadNotice', function () {
it('should retrieve the latest unread notice', function (done) {
var testList = [
{id:0,read:true,title:"Past Notice"},
{id:1,read:false,title:"Current Notice"},
{id:2,read:false,title:"Future Notice"},
{id: 0, read: true, title: 'Past Notice'},
{id: 1, read: false, title: 'Current Notice'},
{id: 2, read: false, title: 'Future Notice'},
]
noticeController.setNoticesList(testList)
var latestUnread = noticeController.getLatestUnreadNotice()
@ -104,9 +104,9 @@ describe('notice-controller', function() {
})
it('should return undefined if no unread notices exist.', function (done) {
var testList = [
{id:0,read:true,title:"Past Notice"},
{id:1,read:true,title:"Current Notice"},
{id:2,read:true,title:"Future Notice"},
{id: 0, read: true, title: 'Past Notice'},
{id: 1, read: true, title: 'Current Notice'},
{id: 2, read: true, title: 'Future Notice'},
]
noticeController.setNoticesList(testList)
var latestUnread = noticeController.getLatestUnreadNotice()
@ -115,5 +115,4 @@ describe('notice-controller', function() {
})
})
})
})

@ -1,6 +1,6 @@
const assert = require('assert')
const extend = require('xtend')
const EventEmitter = require('events')
// const extend = require('xtend')
// const EventEmitter = require('events')
const PersonalMessageManager = require('../../app/scripts/lib/personal-message-manager')
@ -71,7 +71,7 @@ describe('Personal Message Manager', function() {
it('returns unapproved Msgs in a hash', function () {
messageManager.addMsg({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' })
messageManager.addMsg({ id: '2', status: 'approved', metamaskNetworkId: 'unit test' })
let result = messageManager.getUnapprovedMsgs()
const result = messageManager.getUnapprovedMsgs()
assert.equal(typeof result, 'object')
assert.equal(result['1'].status, 'unapproved')
assert.equal(result['2'], undefined)
@ -106,5 +106,4 @@ describe('Personal Message Manager', function() {
assert.equal(output, '0x12', 'adds prefix')
})
})
})

@ -1,6 +1,6 @@
var jsdom = require('mocha-jsdom')
// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
// var freeze = require('deep-freeze-strict')
var path = require('path')
var sinon = require('sinon')
@ -8,7 +8,6 @@ var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actio
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
describe('#unlockMetamask(selectedAccount)', function () {
beforeEach(function () {
// sinon allows stubbing methods that are easily verified
this.sinon = sinon.sandbox.create()
@ -26,7 +25,7 @@ describe('#unlockMetamask(selectedAccount)', function() {
const initialState = {
appState: {
warning: warning,
}
},
}
const resultState = reducers(initialState, actions.unlockMetamask(account))
@ -37,11 +36,11 @@ describe('#unlockMetamask(selectedAccount)', function() {
describe('going home after an error', function () {
it('clears warning', function () {
const warning = 'this is the wrong warning'
const account = 'foo_account'
// const account = 'foo_account'
const initialState = {
appState: {
warning: warning,
}
},
}
const resultState = reducers(initialState, actions.goHome())

@ -1,10 +1,10 @@
const assert = require('assert')
const extend = require('xtend')
// const extend = require('xtend')
const EventEmitter = require('events')
const ethUtil = require('ethereumjs-util')
const EthTx = require('ethereumjs-tx')
const ObservableStore = require('obs-store')
const STORAGE_KEY = 'metamask-persistance-key'
// const STORAGE_KEY = 'metamask-persistance-key'
const TransactionManager = require('../../app/scripts/transaction-manager')
const noop = () => true
const currentNetworkId = 42
@ -22,25 +22,25 @@ describe('Transaction Manager', function() {
signTransaction: (ethTx) => new Promise((resolve) => {
ethTx.sign(privKey)
resolve()
})
}),
})
})
describe('#validateTxParams', function () {
it('returns null for positive values', function () {
var sample = {
value: '0x01'
value: '0x01',
}
var res = txManager.txProviderUtils.validateTxParams(sample, (err) => {
txManager.txProviderUtils.validateTxParams(sample, (err) => {
assert.equal(err, null, 'no error')
})
})
it('returns error for negative values', function () {
var sample = {
value: '-0x01'
value: '-0x01',
}
var res = txManager.txProviderUtils.validateTxParams(sample, (err) => {
txManager.txProviderUtils.validateTxParams(sample, (err) => {
assert.ok(err, 'error')
})
})
@ -81,7 +81,7 @@ describe('Transaction Manager', function() {
it('cuts off early txs beyond a limit', function () {
const limit = txManager.txHistoryLimit
for (let i = 0; i < limit + 1; i++) {
let tx = { id: i, time: new Date(), status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {} }
const tx = { id: i, time: new Date(), status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {} }
txManager.addTx(tx, noop)
}
var result = txManager.getTxList()
@ -92,7 +92,7 @@ describe('Transaction Manager', function() {
it('cuts off early txs beyond a limit whether or not it is confirmed or rejected', function () {
const limit = txManager.txHistoryLimit
for (let i = 0; i < limit + 1; i++) {
let tx = { id: i, time: new Date(), status: 'rejected', metamaskNetworkId: currentNetworkId, txParams: {} }
const tx = { id: i, time: new Date(), status: 'rejected', metamaskNetworkId: currentNetworkId, txParams: {} }
txManager.addTx(tx, noop)
}
var result = txManager.getTxList()
@ -105,7 +105,7 @@ describe('Transaction Manager', function() {
txManager.addTx(unconfirmedTx, noop)
const limit = txManager.txHistoryLimit
for (let i = 1; i < limit + 1; i++) {
let tx = { id: i, time: new Date(), status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {} }
const tx = { id: i, time: new Date(), status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {} }
txManager.addTx(tx, noop)
}
var result = txManager.getTxList()
@ -130,7 +130,7 @@ describe('Transaction Manager', function() {
it('should emit a signed event to signal the exciton of callback', (done) => {
this.timeout(10000)
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
let noop = function () {
const noop = function () {
assert(true, 'event listener has been triggered and noop executed')
done()
}
@ -155,14 +155,13 @@ describe('Transaction Manager', function() {
this.timeout(10000)
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
txManager.addTx(tx)
let noop = function (err, txId) {
const noop = function (err, txId) {
assert(true, 'event listener has been triggered and noop executed')
done()
}
txManager.on('1:rejected', noop)
txManager.setTxStatusRejected(1)
})
})
describe('#updateTx', function () {
@ -179,7 +178,7 @@ describe('Transaction Manager', function() {
it('returns unapproved txs in a hash', function () {
txManager.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, noop)
txManager.addTx({ id: '2', status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {} }, noop)
let result = txManager.getUnapprovedTxList()
const result = txManager.getUnapprovedTxList()
assert.equal(typeof result, 'object')
assert.equal(result['1'].status, 'unapproved')
assert.equal(result['2'], undefined)
@ -197,7 +196,7 @@ describe('Transaction Manager', function() {
describe('#getFilteredTxList', function () {
it('returns a tx with the requested data', function () {
let txMetas = [
const txMetas = [
{ id: 0, status: 'unapproved', txParams: { from: '0xaa', to: '0xbb' }, metamaskNetworkId: currentNetworkId },
{ id: 1, status: 'unapproved', txParams: { from: '0xaa', to: '0xbb' }, metamaskNetworkId: currentNetworkId },
{ id: 2, status: 'unapproved', txParams: { from: '0xaa', to: '0xbb' }, metamaskNetworkId: currentNetworkId },
@ -237,5 +236,4 @@ describe('Transaction Manager', function() {
})
})
})
})

@ -48,7 +48,7 @@ describe('txUtils', function() {
// dummy gas limit: 0x0f4240 (1 mil)
const blockGasLimitHex = '0x0f4240'
const output = txUtils.addGasBuffer(inputHex, blockGasLimitHex)
const inputBn = hexToBn(inputHex)
// const inputBn = hexToBn(inputHex)
const outputBn = hexToBn(output)
const expectedBn = hexToBn(inputHex)
assert(outputBn.eq(expectedBn), 'returns the original estimatedGas value')

@ -104,7 +104,6 @@ describe('util', function() {
})
describe('#numericBalance', function () {
it('should return a BN 0 if given nothing', function () {
var result = util.numericBalance()
assert.equal(result.toString(10), 0)
@ -119,11 +118,9 @@ describe('util', function() {
var result = util.numericBalance('012')
assert.equal(result.toString(10), '18')
})
})
describe('#formatBalance', function () {
it('when given nothing', function () {
var result = util.formatBalance()
assert.equal(result, 'None', 'should return "None"')
@ -142,17 +139,17 @@ describe('util', function() {
})
it('should display specified decimal points', function () {
var input = "0x128dfa6a90b28000"
var input = '0x128dfa6a90b28000'
var result = util.formatBalance(input, 2)
assert.equal(result, '1.33 ETH')
})
it('should default to 3 decimal points', function () {
var input = "0x128dfa6a90b28000"
var input = '0x128dfa6a90b28000'
var result = util.formatBalance(input)
assert.equal(result, '1.337 ETH')
})
it('should show 2 significant digits for tiny balances', function () {
var input = "0x1230fa6a90b28"
var input = '0x1230fa6a90b28'
var result = util.formatBalance(input)
assert.equal(result, '0.00032 ETH')
})
@ -165,7 +162,6 @@ describe('util', function() {
})
describe('normalizing values', function () {
describe('#normalizeToWei', function () {
it('should convert an eth to the appropriate equivalent values', function () {
var valueTable = {
@ -186,7 +182,6 @@ describe('util', function() {
var oneEthBn = new ethUtil.BN(ethInWei, 10)
for (var currency in valueTable) {
var value = new ethUtil.BN(valueTable[currency], 10)
var output = util.normalizeToWei(value, currency)
assert.equal(output.toString(10), valueTable.wei, `value of ${output.toString(10)} ${currency} should convert to ${oneEthBn}`)
@ -209,7 +204,6 @@ describe('util', function() {
})
describe('#normalizeNumberToWei', function () {
it('should handle a simple use case', function () {
var input = 0.0002
var output = util.normalizeNumberToWei(input, 'ether')
@ -247,7 +241,6 @@ describe('util', function() {
var result = util.isHex('0xc3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2')
assert(result)
})
})
})
})

Loading…
Cancel
Save