aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-03 08:12:50 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-03 08:12:50 +0800
commit0da41263acabe99fb1bf6b1a3a00c0c27a305eea (patch)
tree722f22697118dfef12d83f55cce13a567040791d /test
parent390f86113a3ca8c1e2725af4705b3863f3da9a3f (diff)
downloadtangerine-wallet-browser-0da41263acabe99fb1bf6b1a3a00c0c27a305eea.tar
tangerine-wallet-browser-0da41263acabe99fb1bf6b1a3a00c0c27a305eea.tar.gz
tangerine-wallet-browser-0da41263acabe99fb1bf6b1a3a00c0c27a305eea.tar.bz2
tangerine-wallet-browser-0da41263acabe99fb1bf6b1a3a00c0c27a305eea.tar.lz
tangerine-wallet-browser-0da41263acabe99fb1bf6b1a3a00c0c27a305eea.tar.xz
tangerine-wallet-browser-0da41263acabe99fb1bf6b1a3a00c0c27a305eea.tar.zst
tangerine-wallet-browser-0da41263acabe99fb1bf6b1a3a00c0c27a305eea.zip
fix warning for unit tests
Diffstat (limited to 'test')
-rw-r--r--test/unit/app/account-import-strategies.spec.js1
-rw-r--r--test/unit/app/controllers/network-contoller-test.js3
-rw-r--r--test/unit/app/controllers/transactions/nonce-tracker-test.js12
-rw-r--r--test/unit/app/controllers/transactions/pending-tx-test.js39
-rw-r--r--test/unit/app/controllers/transactions/tx-controller-test.js6
-rw-r--r--test/unit/app/controllers/transactions/tx-gas-util-test.js1
-rw-r--r--test/unit/app/controllers/transactions/tx-state-manager-test.js5
-rw-r--r--test/unit/app/edge-encryptor-test.js4
-rw-r--r--test/unit/app/nodeify-test.js1
-rw-r--r--test/unit/app/pending-balance-test.js1
-rw-r--r--test/unit/app/seed-phrase-verifier-test.js27
-rw-r--r--test/unit/migrations/023-test.js1
-rw-r--r--test/unit/migrations/024-test.js1
-rw-r--r--test/unit/migrations/template-test.js1
14 files changed, 35 insertions, 68 deletions
diff --git a/test/unit/app/account-import-strategies.spec.js b/test/unit/app/account-import-strategies.spec.js
index e0d514d07..d20ba0f0b 100644
--- a/test/unit/app/account-import-strategies.spec.js
+++ b/test/unit/app/account-import-strategies.spec.js
@@ -1,5 +1,4 @@
const assert = require('assert')
-const path = require('path')
const ethUtil = require('ethereumjs-util')
const accountImporter = require('../../../app/scripts/account-import-strategies/index')
const { assertRejects } = require('../test-utils')
diff --git a/test/unit/app/controllers/network-contoller-test.js b/test/unit/app/controllers/network-contoller-test.js
index 789850ef3..e16fb104e 100644
--- a/test/unit/app/controllers/network-contoller-test.js
+++ b/test/unit/app/controllers/network-contoller-test.js
@@ -5,9 +5,6 @@ const {
getNetworkDisplayName,
} = require('../../../../app/scripts/controllers/network/util')
-const { createTestProviderTools } = require('../../../stub/provider')
-const providerResultStub = {}
-
describe('# Network Controller', function () {
let networkController
const noop = () => {}
diff --git a/test/unit/app/controllers/transactions/nonce-tracker-test.js b/test/unit/app/controllers/transactions/nonce-tracker-test.js
index aaf9b0dc4..6c0ac759f 100644
--- a/test/unit/app/controllers/transactions/nonce-tracker-test.js
+++ b/test/unit/app/controllers/transactions/nonce-tracker-test.js
@@ -4,9 +4,7 @@ const MockTxGen = require('../../../../lib/mock-tx-gen')
const providerResultStub = {}
describe('Nonce Tracker', function () {
- let nonceTracker, provider
- let getPendingTransactions, pendingTxs
- let getConfirmedTransactions, confirmedTxs
+ let nonceTracker, pendingTxs, confirmedTxs
describe('#getNonceLock', function () {
@@ -182,8 +180,8 @@ describe('Nonce Tracker', function () {
describe('When all three return different values', function () {
beforeEach(function () {
const txGen = new MockTxGen()
- const confirmedTxs = txGen.generate({ status: 'confirmed' }, { count: 10 })
- const pendingTxs = txGen.generate({
+ confirmedTxs = txGen.generate({ status: 'confirmed' }, { count: 10 })
+ pendingTxs = txGen.generate({
status: 'submitted',
nonce: 100,
}, { count: 1 })
@@ -202,8 +200,8 @@ describe('Nonce Tracker', function () {
describe('Faq issue 67', function () {
beforeEach(function () {
const txGen = new MockTxGen()
- const confirmedTxs = txGen.generate({ status: 'confirmed' }, { count: 64 })
- const pendingTxs = txGen.generate({
+ confirmedTxs = txGen.generate({ status: 'confirmed' }, { count: 64 })
+ pendingTxs = txGen.generate({
status: 'submitted',
}, { count: 10 })
// 0x40 is 64 in hex:
diff --git a/test/unit/app/controllers/transactions/pending-tx-test.js b/test/unit/app/controllers/transactions/pending-tx-test.js
index b83af568a..8bf2da6f8 100644
--- a/test/unit/app/controllers/transactions/pending-tx-test.js
+++ b/test/unit/app/controllers/transactions/pending-tx-test.js
@@ -1,20 +1,12 @@
const assert = require('assert')
-const ethUtil = require('ethereumjs-util')
-const EthTx = require('ethereumjs-tx')
-const ObservableStore = require('obs-store')
-const clone = require('clone')
const { createTestProviderTools } = require('../../../../stub/provider')
const PendingTransactionTracker = require('../../../../../app/scripts/controllers/transactions/pending-tx-tracker')
const MockTxGen = require('../../../../lib/mock-tx-gen')
const sinon = require('sinon')
-const noop = () => true
-const currentNetworkId = 42
-const otherNetworkId = 36
-const privKey = new Buffer('8718b9618a37d1fc78c436511fc6df3c8258d3250635bba617f33003270ec03e', 'hex')
describe('PendingTransactionTracker', function () {
- let pendingTxTracker, txMeta, txMetaNoHash, txMetaNoRawTx, providerResultStub,
+ let pendingTxTracker, txMeta, txMetaNoHash, providerResultStub,
provider, txMeta3, txList, knownErrors
this.timeout(10000)
beforeEach(function () {
@@ -34,11 +26,7 @@ describe('PendingTransactionTracker', function () {
status: 'signed',
txParams: { from: '0x1678a085c290ebd122dc42cba69373b5953b831d'},
}
- txMetaNoRawTx = {
- hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
- status: 'signed',
- txParams: { from: '0x1678a085c290ebd122dc42cba69373b5953b831d'},
- }
+
providerResultStub = {}
provider = createTestProviderTools({ scaffold: providerResultStub }).provider
@@ -133,22 +121,20 @@ describe('PendingTransactionTracker', function () {
})
describe('#queryPendingTxs', function () {
it('should call #_checkPendingTxs if their is no oldBlock', function (done) {
- let newBlock, oldBlock
- newBlock = { number: '0x01' }
+ let oldBlock
+ const newBlock = { number: '0x01' }
pendingTxTracker._checkPendingTxs = done
pendingTxTracker.queryPendingTxs({ oldBlock, newBlock })
})
it('should call #_checkPendingTxs if oldBlock and the newBlock have a diff of greater then 1', function (done) {
- let newBlock, oldBlock
- oldBlock = { number: '0x01' }
- newBlock = { number: '0x03' }
+ const oldBlock = { number: '0x01' }
+ const newBlock = { number: '0x03' }
pendingTxTracker._checkPendingTxs = done
pendingTxTracker.queryPendingTxs({ oldBlock, newBlock })
})
it('should not call #_checkPendingTxs if oldBlock and the newBlock have a diff of 1 or less', function (done) {
- let newBlock, oldBlock
- oldBlock = { number: '0x1' }
- newBlock = { number: '0x2' }
+ const oldBlock = { number: '0x1' }
+ const newBlock = { number: '0x2' }
pendingTxTracker._checkPendingTxs = () => {
const err = new Error('should not call #_checkPendingTxs if oldBlock and the newBlock have a diff of 1 or less')
done(err)
@@ -197,7 +183,6 @@ describe('PendingTransactionTracker', function () {
it('should warp all txMeta\'s in #_checkPendingTx', function (done) {
pendingTxTracker.getPendingTransactions = () => txList
pendingTxTracker._checkPendingTx = (tx) => { tx.resolve(tx) }
- const list = txList.map
Promise.all(txList.map((tx) => tx.processed))
.then((txCompletedList) => done())
.catch(done)
@@ -275,7 +260,7 @@ describe('PendingTransactionTracker', function () {
})
describe('#_resubmitTx', function () {
const mockFirstRetryBlockNumber = '0x1'
- let txMetaToTestExponentialBackoff
+ let txMetaToTestExponentialBackoff, enoughBalance
beforeEach(() => {
pendingTxTracker.getBalance = (address) => {
@@ -298,7 +283,7 @@ describe('PendingTransactionTracker', function () {
})
it('should publish the transaction', function (done) {
- const enoughBalance = '0x100000'
+ enoughBalance = '0x100000'
// Stubbing out current account state:
// Adding the fake tx:
@@ -313,7 +298,7 @@ describe('PendingTransactionTracker', function () {
})
it('should not publish the transaction if the limit of retries has been exceeded', function (done) {
- const enoughBalance = '0x100000'
+ enoughBalance = '0x100000'
const mockLatestBlockNumber = '0x5'
pendingTxTracker._resubmitTx(txMetaToTestExponentialBackoff, mockLatestBlockNumber)
@@ -327,7 +312,7 @@ describe('PendingTransactionTracker', function () {
})
it('should publish the transaction if the number of blocks since last retry exceeds the last set limit', function (done) {
- const enoughBalance = '0x100000'
+ enoughBalance = '0x100000'
const mockLatestBlockNumber = '0x11'
pendingTxTracker._resubmitTx(txMetaToTestExponentialBackoff, mockLatestBlockNumber)
diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js
index c480c85f3..d4c5ff0ec 100644
--- a/test/unit/app/controllers/transactions/tx-controller-test.js
+++ b/test/unit/app/controllers/transactions/tx-controller-test.js
@@ -1,20 +1,17 @@
const assert = require('assert')
const ethUtil = require('ethereumjs-util')
const EthTx = require('ethereumjs-tx')
-const EthjsQuery = require('ethjs-query')
const ObservableStore = require('obs-store')
const sinon = require('sinon')
const TransactionController = require('../../../../../app/scripts/controllers/transactions')
-const TxGasUtils = require('../../../../../app/scripts/controllers/transactions/tx-gas-utils')
const { createTestProviderTools, getTestAccounts } = require('../../../../stub/provider')
const noop = () => true
const currentNetworkId = 42
-const otherNetworkId = 36
describe('Transaction Controller', function () {
- let txController, provider, providerResultStub, query, fromAccount
+ let txController, provider, providerResultStub, fromAccount
beforeEach(function () {
providerResultStub = {
@@ -24,7 +21,6 @@ describe('Transaction Controller', function () {
eth_getCode: '0x',
}
provider = createTestProviderTools({ scaffold: providerResultStub }).provider
- query = new EthjsQuery(provider)
fromAccount = getTestAccounts()[0]
txController = new TransactionController({
diff --git a/test/unit/app/controllers/transactions/tx-gas-util-test.js b/test/unit/app/controllers/transactions/tx-gas-util-test.js
index d1ee86033..31defd6ed 100644
--- a/test/unit/app/controllers/transactions/tx-gas-util-test.js
+++ b/test/unit/app/controllers/transactions/tx-gas-util-test.js
@@ -1,6 +1,5 @@
const assert = require('assert')
const Transaction = require('ethereumjs-tx')
-const BN = require('bn.js')
const { hexToBn, bnToHex } = require('../../../../../app/scripts/lib/util')
diff --git a/test/unit/app/controllers/transactions/tx-state-manager-test.js b/test/unit/app/controllers/transactions/tx-state-manager-test.js
index 2597e2490..2509c11fb 100644
--- a/test/unit/app/controllers/transactions/tx-state-manager-test.js
+++ b/test/unit/app/controllers/transactions/tx-state-manager-test.js
@@ -1,6 +1,4 @@
const assert = require('assert')
-const clone = require('clone')
-const ObservableStore = require('obs-store')
const TxStateManager = require('../../../../../app/scripts/controllers/transactions/tx-state-manager')
const txStateHistoryHelper = require('../../../../../app/scripts/controllers/transactions/lib/tx-state-history-helper')
const noop = () => true
@@ -59,6 +57,7 @@ describe('TransactionStateManager', function () {
const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
txStateManager.addTx(tx)
const noop = function (err, txId) {
+ assert(err, null)
assert(true, 'event listener has been triggered and noop executed')
done()
}
@@ -166,8 +165,6 @@ describe('TransactionStateManager', function () {
},
}
- const updatedMeta = clone(txMeta)
-
txStateManager.addTx(txMeta)
const updatedTx = txStateManager.getTx('1')
// verify tx was initialized correctly
diff --git a/test/unit/app/edge-encryptor-test.js b/test/unit/app/edge-encryptor-test.js
index f7fb7561d..1a6255b36 100644
--- a/test/unit/app/edge-encryptor-test.js
+++ b/test/unit/app/edge-encryptor-test.js
@@ -35,8 +35,8 @@ describe('EdgeEncryptor', function () {
.then(function (encryptedData) {
const encryptedObject = JSON.parse(encryptedData)
assert.ok(encryptedObject.data, 'there is no data')
- assert.ok(encryptedObject.iv && encryptedObject.iv.length != 0, 'there is no iv')
- assert.ok(encryptedObject.salt && encryptedObject.salt.length != 0, 'there is no salt')
+ assert.ok(encryptedObject.iv && encryptedObject.iv.length !== 0, 'there is no iv')
+ assert.ok(encryptedObject.salt && encryptedObject.salt.length !== 0, 'there is no salt')
done()
}).catch(function (err) {
done(err)
diff --git a/test/unit/app/nodeify-test.js b/test/unit/app/nodeify-test.js
index 901603c8b..e21654a7b 100644
--- a/test/unit/app/nodeify-test.js
+++ b/test/unit/app/nodeify-test.js
@@ -13,6 +13,7 @@ describe('nodeify', function () {
it('should retain original context', function (done) {
var nodified = nodeify(obj.promiseFunc, obj)
nodified('baz', function (err, res) {
+ assert(err, null)
assert.equal(res, 'barbaz')
done()
})
diff --git a/test/unit/app/pending-balance-test.js b/test/unit/app/pending-balance-test.js
index 903c7840c..508635c46 100644
--- a/test/unit/app/pending-balance-test.js
+++ b/test/unit/app/pending-balance-test.js
@@ -2,7 +2,6 @@ const assert = require('assert')
const PendingBalanceCalculator = require('../../../app/scripts/lib/pending-balance-calculator')
const MockTxGen = require('../../lib/mock-tx-gen')
const BN = require('ethereumjs-util').BN
-const providerResultStub = {}
const zeroBn = new BN(0)
const etherBn = new BN(String(1e18))
diff --git a/test/unit/app/seed-phrase-verifier-test.js b/test/unit/app/seed-phrase-verifier-test.js
index 88c4e8d67..d8720d5a0 100644
--- a/test/unit/app/seed-phrase-verifier-test.js
+++ b/test/unit/app/seed-phrase-verifier-test.js
@@ -13,7 +13,6 @@ describe('SeedPhraseVerifier', function () {
const hdKeyTree = 'HD Key Tree'
let keyringController
- let vault
let primaryKeyring
beforeEach(async function () {
@@ -24,7 +23,7 @@ describe('SeedPhraseVerifier', function () {
assert(keyringController)
- vault = await keyringController.createNewVaultAndKeychain(password)
+ await keyringController.createNewVaultAndKeychain(password)
primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0]
})
@@ -37,7 +36,7 @@ describe('SeedPhraseVerifier', function () {
const seedWords = serialized.mnemonic
assert.notEqual(seedWords.length, 0)
- const result = await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
+ await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
})
it('should be able to verify created account (upper case) with seed words', async function () {
@@ -51,7 +50,7 @@ describe('SeedPhraseVerifier', function () {
const seedWords = serialized.mnemonic
assert.notEqual(seedWords.length, 0)
- const result = await seedPhraseVerifier.verifyAccounts(upperCaseAccounts, seedWords)
+ await seedPhraseVerifier.verifyAccounts(upperCaseAccounts, seedWords)
})
it('should be able to verify created account (lower case) with seed words', async function () {
@@ -64,7 +63,7 @@ describe('SeedPhraseVerifier', function () {
const seedWords = serialized.mnemonic
assert.notEqual(seedWords.length, 0)
- const result = await seedPhraseVerifier.verifyAccounts(lowerCaseAccounts, seedWords)
+ await seedPhraseVerifier.verifyAccounts(lowerCaseAccounts, seedWords)
})
it('should return error with good but different seed words', async function () {
@@ -72,11 +71,11 @@ describe('SeedPhraseVerifier', function () {
const createdAccounts = await primaryKeyring.getAccounts()
assert.equal(createdAccounts.length, 1)
- const serialized = await primaryKeyring.serialize()
+ await primaryKeyring.serialize()
const seedWords = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
try {
- const result = await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
+ await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
assert.fail('Should reject')
} catch (err) {
assert.ok(err.message.indexOf('Not identical accounts!') >= 0, 'Wrong error message')
@@ -88,11 +87,11 @@ describe('SeedPhraseVerifier', function () {
const createdAccounts = await primaryKeyring.getAccounts()
assert.equal(createdAccounts.length, 1)
- const serialized = await primaryKeyring.serialize()
+ await primaryKeyring.serialize()
const seedWords = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
try {
- const result = await seedPhraseVerifier.verifyAccounts(undefined, seedWords)
+ await seedPhraseVerifier.verifyAccounts(undefined, seedWords)
assert.fail('Should reject')
} catch (err) {
assert.equal(err.message, 'No created accounts defined.')
@@ -104,11 +103,11 @@ describe('SeedPhraseVerifier', function () {
const createdAccounts = await primaryKeyring.getAccounts()
assert.equal(createdAccounts.length, 1)
- const serialized = await primaryKeyring.serialize()
+ await primaryKeyring.serialize()
const seedWords = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
try {
- const result = await seedPhraseVerifier.verifyAccounts([], seedWords)
+ await seedPhraseVerifier.verifyAccounts([], seedWords)
assert.fail('Should reject')
} catch (err) {
assert.equal(err.message, 'No created accounts defined.')
@@ -117,8 +116,8 @@ describe('SeedPhraseVerifier', function () {
it('should be able to verify more than one created account with seed words', async function () {
- const keyState = await keyringController.addNewAccount(primaryKeyring)
- const keyState2 = await keyringController.addNewAccount(primaryKeyring)
+ await keyringController.addNewAccount(primaryKeyring)
+ await keyringController.addNewAccount(primaryKeyring)
const createdAccounts = await primaryKeyring.getAccounts()
assert.equal(createdAccounts.length, 3)
@@ -127,7 +126,7 @@ describe('SeedPhraseVerifier', function () {
const seedWords = serialized.mnemonic
assert.notEqual(seedWords.length, 0)
- const result = await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
+ await seedPhraseVerifier.verifyAccounts(createdAccounts, seedWords)
})
})
})
diff --git a/test/unit/migrations/023-test.js b/test/unit/migrations/023-test.js
index 2b01c64d2..7da94448d 100644
--- a/test/unit/migrations/023-test.js
+++ b/test/unit/migrations/023-test.js
@@ -1,6 +1,5 @@
const assert = require('assert')
const migration23 = require('../../../app/scripts/migrations/023')
-const properTime = (new Date()).getTime()
const storage = {
'meta': {},
'data': {
diff --git a/test/unit/migrations/024-test.js b/test/unit/migrations/024-test.js
index 0492cafdb..c7b0611bc 100644
--- a/test/unit/migrations/024-test.js
+++ b/test/unit/migrations/024-test.js
@@ -4,7 +4,6 @@ const firstTimeState = {
meta: {},
data: require('../../../app/scripts/first-time-state'),
}
-const properTime = (new Date()).getTime()
const storage = {
'meta': {},
'data': {
diff --git a/test/unit/migrations/template-test.js b/test/unit/migrations/template-test.js
index 35060e2fe..0db69d65a 100644
--- a/test/unit/migrations/template-test.js
+++ b/test/unit/migrations/template-test.js
@@ -1,6 +1,5 @@
const assert = require('assert')
const migrationTemplate = require('../../../app/scripts/migrations/template')
-const properTime = (new Date()).getTime()
const storage = {
meta: {},
data: {},