-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from matter-labs/QA-543-cover-the-Deposit-tests
test: covering UI tests for Deposit
- Loading branch information
Showing
4 changed files
with
68 additions
and
11 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
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
12 changes: 7 additions & 5 deletions
12
packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts
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 |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import * as ethers from "ethers"; | ||
import { promises as fs } from "fs"; | ||
import * as zksync from "zksync-web3"; | ||
|
||
import { localConfig } from "../../../config"; | ||
import { Logger } from "../../../entities"; | ||
import { Buffer, Logger } from "../../../entities"; | ||
import { Helper } from "../../../helper"; | ||
|
||
export const depositEth = async function (sum = "0.000009") { | ||
const helper = new Helper(); | ||
const syncProvider = new zksync.Provider(localConfig.L2Network); | ||
const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); | ||
const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); | ||
const playbookRoot = "src/playbook/"; | ||
const bufferFile = playbookRoot + Buffer.txEthDeposit; | ||
|
||
const deposit = await syncWallet.deposit({ | ||
token: zksync.utils.ETH_ADDRESS, | ||
amount: ethers.utils.parseEther(sum), | ||
l2GasLimit: localConfig.l2GasLimit, | ||
}); | ||
|
||
const txHash = deposit.hash; | ||
|
||
await deposit.wait(1); | ||
await helper.txHashLogger(Logger.deposit, txHash, "ETH"); | ||
const txHash = await deposit.waitFinalize(); | ||
await helper.txHashLogger(Logger.deposit, txHash.transactionHash, "ETH"); | ||
await fs.writeFile(bufferFile, txHash.transactionHash); | ||
|
||
return txHash; | ||
}; |
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,53 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
import { config } from "./config"; | ||
import { BlockExplorer, Buffer, Wallets } from "../../src/entities"; | ||
import { Helper } from "../../src/helper"; | ||
|
||
import type { Locator } from "@playwright/test"; | ||
|
||
const bufferRoute = "src/playbook/"; | ||
const helper = new Helper(); | ||
let url: string; | ||
let bufferFile; | ||
let depositTxHash: string; | ||
let initiatorAddress: string; | ||
let hash, initiatorAddressElement, ethValue, erc20Value: Locator; | ||
|
||
//@id1660 | ||
test("Check Deposit ETH transaction on BE", async ({ page }) => { | ||
bufferFile = bufferRoute + Buffer.txEthDeposit; | ||
depositTxHash = await helper.getStringFromFile(bufferFile); | ||
url = BlockExplorer.baseUrl + `/tx/${depositTxHash}` + BlockExplorer.localNetwork; | ||
initiatorAddress = Wallets.richWalletAddress; | ||
|
||
await page.goto(url); | ||
|
||
hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${depositTxHash}"]`).first(); | ||
initiatorAddressElement = await page.locator(`text=${initiatorAddress}`).first(); | ||
ethValue = await page.locator(`text=0.0000001`).first(); | ||
|
||
await expect(hash).toBeVisible(config.defaultTimeout); | ||
await expect(ethValue).toBeVisible(config.defaultTimeout); | ||
await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); | ||
}); | ||
|
||
//@id1681 | ||
test("Check on BE Deposit the custom ERC-20 token", async ({ page }) => { | ||
bufferFile = bufferRoute + Buffer.txERC20Deposit; | ||
depositTxHash = await helper.getStringFromFile(bufferFile); | ||
url = BlockExplorer.baseUrl + `/tx/${depositTxHash}` + BlockExplorer.localNetwork; | ||
initiatorAddress = Wallets.richWalletAddress; | ||
|
||
await page.goto(url); | ||
|
||
hash = await page.locator(`//*[text()="Transaction Hash"]/..//..//*[text()="${depositTxHash}"]`).first(); | ||
initiatorAddressElement = await page.locator( | ||
`//*[text()="From"]/..//*[text()="L1"]/..//*[text()="0x36615Cf349d...c049"]` | ||
); | ||
erc20Value = await page.locator(`//*[text()="0x36615Cf349d...c049"]/..//..//*[text()="100"]`); | ||
|
||
await expect(hash).toBeVisible(config.defaultTimeout); | ||
await expect(erc20Value).toBeVisible(config.defaultTimeout); | ||
await expect(initiatorAddressElement).toBeVisible(config.defaultTimeout); | ||
}); |