diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js index c65b3691..cd804322 100644 --- a/lib/wallet/txdb.js +++ b/lib/wallet/txdb.js @@ -61,9 +61,7 @@ class TXDB { this.db = wdb.db; this.logger = wdb.logger; this.nowFn = wdb.options.nowFn || util.now; - this.maxTXs = wdb.options.maxHistoryTXs || 100; - this.nowFn = util.now; this.wid = wid || 0; this.bucket = null; diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index 1257c991..7ffd0f1d 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -203,9 +203,13 @@ class WalletDB extends EventEmitter { this.client.hook('block rescan interactive', async (entry, txs) => { try { - return await this.rescanBlockInteractive(entry, txs); + this.timeCache.start(); + const result = await this.rescanBlockInteractive(entry, txs); + this.timeCache.commit(); + return result; } catch (e) { this.emit('error', e); + this.timeCache.drop(); return { type: scanActions.ABORT }; diff --git a/test/node-http-test.js b/test/node-http-test.js index ef30b591..cb4f0029 100644 --- a/test/node-http-test.js +++ b/test/node-http-test.js @@ -439,6 +439,8 @@ describe('Node HTTP', function() { wallet: true }); + nodeCtx.init(); + const {nclient} = nodeCtx; before(async () => { @@ -532,6 +534,8 @@ describe('Node HTTP', function() { wallet: true }); + nodeCtx.init(); + const {nclient, network} = nodeCtx; const genesisBlock = Block.decode(network.genesisBlock); let minedHashes; @@ -705,7 +709,7 @@ async function mineBlocks(nodeCtx, count, address) { count ); - const hashes = await nodeCtx.mineBlocks(count, address); + const blocks = await nodeCtx.mineBlocks(count, address); await blockEvents; - return hashes; + return blocks.map(block => block.hash().toString('hex')); } diff --git a/test/util/node-context.js b/test/util/node-context.js index aa2efd3e..32277506 100644 --- a/test/util/node-context.js +++ b/test/util/node-context.js @@ -372,10 +372,15 @@ class NodeContext { if (!tip) tip = this.chain.tip; + const blocks = []; + for (let i = 0; i < count; i++) { const block = await this.miner.mineBlock(tip, address); tip = await this.chain.add(block); + blocks.push(block); } + + return blocks; } } diff --git a/test/util/pagination.js b/test/util/pagination.js index c778850a..32777cc1 100644 --- a/test/util/pagination.js +++ b/test/util/pagination.js @@ -25,7 +25,8 @@ exports.generateInitialBlocks = async (options) => { await nodeCtx.nclient.execute('setmocktime', [blocktime]); const blocks = await nodeCtx.mineBlocks(1, coinbase); - const block = await nodeCtx.nclient.execute('getblock', [blocks[0]]); + const firstHash = blocks[0].hash().toString('hex'); + const block = await nodeCtx.nclient.execute('getblock', [firstHash]); assert(block.time <= blocktime + 1); assert(block.time >= blocktime); diff --git a/test/wallet-http-test.js b/test/wallet-http-test.js index 011bed38..5d3f8374 100644 --- a/test/wallet-http-test.js +++ b/test/wallet-http-test.js @@ -1189,8 +1189,6 @@ describe('Wallet HTTP', function() { if (key.startsWith(wid1 + '42')) dumpSlice[key] = dump[key]; }); - - console.log(dumpSlice); }); it('should get auction info', async () => { diff --git a/test/wallet-pagination-test.js b/test/wallet-pagination-test.js index dc87a8cf..c2898717 100644 --- a/test/wallet-pagination-test.js +++ b/test/wallet-pagination-test.js @@ -65,7 +65,8 @@ describe('WalletDB Pagination', function() { const mtx = await dummyTX(wallet); const wids = await wdb.addTX(mtx.toTX()); - assert.strictEqual(wids.size, 1); + assert(wids); + assert.strictEqual(wids.wids.size, 1); const txCount = await wallet.txdb.getCountForTX(mtx.hash()); assert.strictEqual(txCount.index, initUCount.index); diff --git a/test/wallet-rpc-test.js b/test/wallet-rpc-test.js index 81b8e94a..31b20a12 100644 --- a/test/wallet-rpc-test.js +++ b/test/wallet-rpc-test.js @@ -53,6 +53,8 @@ describe('Wallet RPC Methods', function() { wallet: true }); + nodeCtx.init(); + wclient = nodeCtx.wclient; nclient = nodeCtx.nclient; wdb = nodeCtx.wdb; diff --git a/test/wallet-test.js b/test/wallet-test.js index 9e4f5fdf..c1ffff56 100644 --- a/test/wallet-test.js +++ b/test/wallet-test.js @@ -2061,14 +2061,15 @@ describe('Wallet', function() { }); it('should pass nowFn to the txdb', async () => { - const nowFn = () => 1; + const NOW = 1; + const nowFn = () => NOW; const wallet = new Wallet({ options: { nowFn } }); - assert.strictEqual(wallet.txdb.nowFn(), nowFn()); + assert.strictEqual(wallet.txdb.nowFn(), NOW); }); it('should cleanup', async () => {