diff --git a/e2e/chainSwaps/chainSwaps.spec.ts b/e2e/chainSwaps/chainSwaps.spec.ts index d49ee342..56faac3d 100644 --- a/e2e/chainSwaps/chainSwaps.spec.ts +++ b/e2e/chainSwaps/chainSwaps.spec.ts @@ -5,6 +5,7 @@ import { generateBitcoinBlock, generateLiquidBlock, getBitcoinAddress, + getBitcoinWalletTx, } from "../utils"; test.describe("Chain swap", () => { @@ -56,6 +57,13 @@ test.describe("Chain swap", () => { await elementsSendToAddress(sendAddress, sendAmount); await generateLiquidBlock(); - // TODO: verify amounts + + const txIdLink = page.getByText("open claim transaction"); + + const txId = (await txIdLink.getAttribute("href")).split("/").pop(); + expect(txId).toBeDefined(); + + const txInfo = JSON.parse(await getBitcoinWalletTx(txId)); + expect(txInfo.amount.toString()).toEqual(receiveAmount); }); }); diff --git a/e2e/chainSwaps/zeroAmount.spec.ts b/e2e/chainSwaps/zeroAmount.spec.ts index 9ef96d29..216b5f44 100644 --- a/e2e/chainSwaps/zeroAmount.spec.ts +++ b/e2e/chainSwaps/zeroAmount.spec.ts @@ -1,8 +1,59 @@ import { expect, test } from "@playwright/test"; -import { getBitcoinAddress } from "../utils"; +import { + bitcoinSendToAddress, + generateBitcoinBlock, + getBitcoinAddress, + getElementsWalletTx, + getLiquidAddress, +} from "../utils"; test.describe("Chain Swap 0-amount", () => { + test("BTC/L-BTC", async ({ page }) => { + await page.goto("/"); + + await page + .locator( + "div:nth-child(3) > .asset-wrap > .asset > .asset-selection > .arrow-down", + ) + .click(); + await page.getByTestId("select-L-BTC").click(); + + await page.locator(".arrow-down").first().click(); + await page.getByTestId("select-BTC").click(); + + await page.getByTestId("onchainAddress").click(); + + const liquidAddress = await getLiquidAddress(); + await page.getByTestId("onchainAddress").fill(liquidAddress); + await page.getByTestId("create-swap-button").click(); + + await page.getByRole("button", { name: "Skip download" }).click(); + + const buttons = page.locator("div[data-testid='pay-onchain-buttons']"); + const copyAddressButton = buttons.getByText("address"); + expect(copyAddressButton).toBeDefined(); + await copyAddressButton.click(); + + const sendAddress = await page.evaluate(() => { + return navigator.clipboard.readText(); + }); + expect(sendAddress).toBeDefined(); + + await bitcoinSendToAddress(sendAddress, "0.01"); + + await page.getByRole("button", { name: "Accept" }).click(); + await generateBitcoinBlock(); + + const txIdLink = page.getByText("open claim transaction"); + + const txId = (await txIdLink.getAttribute("href")).split("/").pop(); + expect(txId).toBeDefined(); + + const txInfo = JSON.parse(await getElementsWalletTx(txId)); + expect(txInfo.amount.bitcoin.toString()).toEqual("0.0099865"); + }); + test("should allow 0-amount chain swaps", async ({ page }) => { await page.goto("/"); diff --git a/e2e/utils.ts b/e2e/utils.ts index 4a08a3e2..1a6816c7 100644 --- a/e2e/utils.ts +++ b/e2e/utils.ts @@ -52,6 +52,9 @@ export const generateLiquidBlock = (): Promise => export const getBitcoinWalletTx = (txId: string): Promise => execCommand(`bitcoin-cli-sim-client gettransaction ${txId}`); +export const getElementsWalletTx = (txId: string): Promise => + execCommand(`elements-cli-sim-client gettransaction ${txId}`); + export const payInvoiceLnd = (invoice: string): Promise => execCommand(`lncli-sim 1 payinvoice -f ${invoice}`); diff --git a/regtest b/regtest index 6e103c77..cf4bb2da 160000 --- a/regtest +++ b/regtest @@ -1 +1 @@ -Subproject commit 6e103c773c3fbe35ff341e56b9c5a3893cb2681b +Subproject commit cf4bb2da7b378289d7c5fb0ef85bd9c119845306 diff --git a/src/components/SwapChecker.tsx b/src/components/SwapChecker.tsx index 00bcb217..ecb4aaec 100644 --- a/src/components/SwapChecker.tsx +++ b/src/components/SwapChecker.tsx @@ -277,7 +277,7 @@ export const SwapChecker = () => { ); } catch (e) { const msg = t("claim_fail", { id: currentSwap.id }); - log.warn(msg, formatError(e)); + log.warn(msg, await handleRequestError(e)); notify("error", msg); } } else if ( diff --git a/src/status/TransactionLockupFailed.tsx b/src/status/TransactionLockupFailed.tsx index 7dc431e0..fd30d867 100644 --- a/src/status/TransactionLockupFailed.tsx +++ b/src/status/TransactionLockupFailed.tsx @@ -164,6 +164,10 @@ const TransactionLockupFailed = (props: { const newSwap = swap() as ChainSwap; const { quote, receiveAmount } = newQuote(); + log.info( + `Accepting new quote for swap ${newSwap.id}`, + { quote, receiveAmount }, + ); newSwap.receiveAmount = receiveAmount; newSwap.claimDetails.amount = quote;