Skip to content

Commit

Permalink
feat: bolt12 support for submarine swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Oct 6, 2024
1 parent c3a0baa commit 8b9c1cb
Show file tree
Hide file tree
Showing 14 changed files with 498 additions and 22 deletions.
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

0 comments on commit 8b9c1cb

Please sign in to comment.