Skip to content

Commit

Permalink
fix: payment error handling (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 authored Oct 24, 2023
1 parent 9e5eade commit 0a4901c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions lib/swap/LightningNursery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
};
Expand All @@ -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'
);
};
Expand Down
4 changes: 2 additions & 2 deletions test/unit/swap/LightningNursery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}
Expand Down

0 comments on commit 0a4901c

Please sign in to comment.