promisify getTransaction
This commit is contained in:
parent
cd2e1d8b8a
commit
2a17f8076a
@ -21,14 +21,15 @@ Transactions.setNode = function(aNode) {
|
||||
* Finds a transaction by its hash
|
||||
*/
|
||||
Transactions.txHashParam = function(req, res, next, txHash) {
|
||||
var tx = node.getTransaction(txHash);
|
||||
|
||||
if (_.isUndefined(tx)) {
|
||||
res.status(404).send('Transaction with id ' + txHash + ' not found');
|
||||
return;
|
||||
}
|
||||
req.tx = tx;
|
||||
next();
|
||||
node.getTransaction(txHash)
|
||||
.then(function(tx) {
|
||||
if (_.isUndefined(tx)) {
|
||||
res.status(404).send('Transaction with id ' + txHash + ' not found');
|
||||
return;
|
||||
}
|
||||
req.tx = tx;
|
||||
})
|
||||
.then(next);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ describe('BitcoreHTTP v1 transactions routes', function() {
|
||||
beforeEach(function() {
|
||||
nodeMock = new EventEmitter();
|
||||
nodeMock.getTransaction = function(txHash) {
|
||||
return mockTransactions[txHash];
|
||||
return Promise.resolve(mockTransactions[txHash]);
|
||||
};
|
||||
nodeMock.broadcast = function(tx) {
|
||||
if (mockTransactions[tx.id]) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user