From 387a15f1efd58b3f716699fa6401dc2d662a5ebf Mon Sep 17 00:00:00 2001 From: Matt Gurzenski Date: Tue, 19 May 2020 16:45:54 -0400 Subject: [PATCH] FIX: Reduced batchsize to prevent "undefined" error and allow viewing of transactions for these 2 wallet addresses: 34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo, 18rnfoQgGo1HqvVQaAN4QnxjYE7Sez9eca --- BlueElectrum.js | 2 +- tests/integration/legacy-wallet.test.js | 34 +++++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/BlueElectrum.js b/BlueElectrum.js index 21f4f64c5..890d7e67d 100644 --- a/BlueElectrum.js +++ b/BlueElectrum.js @@ -339,7 +339,7 @@ module.exports.multiGetHistoryByAddress = async function(addresses, batchsize) { }; module.exports.multiGetTransactionByTxid = async function(txids, batchsize, verbose) { - batchsize = batchsize || 61; + batchsize = batchsize || 40; // this value is fine-tuned so althrough wallets in test suite will occasionally // throw 'response too large (over 1,000,000 bytes', test suite will pass verbose = verbose !== false; diff --git a/tests/integration/legacy-wallet.test.js b/tests/integration/legacy-wallet.test.js index e4436a267..e6b188625 100644 --- a/tests/integration/legacy-wallet.test.js +++ b/tests/integration/legacy-wallet.test.js @@ -67,21 +67,27 @@ describe('LegacyWallet', function() { assert.ok(tx.confirmations > 1); } }); - - it('can fetch TXs when addresses for vout are missing', async () => { - // Transaction with missing address output https://www.blockchain.com/btc/tx/d45818ae11a584357f7b74da26012d2becf4ef064db015a45bdfcd9cb438929d - let w = new LegacyWallet(); - w._address = '1PVfrmbn1vSMoFZB2Ga7nDuXLFDyJZHrHK'; - await w.fetchTransactions(); - assert.ok(w.getTransactions().length > 0); - for (let tx of w.getTransactions()) { - assert.ok(tx.hash); - assert.ok(tx.value); - assert.ok(tx.received); - assert.ok(tx.confirmations > 1); - } - }); + it.each([ + ['addresses for vout missing', '1PVfrmbn1vSMoFZB2Ga7nDuXLFDyJZHrHK'], + ['txdatas were coming back null from BlueElectrum because of high batchsize', '34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo'], + ])( + 'can fetch TXs when %s', + async (useCase, address) => { + let w = new LegacyWallet(); + w._address = address; + await w.fetchTransactions(); + + assert.ok(w.getTransactions().length > 0); + for (let tx of w.getTransactions()) { + assert.ok(tx.hash); + assert.ok(tx.value); + assert.ok(tx.received); + assert.ok(tx.confirmations > 1); + } + }, + 240000, + ); it('can fetch UTXO', async () => { let w = new LegacyWallet();