diff --git a/src/api/ledger/transaction.js b/src/api/ledger/transaction.js index 56d291ff..17f4416a 100644 --- a/src/api/ledger/transaction.js +++ b/src/api/ledger/transaction.js @@ -57,6 +57,11 @@ function getTransactionAsync(identifier: string, options: TransactionOptions, function callbackWrapper(error_?: Error, tx?: Object) { let error = error_; + + if (!error && tx && tx.validated !== true) { + return callback(new errors.NotFoundError('Transaction not found')); + } + if (error instanceof RippleError && error.remote && error.remote.error === 'txnNotFound') { error = new errors.NotFoundError('Transaction not found'); diff --git a/test/api-test.js b/test/api-test.js index e0226965..5c207fb0 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -217,9 +217,11 @@ describe('RippleAPI', function() { it('getTransaction - not validated', function() { const hash = '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA10'; - return this.api.getTransaction(hash).then( - _.partial(checkResult, responses.getTransaction.notValidated, - 'getTransaction')); + return this.api.getTransaction(hash).then(() => { + assert(false, 'Should throw NotFoundError'); + }).catch(error => { + assert(error instanceof this.api.errors.NotFoundError); + }); }); it('getTransaction - tracking on', function() { diff --git a/test/fixtures/api/rippled/tx/not-validated.json b/test/fixtures/api/rippled/tx/not-validated.json index aba33004..986a0d62 100644 --- a/test/fixtures/api/rippled/tx/not-validated.json +++ b/test/fixtures/api/rippled/tx/not-validated.json @@ -40,6 +40,7 @@ ], "TransactionIndex": 5, "TransactionResult": "tesSUCCESS" - } + }, + "validated": false } } diff --git a/test/fixtures/api/rippled/tx/payment.json b/test/fixtures/api/rippled/tx/payment.json index efa39cb6..d4509529 100644 --- a/test/fixtures/api/rippled/tx/payment.json +++ b/test/fixtures/api/rippled/tx/payment.json @@ -181,6 +181,7 @@ ], "TransactionIndex": 0, "TransactionResult": "tesSUCCESS" - } + }, + "validated": true } }