Skip to content

Commit

Permalink
treat timeout as failure
Browse files Browse the repository at this point in the history
fixes #88
  • Loading branch information
C-Otto committed Feb 15, 2024
1 parent 1049eed commit 099270c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void start(
if (paymentStatus.isFailure() && decodedPaymentRequest.destination().equals(ownPubkey)) {
grpcInvoices.cancelPaymentRequest(decodedPaymentRequest);
}
if (paymentStatus.isPending() || paymentStatus.isFailure()) {
if (paymentStatus.isFailure()) {
grpcSendToRoute.forceFailureForPayment(decodedPaymentRequest);
}
}
Expand Down Expand Up @@ -103,7 +103,7 @@ private void start() {
loopIterationCounter++;
Coins residualAmount = totalAmountToSend.subtract(inFlight);
if (Coins.NONE.equals(residualAmount)) {
paymentStatus.info(TIMEOUT_MESSAGE);
paymentStatus.failed(TIMEOUT_MESSAGE);
return;
}
if (shouldAbort(loopIterationCounter)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,8 @@ void aborts_for_stuck_pending_amount() {
.thenReturn(Coins.NONE)
.thenReturn(DECODED_PAYMENT_REQUEST.amount());
paymentLoop.start(DECODED_PAYMENT_REQUEST, PAYMENT_OPTIONS, paymentStatus);
SoftAssertions softly = new SoftAssertions();
softly.assertThat(paymentStatus.isSuccess()).isFalse();
softly.assertThat(paymentStatus.isFailure()).isFalse();
softly.assertAll();
// it's not strictly a failure, but we need to complete the flux/stream (see #88)
assertThat(paymentStatus.isFailure()).isTrue();
verify(grpcSendToRoute).forceFailureForPayment(DECODED_PAYMENT_REQUEST);
}

Expand Down

0 comments on commit 099270c

Please sign in to comment.