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
|
* Finds a transaction by its hash
|
||||||
*/
|
*/
|
||||||
Transactions.txHashParam = function(req, res, next, txHash) {
|
Transactions.txHashParam = function(req, res, next, txHash) {
|
||||||
var tx = node.getTransaction(txHash);
|
node.getTransaction(txHash)
|
||||||
|
.then(function(tx) {
|
||||||
if (_.isUndefined(tx)) {
|
if (_.isUndefined(tx)) {
|
||||||
res.status(404).send('Transaction with id ' + txHash + ' not found');
|
res.status(404).send('Transaction with id ' + txHash + ' not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req.tx = tx;
|
req.tx = tx;
|
||||||
next();
|
})
|
||||||
|
.then(next);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ describe('BitcoreHTTP v1 transactions routes', function() {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
nodeMock = new EventEmitter();
|
nodeMock = new EventEmitter();
|
||||||
nodeMock.getTransaction = function(txHash) {
|
nodeMock.getTransaction = function(txHash) {
|
||||||
return mockTransactions[txHash];
|
return Promise.resolve(mockTransactions[txHash]);
|
||||||
};
|
};
|
||||||
nodeMock.broadcast = function(tx) {
|
nodeMock.broadcast = function(tx) {
|
||||||
if (mockTransactions[tx.id]) {
|
if (mockTransactions[tx.id]) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user