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 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?

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