|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
import sinon from 'sinon' |
|
|
|
|
import { strict as assert } from 'assert' |
|
|
|
|
import BN from 'bn.js' |
|
|
|
|
import PendingTransactionTracker from '../../../../../app/scripts/controllers/transactions/pending-tx-tracker' |
|
|
|
|
|
|
|
|
|
describe('PendingTransactionTracker', function () { |
|
|
|
@ -311,10 +312,11 @@ describe('PendingTransactionTracker', function () { |
|
|
|
|
|
|
|
|
|
describe('#_checkIfTxWasDropped', function () { |
|
|
|
|
it('should return true when the given nonce is lower than the network nonce', async function () { |
|
|
|
|
const nonceBN = new BN(2) |
|
|
|
|
const pendingTxTracker = new PendingTransactionTracker({ |
|
|
|
|
query: { |
|
|
|
|
getTransactionReceipt: sinon.stub(), |
|
|
|
|
getTransactionCount: sinon.stub().resolves('0x02'), |
|
|
|
|
getTransactionCount: sinon.stub().resolves(nonceBN), |
|
|
|
|
}, |
|
|
|
|
nonceTracker: { |
|
|
|
|
getGlobalLock: sinon.stub().resolves({ |
|
|
|
@ -343,10 +345,11 @@ describe('PendingTransactionTracker', function () { |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it('should return false when the given nonce is the network nonce', async function () { |
|
|
|
|
const nonceBN = new BN(1) |
|
|
|
|
const pendingTxTracker = new PendingTransactionTracker({ |
|
|
|
|
query: { |
|
|
|
|
getTransactionReceipt: sinon.stub(), |
|
|
|
|
getTransactionCount: sinon.stub().resolves('0x01'), |
|
|
|
|
getTransactionCount: sinon.stub().resolves(nonceBN), |
|
|
|
|
}, |
|
|
|
|
nonceTracker: { |
|
|
|
|
getGlobalLock: sinon.stub().resolves({ |
|
|
|
@ -487,10 +490,11 @@ describe('PendingTransactionTracker', function () { |
|
|
|
|
history: [{}], |
|
|
|
|
rawTx: '0xf86c808504a817c80082471d', |
|
|
|
|
} |
|
|
|
|
const nonceBN = new BN(2) |
|
|
|
|
const pendingTxTracker = new PendingTransactionTracker({ |
|
|
|
|
query: { |
|
|
|
|
getTransactionReceipt: sinon.stub().rejects(), |
|
|
|
|
getTransactionCount: sinon.stub().resolves('0x02'), |
|
|
|
|
getTransactionCount: sinon.stub().resolves(nonceBN), |
|
|
|
|
}, |
|
|
|
|
nonceTracker: { |
|
|
|
|
getGlobalLock: sinon.stub().resolves({ |
|
|
|
@ -647,6 +651,7 @@ describe('PendingTransactionTracker', function () { |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it("should emit 'tx:dropped' with the txMetas id only after the fourth call", async function () { |
|
|
|
|
const nonceBN = new BN(2) |
|
|
|
|
const txMeta = { |
|
|
|
|
id: 1, |
|
|
|
|
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb', |
|
|
|
@ -662,7 +667,7 @@ describe('PendingTransactionTracker', function () { |
|
|
|
|
const pendingTxTracker = new PendingTransactionTracker({ |
|
|
|
|
query: { |
|
|
|
|
getTransactionReceipt: sinon.stub().resolves(null), |
|
|
|
|
getTransactionCount: sinon.stub().resolves('0x02'), |
|
|
|
|
getTransactionCount: sinon.stub().resolves(nonceBN), |
|
|
|
|
}, |
|
|
|
|
nonceTracker: { |
|
|
|
|
getGlobalLock: sinon.stub().resolves({ |
|
|
|
|