diff options
author | brunobar79 <brunobar79@gmail.com> | 2018-11-21 06:44:28 +0800 |
---|---|---|
committer | brunobar79 <brunobar79@gmail.com> | 2018-11-21 06:44:28 +0800 |
commit | 9b1df386de908ae14e0ce169f1231a0d6de77972 (patch) | |
tree | d7fc663343b7ba3c28dff0022ca018a01bea451c /test/unit | |
parent | c0557b43e2c493de73c8bf74cfa9e5740c8cfd3f (diff) | |
parent | 5956f8d260270d41f1e5be53f3c058782a1ae7f4 (diff) | |
download | tangerine-wallet-browser-9b1df386de908ae14e0ce169f1231a0d6de77972.tar tangerine-wallet-browser-9b1df386de908ae14e0ce169f1231a0d6de77972.tar.gz tangerine-wallet-browser-9b1df386de908ae14e0ce169f1231a0d6de77972.tar.bz2 tangerine-wallet-browser-9b1df386de908ae14e0ce169f1231a0d6de77972.tar.lz tangerine-wallet-browser-9b1df386de908ae14e0ce169f1231a0d6de77972.tar.xz tangerine-wallet-browser-9b1df386de908ae14e0ce169f1231a0d6de77972.tar.zst tangerine-wallet-browser-9b1df386de908ae14e0ce169f1231a0d6de77972.zip |
fix merge conflicts
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/app/controllers/metamask-controller-test.js | 1 | ||||
-rw-r--r-- | test/unit/app/controllers/preferences-controller-test.js | 6 | ||||
-rw-r--r-- | test/unit/app/controllers/transactions/pending-tx-test.js | 2 | ||||
-rw-r--r-- | test/unit/app/controllers/transactions/tx-controller-test.js | 48 | ||||
-rw-r--r-- | test/unit/development/sample-changelog.md | 2 | ||||
-rw-r--r-- | test/unit/migrations/029-test.js | 38 | ||||
-rw-r--r-- | test/unit/ui/app/reducers/metamask.spec.js | 2 | ||||
-rw-r--r-- | test/unit/ui/app/selectors.spec.js | 2 |
8 files changed, 71 insertions, 30 deletions
diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js index 17be2c028..1ed6a95fb 100644 --- a/test/unit/app/controllers/metamask-controller-test.js +++ b/test/unit/app/controllers/metamask-controller-test.js @@ -58,6 +58,7 @@ describe('MetaMaskController', function () { }, }, initState: clone(firstTimeState), + platform: { showTransactionNotification: () => {} }, }) // disable diagnostics metamaskController.diagnostics = null diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index 473f22f8b..67d1875c1 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -515,14 +515,14 @@ describe('preferences controller', function () { it('should add custom RPC url to state', function () { preferencesController.addToFrequentRpcList('rpc_url', 1) preferencesController.addToFrequentRpcList('http://localhost:8545', 1) - assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }]) preferencesController.addToFrequentRpcList('rpc_url', 1) - assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }]) }) it('should remove custom RPC url from state', function () { preferencesController.addToFrequentRpcList('rpc_url', 1) - assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }]) preferencesController.removeFromFrequentRpcList('other_rpc_url') preferencesController.removeFromFrequentRpcList('http://localhost:8545') preferencesController.removeFromFrequentRpcList('rpc_url') diff --git a/test/unit/app/controllers/transactions/pending-tx-test.js b/test/unit/app/controllers/transactions/pending-tx-test.js index 85b0969f5..2988bf61f 100644 --- a/test/unit/app/controllers/transactions/pending-tx-test.js +++ b/test/unit/app/controllers/transactions/pending-tx-test.js @@ -20,10 +20,12 @@ describe('PendingTransactionTracker', function () { nonce: '0x1', value: '0xfffff', }, + history: [{}], rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d', } txMetaNoHash = { id: 2, + history: [{}], status: 'submitted', txParams: { from: '0x1678a085c290ebd122dc42cba69373b5953b831d'}, } diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index 7f1d8e6f5..b76f256b9 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -52,9 +52,9 @@ describe('Transaction Controller', function () { describe('#getUnapprovedTxCount', function () { it('should return the number of unapproved txs', function () { txController.txStateManager._saveTxList([ - { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, - { id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, - { id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, + { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, ]) const unapprovedTxCount = txController.getUnapprovedTxCount() assert.equal(unapprovedTxCount, 3, 'should be 3') @@ -64,9 +64,9 @@ describe('Transaction Controller', function () { describe('#getPendingTxCount', function () { it('should return the number of pending txs', function () { txController.txStateManager._saveTxList([ - { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, - { id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, - { id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] }, + { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, ]) const pendingTxCount = txController.getPendingTxCount() assert.equal(pendingTxCount, 3, 'should be 3') @@ -82,15 +82,15 @@ describe('Transaction Controller', function () { 'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d', } txController.txStateManager._saveTxList([ - {id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] }, - {id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [] }, + {id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, + {id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, ]) }) @@ -112,7 +112,7 @@ describe('Transaction Controller', function () { id: 1, metamaskNetworkId: currentNetworkId, txParams, - history: [], + history: [{}], } txController.txStateManager._saveTxList([txMeta]) stub = sinon.stub(txController, 'addUnapprovedTransaction').callsFake(() => { @@ -232,7 +232,7 @@ describe('Transaction Controller', function () { from: '0xc684832530fcbddae4b4230a47e991ddcec2831d', to: '0xc684832530fcbddae4b4230a47e991ddcec2831d', }, - history: [], + history: [{}], } providerResultStub.eth_gasPrice = '4a817c800' providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' } @@ -423,7 +423,7 @@ describe('Transaction Controller', function () { data: '0x0', } txController.txStateManager._saveTxList([ - { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] }, + { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, ]) txController.retryTransaction(1) .then((txMeta) => { @@ -462,12 +462,12 @@ describe('Transaction Controller', function () { beforeEach(function () { txController.txStateManager._saveTxList([ { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 2, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 3, status: 'approved', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 4, status: 'signed', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 5, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 6, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {} }, - { id: 7, status: 'failed', metamaskNetworkId: currentNetworkId, txParams: {} }, + { id: 2, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 3, status: 'approved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 4, status: 'signed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 5, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 6, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, + { id: 7, status: 'failed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] }, ]) }) it('should show only submitted and approved transactions as pending transasction', function () { diff --git a/test/unit/development/sample-changelog.md b/test/unit/development/sample-changelog.md index fd980e375..69f6513e6 100644 --- a/test/unit/development/sample-changelog.md +++ b/test/unit/development/sample-changelog.md @@ -1,6 +1,6 @@ # Changelog -## Current Master +## Current Develop Branch ## 4.1.3 2018-2-28 diff --git a/test/unit/migrations/029-test.js b/test/unit/migrations/029-test.js new file mode 100644 index 000000000..a2876487b --- /dev/null +++ b/test/unit/migrations/029-test.js @@ -0,0 +1,38 @@ +const assert = require('assert') +const migration29 = require('../../../app/scripts/migrations/029') +const properTime = (new Date()).getTime() +const storage = { + 'meta': {}, + 'data': { + 'TransactionController': { + 'transactions': [ + { 'status': 'approved', id: 1, submittedTime: 0 }, + { 'status': 'approved', id: 2, submittedTime: properTime }, + { 'status': 'confirmed', id: 3, submittedTime: properTime }, + { 'status': 'submitted', id: 4, submittedTime: properTime }, + { 'status': 'submitted', id: 5, submittedTime: 0 }, + ], + }, + }, +} + +describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => { + it('should auto fail transactions more than 12 hours old', (done) => { + migration29.migrate(storage) + .then((migratedData) => { + const txs = migratedData.data.TransactionController.transactions + const [ txMeta1 ] = txs + assert.equal(migratedData.meta.version, 29) + + assert.equal(txMeta1.status, 'failed', 'old tx is auto failed') + assert(txMeta1.err.message.includes('too long'), 'error message assigned') + + txs.forEach((tx) => { + if (tx.id === 1) return + assert.notEqual(tx.status, 'failed', 'other tx is not auto failed') + }) + + done() + }).catch(done) + }) +}) diff --git a/test/unit/ui/app/reducers/metamask.spec.js b/test/unit/ui/app/reducers/metamask.spec.js index e1a50eef2..502e7ef33 100644 --- a/test/unit/ui/app/reducers/metamask.spec.js +++ b/test/unit/ui/app/reducers/metamask.spec.js @@ -5,7 +5,7 @@ import * as actions from '../../../../../ui/app/actions' describe('MetaMask Reducers', () => { it('init state', () => { - const initState = reduceMetamask({metamask:{}}, {}) + const initState = reduceMetamask({metamask: {}}, {}) assert(initState) }) diff --git a/test/unit/ui/app/selectors.spec.js b/test/unit/ui/app/selectors.spec.js index 78c4267ee..e2b198abf 100644 --- a/test/unit/ui/app/selectors.spec.js +++ b/test/unit/ui/app/selectors.spec.js @@ -148,7 +148,7 @@ describe('Selectors', function () { it('#getSelectedTokenToFiatRate', () => { const selectedTokenToFiatRate = selectors.getSelectedTokenToFiatRate(mockState) - assert.equal(selectedTokenToFiatRate, '0.21880988420033493') + assert.equal(selectedTokenToFiatRate, '0.21880988420033492152') }) describe('#getSelectedTokenContract', () => { |