Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit b93dcde

Browse files
committed
throw error if faucet fails
1 parent 3fd95e6 commit b93dcde

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

e2e/roundtrip.spec.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,23 @@ test("rountrip receive and send", async ({ page }) => {
5454
// The SVG's value property includes "lightning:l"
5555
expect(value).toContain("lightning:l");
5656

57-
const lightningInvoice = value?.split("lightning:")[1];
58-
5957
// Post the lightning invoice to the server
60-
const _response = await fetch(
61-
"https://faucet.mutinynet.com/api/lightning",
62-
{
63-
method: "POST",
64-
headers: {
65-
"Content-Type": "application/json"
66-
},
67-
body: JSON.stringify({
68-
bolt11: lightningInvoice
69-
})
70-
}
71-
);
58+
const response = await fetch("https://faucet.mutinynet.com/api/lightning", {
59+
method: "POST",
60+
mode: "cors",
61+
headers: {
62+
"Content-Type": "application/json"
63+
},
64+
body: JSON.stringify({
65+
bolt11: value
66+
})
67+
});
68+
69+
if (!response.ok) {
70+
response.text().then((text) => {
71+
throw new Error("failed to post invoice to faucet: " + text);
72+
});
73+
}
7274

7375
// Wait for an h1 to appear in the dom that says "Payment Received"
7476
await page.waitForSelector("text=Payment Received", { timeout: 30000 });

src/components/FederationPopup.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function FederationPopup() {
1818

1919
return (
2020
<SimpleDialog
21-
title={i18n.t("activity.federation_message")}
21+
title={`${i18n.t("activity.federation_message")}: ${state.expiration_warning?.federationName}`}
2222
open={showFederationExpirationWarning()}
2323
setOpen={(open: boolean) => {
2424
if (!open) {

src/state/megaStore.tsx

+19-5
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ export const makeMegaStoreContext = () => {
8989
federations: undefined as MutinyFederationIdentity[] | undefined,
9090
balanceView: localStorage.getItem("balanceView") || "sats",
9191
expiration_warning: undefined as
92-
| { expiresTimestamp: number; expiresMessage: string }
92+
| {
93+
expiresTimestamp: number;
94+
expiresMessage: string;
95+
federationName: string;
96+
}
9397
| undefined,
9498
expiration_warning_seen: false
9599
});
@@ -233,14 +237,19 @@ export const makeMegaStoreContext = () => {
233237
const federations = await sw.list_federations();
234238

235239
let expiration_warning:
236-
| { expiresTimestamp: number; expiresMessage: string }
240+
| {
241+
expiresTimestamp: number;
242+
expiresMessage: string;
243+
federationName: string;
244+
}
237245
| undefined = undefined;
238246

239247
federations.forEach((f) => {
240248
if (f.popup_countdown_message && f.popup_end_timestamp) {
241249
expiration_warning = {
242250
expiresTimestamp: f.popup_end_timestamp,
243-
expiresMessage: f.popup_countdown_message
251+
expiresMessage: f.popup_countdown_message,
252+
federationName: f.federation_name
244253
};
245254
}
246255
});
@@ -485,14 +494,19 @@ export const makeMegaStoreContext = () => {
485494
const federations = await sw.list_federations();
486495

487496
let expiration_warning:
488-
| { expiresTimestamp: number; expiresMessage: string }
497+
| {
498+
expiresTimestamp: number;
499+
expiresMessage: string;
500+
federationName: string;
501+
}
489502
| undefined = undefined;
490503

491504
federations.forEach((f) => {
492505
if (f.popup_countdown_message && f.popup_end_timestamp) {
493506
expiration_warning = {
494507
expiresTimestamp: f.popup_end_timestamp,
495-
expiresMessage: f.popup_countdown_message
508+
expiresMessage: f.popup_countdown_message,
509+
federationName: f.federation_name
496510
};
497511
}
498512
});

0 commit comments

Comments
 (0)