Do not return non-validated transaction from RippleAPI#getTransaction

This commit is contained in:
Alan Cohen
2015-09-16 12:11:29 -07:00
parent fe5bc1d215
commit 3c608de5bb
4 changed files with 14 additions and 5 deletions

View File

@@ -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');

View File

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

View File

@@ -40,6 +40,7 @@
],
"TransactionIndex": 5,
"TransactionResult": "tesSUCCESS"
}
},
"validated": false
}
}

View File

@@ -181,6 +181,7 @@
],
"TransactionIndex": 0,
"TransactionResult": "tesSUCCESS"
}
},
"validated": true
}
}