Skip to content

Commit

Permalink
test: fix unexpected pay via routes
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed Jun 12, 2024
1 parent 365c439 commit 5da0222
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions core/api/test/integration/services/lnd-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ describe("Lnd", () => {
})

it("parses error message from failures object", async () => {
const channel = "1x1x1"
const payArgs = {
lnd: lnd1,
routes: [
Expand All @@ -508,7 +509,7 @@ describe("Lnd", () => {
fee_mtokens: "1000",
hops: [
{
channel: "1x1x1",
channel,
channel_capacity: 1,
fee: 1,
fee_mtokens: "1000",
Expand All @@ -528,9 +529,10 @@ describe("Lnd", () => {
const err = await getError<LnError<{ failures: LnError }>>(() =>
payViaRoutes(payArgs),
)

expect(err).toHaveLength(3)
expect(err[0]).toEqual(503)
expect(err[1]).toBe("UnexpectedErrorWhenPayingViaRoute")
expect(err[0]).toEqual(500)
expect(err[1]).toBe("UnexpectedPayViaRoutesFailure")

const nestedFailureErr = err[2].failures[0]
expect(nestedFailureErr).toHaveLength(3)
Expand All @@ -543,16 +545,10 @@ describe("Lnd", () => {
expect(nestedFailureErr[1]).toBe(err[1])

// @ts-ignore-next-line no-implicit-any error
const nestedErrObj = nestedFailureErr[2].err
expect(nestedErrObj).toBeInstanceOf(Error)
expect(nestedErrObj).toHaveProperty("code")
expect(nestedErrObj).toHaveProperty("metadata")

const expectedDetails = "invalid public key: unsupported format: 0"
expect(nestedErrObj).toHaveProperty("details", expectedDetails)
expect(nestedFailureErr[2]).toHaveProperty("channel", channel)

const parsedErr = parseLndErrorDetails(err)
expect(parsedErr).toBe(expectedDetails)
expect(parsedErr).toBe("UnexpectedPayViaRoutesFailure")
})
})
})

0 comments on commit 5da0222

Please sign in to comment.