Skip to content

Commit

Permalink
test: fix expected expiration with default values
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed Oct 28, 2024
1 parent 3f396b1 commit 850bfc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/api/src/domain/bitcoin/lightning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { decodeInvoice } from "./ln-invoice"
export {
invoiceExpirationForCurrency,
defaultTimeToExpiryInSeconds,
INVOICE_EXPIRATIONS,
} from "./invoice-expiration"
export * from "./errors"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { SECS_PER_10_MINS, SECS_PER_DAY } from "@/config"

import {
invoiceExpirationForCurrency,
INVOICE_EXPIRATIONS,
} from "@/domain/bitcoin/lightning"
import { toSeconds } from "@/domain/primitives"
import { WalletCurrency } from "@/domain/shared"
import { invoiceExpirationForCurrency } from "@/domain/bitcoin/lightning"

describe("invoiceExpirationForCurrency", () => {
const BTC = WalletCurrency.Btc
const USD = WalletCurrency.Usd
const now = new Date("2000-01-01T00:00:00Z")

it("should return expiration for BTC currency with default delay", () => {
const expectedExpiration = new Date("2000-01-02T00:00:00.000Z")
const expectedExpiration = new Date(
now.getTime() + INVOICE_EXPIRATIONS.BTC.defaultValue * 1000,
)
let expiresAt = invoiceExpirationForCurrency(BTC, now)
expect(expiresAt).toEqual(expectedExpiration)

Expand All @@ -28,7 +33,9 @@ describe("invoiceExpirationForCurrency", () => {
})

it("should return expiration for USD currency with default delay", () => {
const expectedExpiration = new Date("2000-01-01T00:05:00.000Z")
const expectedExpiration = new Date(
now.getTime() + INVOICE_EXPIRATIONS.USD.defaultValue * 1000,
)
let expiresAt = invoiceExpirationForCurrency(USD, now)
expect(expiresAt).toEqual(expectedExpiration)

Expand Down

0 comments on commit 850bfc4

Please sign in to comment.