diff options
Diffstat (limited to 'test/unit/app/controllers/transactions/pending-tx-test.js')
-rw-r--r-- | test/unit/app/controllers/transactions/pending-tx-test.js | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/test/unit/app/controllers/transactions/pending-tx-test.js b/test/unit/app/controllers/transactions/pending-tx-test.js index b37ac2766..e1de5731b 100644 --- a/test/unit/app/controllers/transactions/pending-tx-test.js +++ b/test/unit/app/controllers/transactions/pending-tx-test.js @@ -7,7 +7,7 @@ const sinon = require('sinon') describe('PendingTransactionTracker', function () { let pendingTxTracker, txMeta, txMetaNoHash, providerResultStub, - provider, txMeta3, txList, knownErrors + provider, txMeta3, txList, knownErrors this.timeout(10000) beforeEach(function () { @@ -80,7 +80,7 @@ describe('PendingTransactionTracker', function () { }, { count: 1 })[0] stub = sinon.stub(pendingTxTracker, 'getCompletedTransactions') - .returns(txGen.txs) + .returns(txGen.txs) // THE EXPECTATION const spy = sinon.spy() @@ -107,18 +107,18 @@ describe('PendingTransactionTracker', function () { }) it('should emit tx:dropped with the txMetas id only after the second call', function (done) { - txMeta = { - id: 1, - hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb', - status: 'submitted', - txParams: { - from: '0x1678a085c290ebd122dc42cba69373b5953b831d', - nonce: '0x1', - value: '0xfffff', - }, - history: [{}], - rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d', - } + txMeta = { + id: 1, + hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb', + status: 'submitted', + txParams: { + from: '0x1678a085c290ebd122dc42cba69373b5953b831d', + nonce: '0x1', + value: '0xfffff', + }, + history: [{}], + rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d', + } providerResultStub['eth_getTransactionCount'] = '0x02' providerResultStub['eth_getTransactionByHash'] = {} @@ -159,8 +159,8 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._checkPendingTx = (tx) => { tx.resolve(tx) } Promise.all(txList.map((tx) => tx.processed)) - .then(() => done()) - .catch(done) + .then(() => done()) + .catch(done) pendingTxTracker.updatePendingTxs() }) @@ -169,8 +169,8 @@ describe('PendingTransactionTracker', function () { describe('#resubmitPendingTxs', function () { const blockNumberStub = '0x0' beforeEach(function () { - const txMeta2 = txMeta3 = txMeta - txList = [txMeta, txMeta2, txMeta3].map((tx) => { + const txMeta2 = txMeta3 = txMeta + txList = [txMeta, txMeta2, txMeta3].map((tx) => { tx.processed = new Promise((resolve) => { tx.resolve = resolve }) return tx }) @@ -183,8 +183,8 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._resubmitTx = async (tx) => { tx.resolve(tx) } Promise.all(txList.map((tx) => tx.processed)) - .then(() => done()) - .catch(done) + .then(() => done()) + .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) }) it('should not emit \'tx:failed\' if the txMeta throws a known txError', function (done) { @@ -209,8 +209,8 @@ describe('PendingTransactionTracker', function () { throw new Error(knownErrors.pop()) } Promise.all(txList.map((tx) => tx.processed)) - .then(() => done()) - .catch(done) + .then(() => done()) + .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) }) @@ -227,8 +227,8 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._resubmitTx = async () => { throw new TypeError('im some real error') } Promise.all(txList.map((tx) => tx.processed)) - .then(() => done()) - .catch(done) + .then(() => done()) + .catch(done) pendingTxTracker.resubmitPendingTxs(blockNumberStub) }) @@ -264,11 +264,11 @@ describe('PendingTransactionTracker', function () { // Stubbing out current account state: // Adding the fake tx: pendingTxTracker._resubmitTx(txMeta) - .then(() => done()) - .catch((err) => { - assert.ifError(err, 'should not throw an error') - done(err) - }) + .then(() => done()) + .catch((err) => { + assert.ifError(err, 'should not throw an error') + done(err) + }) assert.equal(pendingTxTracker.publishTransaction.callCount, 1, 'Should call publish transaction') }) @@ -278,11 +278,11 @@ describe('PendingTransactionTracker', function () { const mockLatestBlockNumber = '0x5' pendingTxTracker._resubmitTx(txMetaToTestExponentialBackoff, mockLatestBlockNumber) - .then(() => done()) - .catch((err) => { - assert.ifError(err, 'should not throw an error') - done(err) - }) + .then(() => done()) + .catch((err) => { + assert.ifError(err, 'should not throw an error') + done(err) + }) assert.equal(pendingTxTracker.publishTransaction.callCount, 0, 'Should NOT call publish transaction') }) @@ -292,11 +292,11 @@ describe('PendingTransactionTracker', function () { const mockLatestBlockNumber = '0x11' pendingTxTracker._resubmitTx(txMetaToTestExponentialBackoff, mockLatestBlockNumber) - .then(() => done()) - .catch((err) => { - assert.ifError(err, 'should not throw an error') - done(err) - }) + .then(() => done()) + .catch((err) => { + assert.ifError(err, 'should not throw an error') + done(err) + }) assert.equal(pendingTxTracker.publishTransaction.callCount, 1, 'Should call publish transaction') }) @@ -382,11 +382,11 @@ describe('PendingTransactionTracker', function () { value: '0xfffff', }, }) - .then((taken) => { - assert.ok(!taken) - done() - }) - .catch(done) + .then((taken) => { + assert.ok(!taken) + done() + }) + .catch(done) }) it('should return true if nonce has been taken', function (done) { @@ -400,7 +400,7 @@ describe('PendingTransactionTracker', function () { assert.ok(taken) done() }) - .catch(done) + .catch(done) }) }) }) |