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

feat: bolt12 support for submarine swaps #666

Merged
merged 2 commits into from
Oct 6, 2024
Merged
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
32 changes: 32 additions & 0 deletions e2e/bolt12.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { expect, test } from "@playwright/test";

import { generateBitcoinBlock, getBolt12Offer } from "./utils";

test.describe("BOLT12", () => {
test.beforeEach(async () => {
await generateBitcoinBlock();
});

test("Resolve bolt12 offer", async ({ page }) => {
await page.goto("/");

const divFlipAssets = page.locator("#flip-assets");
await divFlipAssets.click();

const receiveAmount = "0.01";
const inputReceiveAmount = page.locator(
"input[data-testid='receiveAmount']",
);
await inputReceiveAmount.fill(receiveAmount);

const invoiceInput = page.locator("textarea[data-testid='invoice']");
await invoiceInput.fill(await getBolt12Offer());
const buttonCreateSwap = page.locator(
"button[data-testid='create-swap-button']",
);
await buttonCreateSwap.click();

const skipDownload = page.getByText("Skip download");
await expect(skipDownload).toBeVisible();
});
});
5 changes: 5 additions & 0 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ export const generateInvoiceLnd = async (amount: number): Promise<string> => {
await execCommand(`lncli-sim 1 addinvoice --amt ${amount}`),
).payment_request;
};

export const getBolt12Offer = async (): Promise<string> => {
return JSON.parse(await execCommand("lightning-cli-sim 1 offer any ''"))
.bolt12;
};
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module.exports = {
preset: "solid-jest/preset/browser",
setupFilesAfterEnv: ["<rootDir>/node_modules/@testing-library/jest-dom"],
transformIgnorePatterns: ["node_modules/(?!@solidjs|solid-icons)"],
transformIgnorePatterns: [
"node_modules/(?!@solidjs|solid-icons|boltz-bolt12)",
],
moduleNameMapper: {
"^.+\\.svg": "<rootDir>/tests/mocks/SvgMock.tsx",
"^.+\\.css": "<rootDir>/tests/mocks/StylesMock.tsx",
"^.+\\.scss": "<rootDir>/tests/mocks/StylesMock.tsx",
"boltz-bolt12": "<rootDir>/tests/mocks/bolt12.ts",
},
globals: {
Buffer: Buffer,
Expand Down
Loading