Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 28c2a7c

Browse files
valentinewallacetanx
authored andcommitted
Handle case where queryRoutes takes > 0.5s + fix integ test
1 parent 860d696 commit 28c2a7c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/action/payment.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PREFIX_URI } from '../config';
1+
import { PREFIX_URI, WAIT_DELAY } from '../config';
22
import {
33
toSatoshis,
44
toAmount,
@@ -64,6 +64,7 @@ class PaymentAction {
6464

6565
async decodeInvoice({ invoice }) {
6666
try {
67+
const timer = setTimeout(() => this._nav.goWait(), WAIT_DELAY);
6768
const { payment, settings } = this._store;
6869
const request = await this._grpc.sendCommand('decodePayReq', {
6970
pay_req: invoice.replace(PREFIX_URI, ''),
@@ -75,9 +76,11 @@ class PaymentAction {
7576
payment.amount = toAmount(parseSat(request.num_satoshis), settings.unit);
7677
payment.note = request.description;
7778
payment.fee = toAmount(parseSat(fee), settings.unit);
79+
clearTimeout(timer);
7880
return true;
7981
} catch (err) {
8082
log.info(`Decoding payment request failed: ${err.message}`);
83+
this._nav.goPay();
8184
return false;
8285
}
8386
}

src/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports.RETRY_DELAY = 3000;
22
module.exports.LND_INIT_DELAY = 5000;
33
module.exports.NOTIFICATION_DELAY = 5000;
4+
module.exports.WAIT_DELAY = 500;
45

56
module.exports.LND_PORT = 10009;
67
module.exports.LND_PEER_PORT = 10019;

test/integration/action/action-integration.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,11 @@ describe('Action Integration Tests', function() {
348348
const isValid = await payments1.decodeInvoice({
349349
invoice: store2.invoice.uri,
350350
});
351-
expect(parseInt(store1.payment.fee), 'to be greater than or equal to', 0);
351+
expect(
352+
parseFloat(store1.payment.fee),
353+
'to be greater than or equal to',
354+
0
355+
);
352356
expect(isValid, 'to be', true);
353357
});
354358

0 commit comments

Comments
 (0)