Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(PayInvoiceModal): fix incorrect sats value displayed for paid inv… #1110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ describe('PayInvoiceModal', () => {
});
});

it('should pay invoice successfully', async () => {
const { getByText, getByLabelText, store } = await renderComponent();
it('should pay invoice successfully and show correctly formatted success message', async () => {
const { getByText, getByLabelText, store, findByText } = await renderComponent();
fireEvent.change(getByLabelText('BOLT 11 Invoice'), { target: { value: 'lnbc1' } });
fireEvent.click(getByText('Pay Invoice'));
await waitFor(() => {
Expand All @@ -119,6 +119,8 @@ describe('PayInvoiceModal', () => {
'lnbc1',
undefined,
);
const element = await findByText('Sent 1,000 sats from alice');
expect(element).toBeInTheDocument();
});

it('should display an error when paying the invoice fails', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const PayInvoiceModal: React.FC<Props> = ({ network }) => {
const nodeName = node.name;
notify({
message: l('successTitle'),
description: l('successDesc', { amount: format(amount), nodeName, assetName }),
description: l('successDesc', { amount, nodeName, assetName }),
});
await hidePayInvoice();
} catch (error: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tap/tapd/tapdService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('TapdService', () => {
},
paymentResult: {
paymentPreimage: Buffer.from('preimage'),
valueMsat: 100_000_000,
valueMsat: 1_000_000,
},
};
tapdProxyClient.sendPayment = jest.fn().mockResolvedValue(res);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tap/tapd/tapdService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class TapdService implements TapService {
const pmt = res.paymentResult as LND.Payment;
return {
// convert from msat to asset units using the default oracle exchange rate
amount: parseInt(pmt.valueMsat) / 100_000,
amount: parseInt(pmt.valueMsat) / 1000,
preimage: pmt.paymentPreimage.toString(),
destination: '',
};
Expand Down