Skip to content

Commit

Permalink
Merge pull request #666 from BoltzExchange/bolt12
Browse files Browse the repository at this point in the history
feat: bolt12 support for submarine swaps
  • Loading branch information
michael1011 authored Oct 6, 2024
2 parents c3a0baa + 8e32075 commit 52f0c19
Show file tree
Hide file tree
Showing 15 changed files with 506 additions and 35 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 52f0c19

Please sign in to comment.