-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
import { | ||
elementsSendToAddress, | ||
generateBitcoinBlock, | ||
generateLiquidBlock, | ||
getBitcoinAddress, | ||
} from "./utils"; | ||
|
||
test.describe("Chain swap", () => { | ||
test.beforeEach(async () => { | ||
await generateBitcoinBlock(); | ||
}); | ||
|
||
test("BTC/L-BTC", async ({ page }) => { | ||
await page.goto("/"); | ||
|
||
const assetSelector = page.locator("div[class='asset asset-LN'] div"); | ||
await assetSelector.click(); | ||
|
||
const lbtcAsset = page.locator("div[data-testid='select-L-BTC']"); | ||
await lbtcAsset.click(); | ||
|
||
const receiveAmount = "0.01"; | ||
const inputReceiveAmount = page.locator( | ||
"input[data-testid='receiveAmount']", | ||
); | ||
await inputReceiveAmount.fill(receiveAmount); | ||
|
||
const inputSendAmount = page.locator("input[data-testid='sendAmount']"); | ||
const sendAmount = "0.0100168"; | ||
await expect(inputSendAmount).toHaveValue(sendAmount); | ||
|
||
const inputOnchainAddress = page.locator( | ||
"input[data-testid='onchainAddress']", | ||
); | ||
await inputOnchainAddress.fill(await getBitcoinAddress()); | ||
|
||
const buttonCreateSwap = page.locator( | ||
"button[data-testid='create-swap-button']", | ||
); | ||
await buttonCreateSwap.click(); | ||
|
||
const skipDownload = page.getByText("Skip download"); | ||
await skipDownload.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 elementsSendToAddress(sendAddress, sendAmount); | ||
await generateLiquidBlock(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
import { | ||
bitcoinSendToAddress, | ||
generateBitcoinBlock, | ||
generateInvoiceLnd, | ||
} from "./utils"; | ||
|
||
test.describe("Submarine swap", () => { | ||
test.beforeEach(async () => { | ||
await generateBitcoinBlock(); | ||
}); | ||
|
||
test("Submarine swap BTC/BTC", 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 inputSendAmount = page.locator("input[data-testid='sendAmount']"); | ||
const sendAmount = "0.01005302"; | ||
await expect(inputSendAmount).toHaveValue(sendAmount); | ||
|
||
const invoiceInput = page.locator("textarea[data-testid='invoice']"); | ||
await invoiceInput.fill( | ||
JSON.parse(await generateInvoiceLnd(1000000)).payment_request, | ||
); | ||
const buttonCreateSwap = page.locator( | ||
"button[data-testid='create-swap-button']", | ||
); | ||
await buttonCreateSwap.click(); | ||
|
||
const skipDownload = page.getByText("Skip download"); | ||
await skipDownload.click(); | ||
|
||
const copyAddressButton = page.getByText("address"); | ||
expect(copyAddressButton).toBeDefined(); | ||
await copyAddressButton.click(); | ||
|
||
const sendAddress = await page.evaluate(() => { | ||
return navigator.clipboard.readText(); | ||
}); | ||
expect(sendAddress).toBeDefined(); | ||
await bitcoinSendToAddress(sendAddress, sendAmount); | ||
|
||
await generateBitcoinBlock(); | ||
// TODO: verify amounts | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters