Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): Check quote expiry in outgoing payment worker (#3141) #3173

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,9 @@ export enum LifecycleError {
MissingBalance = 'MissingBalance',
MissingQuote = 'MissingQuote',
MissingExpiration = 'MissingExpiration',
Unauthorized = 'Unauthorized'
Unauthorized = 'Unauthorized',

// To be thrown when a Quote has expired
QuoteExpired = 'QuoteExpired'

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LifecycleError } from './errors'
import { LifecycleError, OutgoingPaymentError } from './errors'
import {
OutgoingPayment,
OutgoingPaymentState,
Expand All @@ -17,6 +17,11 @@ export async function handleSending(
): Promise<void> {
if (!payment.quote) throw LifecycleError.MissingQuote

// Check if the current time is greater than or equal to when the Quote should be expiring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test for this case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Max, I have been looking to add the test here at (service.test.ts) potentially something similar to ('processNext' test) or ('fund').
Is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @CollinsMunene , yes, in the processNext describe block

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mkurapov, here is the implementation of the test. It works, should I proceed to make a pull request?

Screenshot 2025-01-09 at 8 34 35 PM

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request made

if (Date.now() >= payment.quote.expiresAt.getTime()) {
throw LifecycleError.QuoteExpired
}

const receiver = await deps.receiverService.get(payment.receiver)

// TODO: Query TigerBeetle transfers by code to distinguish sending debits from withdrawals
Expand Down