Skip to content

Commit

Permalink
Merge pull request #1037 from getAlby/bugfix/umbrel-connection-refused
Browse files Browse the repository at this point in the history
fix: url should include port number
  • Loading branch information
bumi authored Jun 13, 2022
2 parents fdd8e8f + a65be8c commit e868ba2
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/screens/connectors/ConnectMyNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ConnectMyNode() {
let lndconnect = new URL(lndconnectUrl);
lndconnect.protocol = "http:";
lndconnect = new URL(lndconnect.toString());
const url = `https://${lndconnect.hostname}${lndconnect.pathname}`;
const url = `https://${lndconnect.host}${lndconnect.pathname}`;
let macaroon = lndconnect.searchParams.get("macaroon") || "";
macaroon = utils.urlSafeBase64ToHex(macaroon);
// const cert = lndconnect.searchParams.get("cert"); // TODO: handle LND certs with the native connector
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/connectors/ConnectStart9/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ConnectStart9() {
let lndconnect = new URL(lndconnectUrl);
lndconnect.protocol = "http:";
lndconnect = new URL(lndconnect.toString());
const url = `https://${lndconnect.hostname}${lndconnect.pathname}`;
const url = `https://${lndconnect.host}${lndconnect.pathname}`;
let macaroon = lndconnect.searchParams.get("macaroon") || "";
macaroon = utils.urlSafeBase64ToHex(macaroon);
// const cert = lndconnect.searchParams.get("cert"); // TODO: handle LND certs with the native connector
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/connectors/ConnectUmbrel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ConnectUmbrel() {
let lndconnect = new URL(lndconnectUrl);
lndconnect.protocol = "http:";
lndconnect = new URL(lndconnect.toString());
const url = `https://${lndconnect.hostname}${lndconnect.pathname}`;
const url = `https://${lndconnect.host}${lndconnect.pathname}`;
let macaroon = lndconnect.searchParams.get("macaroon") || "";
macaroon = utils.urlSafeBase64ToHex(macaroon);
// const cert = lndconnect.searchParams.get("cert"); // TODO: handle LND certs with the native connector
Expand Down
69 changes: 68 additions & 1 deletion tests/e2e/createWallets.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { test } from "@playwright/test";
import { USER } from "complete-randomer";
import { getDocument, queries, waitFor } from "pptr-testing-library";
const { getByText, getByLabelText } = queries;

import { loadExtension } from "./helpers/loadExtension";

const { getByText, getByLabelText } = queries;

const commonCreateWalletUserCreate = async () => {
const user = USER.SINGLE();
const { page: welcomePage, browser } = await loadExtension();
Expand Down Expand Up @@ -148,6 +149,72 @@ test.describe("Create or connect wallets", () => {
await commonCreateWalletSuccessCheck({ browser, welcomePage, $document });
});

test("successfully connects to Umbrel", async () => {
const { browser, welcomePage, $document } =
await commonCreateWalletUserCreate();

const connectButton = await getByText($document, "Umbrel");
connectButton.click();

// wait for the field label instead of headline (headline text already exists on the page before)
await waitFor(() => getByText($document, "lndconnect REST URL"));

const macaroon =
"AgEDbG5kAvgBAwoQ4hM6HKwsW01W5E4y3GTIVRIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgxPl4Pghz-lCiCRgG9eu5GcXcQy4zgAtAFGOtpkhd8O0";
const restApiUrl = `lndconnect://lnd1.regtest.getalby.com?cert=&macaroon=${macaroon}`;
const lndConnectUrlField = await getByLabelText(
$document,
"lndconnect REST URL"
);
await lndConnectUrlField.type(restApiUrl);

await commonCreateWalletSuccessCheck({ browser, welcomePage, $document });
});

test("successfully connects to myNode", async () => {
const { browser, welcomePage, $document } =
await commonCreateWalletUserCreate();

const connectButton = await getByText($document, "myNode");
connectButton.click();

// wait for the field label instead of headline (headline text already exists on the page before)
await waitFor(() => getByText($document, "lndconnect REST URL"));

const macaroon =
"AgEDbG5kAvgBAwoQ4hM6HKwsW01W5E4y3GTIVRIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgxPl4Pghz-lCiCRgG9eu5GcXcQy4zgAtAFGOtpkhd8O0";
const restApiUrl = `lndconnect://lnd1.regtest.getalby.com?cert=&macaroon=${macaroon}`;
const lndConnectUrlField = await getByLabelText(
$document,
"lndconnect REST URL"
);
await lndConnectUrlField.type(restApiUrl);

await commonCreateWalletSuccessCheck({ browser, welcomePage, $document });
});

test("successfully connects to Start9", async () => {
const { browser, welcomePage, $document } =
await commonCreateWalletUserCreate();

const connectButton = await getByText($document, "Start9");
connectButton.click();

// wait for the field label instead of headline (headline text already exists on the page before)
await waitFor(() => getByText($document, "lndconnect REST URL"));

const macaroon =
"AgEDbG5kAvgBAwoQ4hM6HKwsW01W5E4y3GTIVRIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgxPl4Pghz-lCiCRgG9eu5GcXcQy4zgAtAFGOtpkhd8O0";
const restApiUrl = `lndconnect://lnd1.regtest.getalby.com?cert=&macaroon=${macaroon}`;
const lndConnectUrlField = await getByLabelText(
$document,
"lndconnect REST URL"
);
await lndConnectUrlField.type(restApiUrl);

await commonCreateWalletSuccessCheck({ browser, welcomePage, $document });
});

test("successfully connects to Eclair", async () => {
const { browser, welcomePage, $document } =
await commonCreateWalletUserCreate();
Expand Down

0 comments on commit e868ba2

Please sign in to comment.