ParseInt nextworkNextNonce correction (#8827)

* networkNextNonce toNumber

* nonceBN for all getTransactionCount

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
feature/default_network_editable
Thomas Huang 4 years ago committed by GitHub
parent c8be5d0779
commit 753a3eb4c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/scripts/controllers/transactions/pending-tx-tracker.js
  2. 13
      test/unit/app/controllers/transactions/pending-tx-tracker-test.js

@ -211,7 +211,7 @@ export default class PendingTransactionTracker extends EventEmitter {
const { hash: txHash, txParams: { nonce, from } } = txMeta
const networkNextNonce = await this.query.getTransactionCount(from)
if (parseInt(nonce, 16) >= parseInt(networkNextNonce, 16)) {
if (parseInt(nonce, 16) >= networkNextNonce.toNumber()) {
return false
}

@ -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({

Loading…
Cancel
Save