-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: move 'decline held expired USD invoice' integration (#3268)
* test: remove redundant trigger-restart legacy tests * chore: remove unused WalletInvoiceValidator * refactor: add new WalletInvoiceChecker * refactor: swap WalletInvoiceChecker into trigger handler * refactor: isolate 'updateOrDeclinePendingInvoice' method for held-invoices handler * refactor: clean up invoiceUpdateHandler usage * test: move decline-expired-usd test to new integration format * test: move remaining invoice-expiration to new integration format
- Loading branch information
Showing
11 changed files
with
398 additions
and
616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./wallet-invoice-validator" | ||
export * from "./wallet-invoice-checker" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { invoiceExpirationForCurrency } from "@domain/bitcoin/lightning" | ||
import { CouldNotFindWalletInvoiceError } from "@domain/errors" | ||
import { WalletCurrency } from "@domain/shared" | ||
|
||
export const WalletInvoiceChecker = ( | ||
walletInvoice: WalletInvoice | RepositoryError, | ||
): WalletInvoiceChecker => { | ||
const shouldDecline = (): boolean => { | ||
if (walletInvoice instanceof CouldNotFindWalletInvoiceError) { | ||
return true | ||
} | ||
|
||
if (walletInvoice instanceof Error) { | ||
return false | ||
} | ||
|
||
const expiresAtWithDelay = invoiceExpirationForCurrency( | ||
walletInvoice.recipientWalletDescriptor.currency, | ||
walletInvoice.createdAt, | ||
) | ||
const isUsdRecipient = | ||
walletInvoice.recipientWalletDescriptor.currency === WalletCurrency.Usd | ||
if (isUsdRecipient && expiresAtWithDelay.getTime() < Date.now()) { | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
return { shouldDecline } | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.