Skip to content

Commit

Permalink
throw error if faucet fails
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed May 9, 2024
1 parent 3fd95e6 commit 8eb9312
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions e2e/roundtrip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,23 @@ test("rountrip receive and send", async ({ page }) => {
// The SVG's value property includes "lightning:l"
expect(value).toContain("lightning:l");

const lightningInvoice = value?.split("lightning:")[1];

// Post the lightning invoice to the server
const _response = await fetch(
"https://faucet.mutinynet.com/api/lightning",
{
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
bolt11: lightningInvoice
})
}
);
const response = await fetch("https://faucet.mutinynet.com/api/lightning", {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
bolt11: value
})
});

if (!response.ok) {
response.text().then((text) => {
throw new Error("failed to post invoice to faucet: " + text);
});
}

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

0 comments on commit 8eb9312

Please sign in to comment.