Skip to content

Commit

Permalink
Merge branch 'integration-tests-signed' into oleh-bairak-qa-720-autom…
Browse files Browse the repository at this point in the history
…ationaccountsblock-automate-negative-test-cases-for
  • Loading branch information
olehbairak authored Apr 8, 2024
2 parents f5ddc30 + 26cf37a commit 5ccebd0
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 17 deletions.
12 changes: 6 additions & 6 deletions packages/app/tests/e2e/features/copying.feature
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ Feature: Copying
Then Clipboard contains "<Text>" value

Examples:
| Row | Text |
| ETH | 0x000000000000000000000000000000000000800A |
| USDC | 0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4 |
| MUTE | 0x0e97C7a0F8B2C9885C8ac9fC6136e829CbC21d42 |
| COMBO | 0xc2B13Bb90E33F1E191b8aA8F44Ce11534D5698E3 |
| PERP | 0x42c1c56be243c250AB24D2ecdcC77F9cCAa59601 |
| Row | Text |
| ETH | 0x000000000000000000000000000000000000800A |
| USDC.e | 0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4 |
| MUTE | 0x0e97C7a0F8B2C9885C8ac9fC6136e829CbC21d42 |
| COMBO | 0xc2B13Bb90E33F1E191b8aA8F44Ce11534D5698E3 |
| PERP | 0x42c1c56be243c250AB24D2ecdcC77F9cCAa59601 |
1 change: 1 addition & 0 deletions packages/integration-tests/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export const localConfig = {

export const environment = {
blockExplorerAPI: "http://localhost:3020",
blockExplorerSepoliaAPI: "https://block-explorer-api.sepolia.zksync.dev",
};
5 changes: 5 additions & 0 deletions packages/integration-tests/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ export enum Values {
txSumETH = "0.000009",
}

export enum Contracts {
greeterContractSepolia = "0x9c6D777A35D127f17eB28B75F80Bb7486118FbE0",
}

export enum IncorrectValues {
incorrectAddressFormat = "0xE4ce1da467a7Ca37727eb7e19857e5167DE25966123",
}

10 changes: 8 additions & 2 deletions packages/integration-tests/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ export class Helper {
await setTimeout(ms);
}

async performBlockExplorerApiGetRequest(apiRoute: string) {
return request(environment.blockExplorerAPI).get(apiRoute);
async performBlockExplorerApiGetRequest(apiRoute: string, network = "local") {
if (network === `sepolia`) {
return request(environment.blockExplorerSepoliaAPI).get(apiRoute);
} else if (network === `local`) {
return request(environment.blockExplorerAPI).get(apiRoute);
} else {
throw new Error(`The API route for the network ${network} is undefined.`);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import * as ethers from "ethers";
import * as zksync from "zksync-web3";

import { localConfig } from "../../../config";
import { Buffer, Logger, Path } from "../../../constants";
import { Buffer, Logger, Path, Values } from "../../../constants";
import { Helper } from "../../../helper";

export const depositEth = async function (sum = "0.000009") {
export const depositEth = async function (sum: string = Values.txSumETH) {
const helper = new Helper();
const syncProvider = new zksync.Provider(localConfig.L2Network);
const ethProvider = ethers.getDefaultProvider(localConfig.L1Network);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import * as ethers from "ethers";
import * as zksync from "zksync-web3";

import { localConfig } from "../../../config";
import { Buffer, Logger, Path, Wallets } from "../../../constants";
import { Buffer, Logger, Path, Values, Wallets } from "../../../constants";
import { Helper } from "../../../helper";

export const transferEth = async function (sum = "0.000009", address: string = Wallets.mainWalletPrivateKey) {
export const transferEth = async function (
sum: string = Values.txSumETH,
address: string = Wallets.mainWalletPrivateKey
) {
const helper = new Helper();
const syncProvider = new zksync.Provider(localConfig.L2Network);
const ethProvider = ethers.getDefaultProvider(localConfig.L1Network);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import * as ethers from "ethers";
import * as zksync from "zksync-web3";

import { localConfig } from "../../../config";
import { Buffer, Logger, Path } from "../../../constants";
import { Buffer, Logger, Path, Values } from "../../../constants";
import { Helper } from "../../../helper";

export const withdrawETH = async function (sum = "0.000009") {
export const withdrawETH = async function (sum: string = Values.txSumETH) {
const helper = new Helper();
const syncProvider = new zksync.Provider(localConfig.L2Network);
const ethProvider = ethers.getDefaultProvider(localConfig.L1Network);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import * as ethers from "ethers";
import * as zksync from "zksync-web3";

import { localConfig } from "../../../config";
import { Buffer, Logger, Path, Wallets } from "../../../constants";
import { Buffer, Logger, Path, Values, Wallets } from "../../../constants";
import { Helper } from "../../../helper";

export const withdrawETHtoOtherAddress = async function (sum = "0.000009") {
export const withdrawETHtoOtherAddress = async function (sum: string = Values.txSumETH) {
const helper = new Helper();
const syncProvider = new zksync.Provider(localConfig.L2Network);
const ethProvider = ethers.getDefaultProvider(localConfig.L1Network);
Expand Down
53 changes: 53 additions & 0 deletions packages/integration-tests/tests/api/contracts.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { localConfig } from "../../src/config";
import { Buffer, Path, Wallets } from "../../src/constants";
import { Contracts } from "../../src/constants";
import { Helper } from "../../src/helper";
import { Playbook } from "../../src/playbook/playbook";

Expand All @@ -21,6 +22,58 @@ describe("API module: Contract", () => {
await playbook.deployMultiCallContracts();
});

//id1851 @Sepolia
it("Verify /api?module=contract&action=checkverifystatus response", async () => {
await helper.runRetriableTestAction(async () => {
apiRoute = `/api?module=contract&action=checkverifystatus&guid=3177`;
response = await helper.performBlockExplorerApiGetRequest(apiRoute, "sepolia");

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Pass - Verified" }));
});
});

//id1695 @Sepolia
it("Verify /api?module=contract&action=getabi response", async () => {
await helper.runRetriableTestAction(async () => {
apiRoute = `/api?module=contract&action=getabi&address=${Contracts.greeterContractSepolia}`;
response = await helper.performBlockExplorerApiGetRequest(apiRoute, "sepolia");

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(typeof response.body.result).toStrictEqual("string");
});
});

//id1802 @Sepolia
it("Verify /api?module=contract&action=getsourcecode response", async () => {
await helper.runRetriableTestAction(async () => {
apiRoute = `/api?module=contract&action=getsourcecode&address=${Contracts.greeterContractSepolia}`;
response = await helper.performBlockExplorerApiGetRequest(apiRoute, "sepolia");

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(typeof response.body.result[0].ABI).toStrictEqual("string");
expect(typeof response.body.result[0].SourceCode).toStrictEqual("string");
expect(typeof response.body.result[0].ConstructorArguments).toStrictEqual("string");
expect(typeof response.body.result[0].ContractName).toStrictEqual("string");
expect(typeof response.body.result[0].EVMVersion).toStrictEqual("string");
expect(typeof response.body.result[0].OptimizationUsed).toStrictEqual("string");
expect(typeof response.body.result[0].Library).toStrictEqual("string");
expect(typeof response.body.result[0].LicenseType).toStrictEqual("string");
expect(typeof response.body.result[0].CompilerVersion).toStrictEqual("string");
expect(typeof response.body.result[0].Runs).toStrictEqual("string");
expect(typeof response.body.result[0].SwarmSource).toStrictEqual("string");
expect(typeof response.body.result[0].Proxy).toStrictEqual("string");
expect(typeof response.body.result[0].Implementation).toStrictEqual("string");
expect(typeof response.body.result[0].ZkCompilerVersion).toBeTruthy();
});
});

//@id1696
it("Verify /api?module=contract&action=getcontractcreation&contractaddresses={address1},{address2} response", async () => {
await helper.runRetriableTestAction(async () => {
Expand Down
20 changes: 20 additions & 0 deletions packages/integration-tests/tests/api/tokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ describe("Tokens", () => {
});
});

//id1907
it("Verify /api?module=token&action=tokeninfo response", async () => {
await helper.runRetriableTestAction(async () => {
apiRoute = `/api?module=token&action=tokeninfo&contractaddress=${Token.ERC20AddressETH}`;
response = await helper.performBlockExplorerApiGetRequest(apiRoute);

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(typeof response.body.result[0].contractAddress).toStrictEqual("string");
expect(typeof response.body.result[0].tokenName).toStrictEqual("string");
expect(typeof response.body.result[0].symbol).toStrictEqual("string");
expect(typeof response.body.result[0].tokenDecimal).toStrictEqual("string");
expect(typeof response.body.result[0].tokenPriceUSD).toStrictEqual("string");
expect(typeof response.body.result[0].liquidity).toStrictEqual("string");
expect(typeof response.body.result[0].l1Address).toStrictEqual("string");
expect(typeof response.body.result[0].iconURL).toStrictEqual("string");
});
});

//id1803
it("Verify the response via /tokens/{address}/transfers", async () => {
await helper.runRetriableTestAction(async () => {
Expand Down
87 changes: 86 additions & 1 deletion packages/integration-tests/tests/ui/transactions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from "@playwright/test";

import { config } from "./config";
import { BlockExplorer, Buffer, Path } from "../../src/constants";
import { BlockExplorer, Buffer, Path, Token, Values, Wallets } from "../../src/constants";
import { Helper } from "../../src/helper";

import type { Locator } from "@playwright/test";
Expand All @@ -10,7 +10,13 @@ const helper = new Helper();
let url: string;
let failedTxHash: string;
let contract: string;
let transaction: string;
let element: Locator;
let elementTx: Locator;
let elementFrom: Locator;
let elementTo: Locator;
let elementContract: Locator;
let elementTxAmount: Locator;
let selector: string;

//@id1656
Expand Down Expand Up @@ -38,3 +44,82 @@ test("Verify deployed the own ERC20 token contract", async ({ page }) => {

await expect(element).toBeVisible(config.extraTimeout);
});

//@id1682
test("Check on BE Transfer ETH token via Portal", async ({ page }) => {
transaction = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdraw);
url = BlockExplorer.baseUrl + `/tx/${transaction}` + BlockExplorer.localNetwork;

await page.goto(url);

selector = `text=${transaction}`;
elementTx = await page.locator(selector).first();

selector = `text=${Wallets.richWalletAddress}`;
elementFrom = await page.locator(selector).first();

selector = `text=${Token.ERC20AddressETH}`;
elementTo = await page.locator(selector).first();

selector = `text=${Values.txSumETH}`;
elementTxAmount = await page.locator(selector).first();

//Check tx Hash
await expect(elementTx).toBeVisible(config.extraTimeout);
//Check address From
await expect(elementFrom).toBeVisible(config.extraTimeout);
//Check address To
await expect(elementTo).toBeVisible(config.extraTimeout);
//Check transaction Amount
await expect(elementTxAmount).toBeVisible(config.extraTimeout);
});

//@id1680
test("Check on BE Transfer custom ERC-20 token via Portal", async ({ page }) => {
transaction = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenI);
const addressTo = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2);
url = BlockExplorer.baseUrl + `/tx/${transaction}` + BlockExplorer.localNetwork;

await page.goto(url);

selector = `text=${transaction}`;
elementTx = await page.locator(selector).first();

selector = `text=${Wallets.richWalletAddress}`;
elementFrom = await page.locator(selector).first();

selector = `text=${addressTo}`;
elementTo = await page.locator(selector).first();

selector = `text=1`;
elementTxAmount = await page.locator(selector).first();

//Check tx Hash
await expect(elementTx).toBeVisible(config.extraTimeout);
//Check address From
await expect(elementFrom).toBeVisible(config.extraTimeout);
//Check address To
await expect(elementTo).toBeVisible(config.extraTimeout);
//Check transaction Amount
await expect(elementTxAmount).toBeVisible(config.extraTimeout);
});

//@id1683
test("Check on BE contract that makes multiple transfers based on stored/retrieved ETH + ERC20", async ({ page }) => {
contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH);
const txAddress = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH);
url = BlockExplorer.baseUrl + `/address/${contract}` + BlockExplorer.localNetwork;

await page.goto(url);

selector = `text=${contract}`;
elementContract = await page.locator(selector).first();

selector = `text=${txAddress}`;
elementTx = await page.locator(selector).first();

//Check contract Address
await expect(elementContract).toBeVisible(config.extraTimeout);
//Check tx Hash
await expect(elementTx).toBeVisible(config.extraTimeout);
});

0 comments on commit 5ccebd0

Please sign in to comment.