From bb24f07b1759eb46fa4e4f733c348f1b87521eb6 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 21 Aug 2017 11:59:51 -0700 Subject: [PATCH] When network nonce is highest, it should be used. --- test/unit/nonce-tracker-test.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/test/unit/nonce-tracker-test.js b/test/unit/nonce-tracker-test.js index e8fa73b55..78fdee209 100644 --- a/test/unit/nonce-tracker-test.js +++ b/test/unit/nonce-tracker-test.js @@ -15,7 +15,6 @@ describe('Nonce Tracker', function () { const txGen = new MockTxGen() confirmedTxs = txGen.generate({ status: 'confirmed' }, { count: 3 }) pendingTxs = txGen.generate({ status: 'pending' }, { count: 1 }) - console.dir(txGen.txs) nonceTracker = generateNonceTrackerWith(pendingTxs, confirmedTxs, '0x1') }) @@ -62,7 +61,6 @@ describe('Nonce Tracker', function () { it('should return nonce after those', async function () { this.timeout(15000) const nonceLock = await nonceTracker.getNonceLock('0x7d3517b0d011698406d6e0aed8453f0be2697926') - console.dir(nonceLock.nextNonce) assert.equal(nonceLock.nextNonce, '2', 'nonce should be 2') await nonceLock.releaseLock() }) @@ -78,7 +76,6 @@ describe('Nonce Tracker', function () { it('should return nonce after those', async function () { this.timeout(15000) const nonceLock = await nonceTracker.getNonceLock('0x7d3517b0d011698406d6e0aed8453f0be2697926') - console.dir(nonceLock.nextNonce) assert.equal(nonceLock.nextNonce, '2', 'nonce should be 2') await nonceLock.releaseLock() }) @@ -94,11 +91,25 @@ describe('Nonce Tracker', function () { it('should return nonce after those', async function () { this.timeout(15000) const nonceLock = await nonceTracker.getNonceLock('0x7d3517b0d011698406d6e0aed8453f0be2697926') - console.dir(nonceLock.nextNonce) assert.equal(nonceLock.nextNonce, '2', 'nonce should be 2') await nonceLock.releaseLock() }) }) + + describe('when provider nonce is higher than other metrics', function () { + beforeEach(function () { + const txGen = new MockTxGen() + pendingTxs = txGen.generate({ status: 'pending' }, { count: 2 }) + nonceTracker = generateNonceTrackerWith(pendingTxs, [], '0x05') + }) + + it('should return nonce after those', async function () { + this.timeout(15000) + const nonceLock = await nonceTracker.getNonceLock('0x7d3517b0d011698406d6e0aed8453f0be2697926') + assert.equal(nonceLock.nextNonce, '6', 'nonce should be 6') + await nonceLock.releaseLock() + }) + }) }) })