From 0a4901c80f1ecd392f319a4bc3ffd056da655c21 Mon Sep 17 00:00:00 2001 From: michael1011 Date: Tue, 24 Oct 2023 17:54:24 +0200 Subject: [PATCH] fix: payment error handling (#417) --- lib/swap/LightningNursery.ts | 2 -- test/unit/swap/LightningNursery.spec.ts | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/swap/LightningNursery.ts b/lib/swap/LightningNursery.ts index 56b664c4..79a67032 100644 --- a/lib/swap/LightningNursery.ts +++ b/lib/swap/LightningNursery.ts @@ -38,7 +38,6 @@ class LightningNursery extends EventEmitter { return ( error !== undefined && error !== null && - (error as any).code === 6 && (error as any).details === 'invoice is already paid' ); }; @@ -47,7 +46,6 @@ class LightningNursery extends EventEmitter { return ( error !== undefined && error !== null && - (error as any).code === 6 && (error as any).details === 'payment is in transition' ); }; diff --git a/test/unit/swap/LightningNursery.spec.ts b/test/unit/swap/LightningNursery.spec.ts index 9a27049f..d6141445 100644 --- a/test/unit/swap/LightningNursery.spec.ts +++ b/test/unit/swap/LightningNursery.spec.ts @@ -110,7 +110,7 @@ describe('LightningNursery', () => { LightningNursery.errIsInvoicePaid({ details, }), - ).toEqual(false); + ).toEqual(true); expect(LightningNursery.errIsInvoicePaid({})).toEqual(false); expect(LightningNursery.errIsInvoicePaid(null)).toEqual(false); expect(LightningNursery.errIsInvoicePaid(undefined)).toEqual(false); @@ -119,8 +119,8 @@ describe('LightningNursery', () => { test.each` expected | error ${true} | ${{ code: 6, details: 'payment is in transition' }} + ${true} | ${{ code: 5, details: 'payment is in transition' }} ${false} | ${{ code: 6, details: 'payment is not in transition' }} - ${false} | ${{ code: 5, details: 'payment is in transition' }} ${false} | ${{ code: 6 }} ${false} | ${{}} ${false} | ${undefined}