From b0a38a050000fc7cd6fc514bb0d90e3c96a24570 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 7 Mar 2024 16:34:57 +0100 Subject: [PATCH] test: refactoring path and variables --- .../src/playbook/deploy/use-greeter.ts | 5 +- .../src/playbook/deploy/use-paymaster.ts | 10 +- .../tests/api/accounts.test.ts | 3 +- .../tests/api/addresses.test.ts | 33 +++--- .../tests/api/contracts.test.ts | 11 +- .../integration-tests/tests/api/logs.test.ts | 7 +- .../tests/api/transactions.test.ts | 105 +++++++++--------- .../integration-tests/tests/hooks/global.ts | 6 +- .../tests/ui/deposit.spec.ts | 10 +- .../tests/ui/multiCall.spec.ts | 13 +-- .../integration-tests/tests/ui/nft.spec.ts | 10 +- .../tests/ui/transactions.spec.ts | 10 +- 12 files changed, 97 insertions(+), 126 deletions(-) diff --git a/packages/integration-tests/src/playbook/deploy/use-greeter.ts b/packages/integration-tests/src/playbook/deploy/use-greeter.ts index 38a91fb9f7..a1e232b7b1 100644 --- a/packages/integration-tests/src/playbook/deploy/use-greeter.ts +++ b/packages/integration-tests/src/playbook/deploy/use-greeter.ts @@ -3,18 +3,17 @@ import { promises as fs } from "fs"; import { Provider, Wallet } from "zksync-web3"; import { localConfig } from "../../config"; -import { Wallets } from "../../constants"; +import { Path, Wallets } from "../../constants"; import { Buffer } from "../../constants"; import { Helper } from "../../helper"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; export default async function (hre: HardhatRuntimeEnvironment) { - const bufferRoute = "src/playbook/"; const helper = new Helper(); let contract: any; // eslint-disable-line - const greeterContractAddress = await helper.readFile(bufferRoute + Buffer.greeterL2); + const greeterContractAddress = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.greeterL2); const provider = new Provider(localConfig.L2Network); const wallet = new Wallet(Wallets.richWalletPrivateKey, provider); diff --git a/packages/integration-tests/src/playbook/deploy/use-paymaster.ts b/packages/integration-tests/src/playbook/deploy/use-paymaster.ts index 0315bcb78b..807af7172c 100644 --- a/packages/integration-tests/src/playbook/deploy/use-paymaster.ts +++ b/packages/integration-tests/src/playbook/deploy/use-paymaster.ts @@ -3,18 +3,16 @@ import { promises as fs } from "fs"; import { Provider, utils, Wallet } from "zksync-web3"; import { localConfig } from "../../config"; -import { Buffer } from "../../constants"; +import { Buffer, Path } from "../../constants"; import { Helper } from "../../helper"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; const helper = new Helper(); export default async function (hre: HardhatRuntimeEnvironment) { - const bufferRoute = "src/playbook/"; - - const PAYMASTER_ADDRESS = await helper.readFile(bufferRoute + Buffer.paymaster); - const TOKEN_ADDRESS = await helper.readFile(bufferRoute + Buffer.customToken); - const EMPTY_WALLET_PRIVATE_KEY = await helper.readFile(bufferRoute + Buffer.emptyWalletPrivateKey); + const PAYMASTER_ADDRESS = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymaster); + const TOKEN_ADDRESS = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.customToken); + const EMPTY_WALLET_PRIVATE_KEY = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.emptyWalletPrivateKey); const provider = new Provider(localConfig.L2Network); const emptyWallet = new Wallet(EMPTY_WALLET_PRIVATE_KEY, provider); diff --git a/packages/integration-tests/tests/api/accounts.test.ts b/packages/integration-tests/tests/api/accounts.test.ts index e75aab0ae8..ff34dc2a93 100644 --- a/packages/integration-tests/tests/api/accounts.test.ts +++ b/packages/integration-tests/tests/api/accounts.test.ts @@ -10,7 +10,6 @@ describe("API module: Account", () => { jest.setTimeout(localConfig.standardTimeout); const helper = new Helper(); - const bufferFile = "src/playbook/"; let apiRoute: string; let response; const playbook = new Playbook(); @@ -215,7 +214,7 @@ describe("API module: Account", () => { await helper.runRetriableTestAction(async () => { const blocks = await request(environment.blockExplorerAPI).get("/blocks"); const blockNumber = blocks.body.items[0].number; - const nftAddress = await helper.readFile(bufferFile + Buffer.NFTtoL2); + const nftAddress = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL2); apiRoute = `/api?module=account&action=tokennfttx&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${nftAddress}&address=${nftAddress}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); diff --git a/packages/integration-tests/tests/api/addresses.test.ts b/packages/integration-tests/tests/api/addresses.test.ts index 4fb9a73a94..237f05be27 100644 --- a/packages/integration-tests/tests/api/addresses.test.ts +++ b/packages/integration-tests/tests/api/addresses.test.ts @@ -1,5 +1,5 @@ import { localConfig } from "../../src/config"; -import { Buffer, Token, Wallets } from "../../src/constants"; +import { Buffer, Path, Token, Wallets } from "../../src/constants"; import { Helper } from "../../src/helper"; import { Playbook } from "../../src/playbook/playbook"; @@ -8,7 +8,6 @@ describe("Address", () => { const helper = new Helper(); const playbook = new Playbook(); - const bufferFile = "src/playbook/"; let apiRoute: string; let contract: string; let token: string; @@ -29,7 +28,7 @@ describe("Address", () => { //@id1457 it("Verify deployed to L2 NFT via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - token = await helper.readFile(bufferFile + Buffer.NFTtoL2); + token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL2); apiRoute = `/address/${token}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -52,8 +51,8 @@ describe("Address", () => { //@id1464 it("Verify the deployed Root contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.addressMultiCallRoot); - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallRoot); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallRoot); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -69,8 +68,8 @@ describe("Address", () => { //@id1465 it("Verify the deployed Middle contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.addressMultiCallMiddle); - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallMiddle); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallMiddle); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallMiddle); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -86,8 +85,8 @@ describe("Address", () => { //@id1466 it("Verify the deployed Caller contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.addressMultiCallCaller); - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallCaller); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallCaller); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallCaller); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -103,7 +102,7 @@ describe("Address", () => { //@id1476 it("Verify the deployed multitransfer contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -116,7 +115,7 @@ describe("Address", () => { //@id1449 it("Verify the deployed Greeter contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.greeterL2); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.greeterL2); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -135,8 +134,8 @@ describe("Address", () => { //@id1510 it("Verify the transaction via /address/{address}/logs", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.greeterL2); - txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.greeterL2); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.executeGreeterTx); apiRoute = `/address/${contract}/logs`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -176,10 +175,10 @@ describe("Address", () => { //@id1509 it("Verify the transaction via /address/{address}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.paymaster); - const emptyWallet = await helper.readFile(bufferFile + Buffer.emptyWalletAddress); - txHash = await helper.readFile(bufferFile + Buffer.paymasterTx); - const customTokenAddress = await helper.readFile(bufferFile + Buffer.customToken); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymaster); + const emptyWallet = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.emptyWalletAddress); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymasterTx); + const customTokenAddress = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.customToken); apiRoute = `/address/${contract}/transfers`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); diff --git a/packages/integration-tests/tests/api/contracts.test.ts b/packages/integration-tests/tests/api/contracts.test.ts index 9c17f8c0ac..4bfc593be2 100644 --- a/packages/integration-tests/tests/api/contracts.test.ts +++ b/packages/integration-tests/tests/api/contracts.test.ts @@ -1,5 +1,5 @@ import { localConfig } from "../../src/config"; -import { Buffer, Wallets } from "../../src/constants"; +import { Buffer, Path, Wallets } from "../../src/constants"; import { Helper } from "../../src/helper"; import { Playbook } from "../../src/playbook/playbook"; @@ -8,7 +8,6 @@ describe("API module: Contract", () => { const helper = new Helper(); const playbook = new Playbook(); - const bufferFile = "src/playbook/"; let apiRoute: string; let paymasterContract: string; let paymasterTx: string; @@ -25,10 +24,10 @@ describe("API module: Contract", () => { //@id1696 it("Verify /api?module=contract&action=getcontractcreation&contractaddresses={address1},{address2} response", async () => { await helper.runRetriableTestAction(async () => { - paymasterContract = await helper.readFile(bufferFile + Buffer.paymaster); - paymasterTx = await helper.readFile(bufferFile + Buffer.paymasterDeployTx); - multicallCallerContract = await helper.readFile(bufferFile + Buffer.addressMultiCallCaller); - multicallCallerTx = await helper.readFile(bufferFile + Buffer.txMultiCallCaller); + paymasterContract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymaster); + paymasterTx = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymasterDeployTx); + multicallCallerContract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallCaller); + multicallCallerTx = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallCaller); apiRoute = `/api?module=contract&action=getcontractcreation&contractaddresses=${paymasterContract},${multicallCallerContract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); diff --git a/packages/integration-tests/tests/api/logs.test.ts b/packages/integration-tests/tests/api/logs.test.ts index e7348f48e2..626e14e1b4 100644 --- a/packages/integration-tests/tests/api/logs.test.ts +++ b/packages/integration-tests/tests/api/logs.test.ts @@ -1,5 +1,5 @@ import { localConfig } from "../../src/config"; -import { Buffer } from "../../src/constants"; +import { Buffer, Path } from "../../src/constants"; import { Helper } from "../../src/helper"; import { Playbook } from "../../src/playbook/playbook"; @@ -7,7 +7,6 @@ describe("API module: Logs", () => { jest.setTimeout(localConfig.standardTimeout); //works unstable without timeout const helper = new Helper(); - const bufferFile = "src/playbook/"; const playbook = new Playbook(); let apiRoute: string; let contractAddress: string; @@ -23,8 +22,8 @@ describe("API module: Logs", () => { //@id1808 it("Verify /api?module=logs&action=getLogs&page={page}&offset={offset}0&toBlock={toBlock}&fromBlock={fromBlock}&address={address} response", async () => { await helper.runRetriableTestAction(async () => { - contractAddress = await helper.readFile(bufferFile + Buffer.greeterL2); - txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); + contractAddress = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.greeterL2); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.executeGreeterTx); apiRoute = `/api?module=logs&action=getLogs&page=1&offset=10&toBlock=10000&fromBlock=1&address=${contractAddress}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); diff --git a/packages/integration-tests/tests/api/transactions.test.ts b/packages/integration-tests/tests/api/transactions.test.ts index eb39d4ab4f..fd75925e97 100644 --- a/packages/integration-tests/tests/api/transactions.test.ts +++ b/packages/integration-tests/tests/api/transactions.test.ts @@ -1,5 +1,5 @@ import { localConfig } from "../../src/config"; -import { Buffer, Token, TransactionStatus, TransactionsType, Wallets } from "../../src/constants"; +import { Buffer, Path, Token, TransactionStatus, TransactionsType, Wallets } from "../../src/constants"; import { Helper } from "../../src/helper"; import { Playbook } from "../../src/playbook/playbook"; @@ -7,7 +7,6 @@ describe("Transactions", () => { jest.setTimeout(localConfig.extendedTimeout); const helper = new Helper(); - const bufferFile = "src/playbook/"; const playbook = new Playbook(); let apiRoute: string; let contract: string; @@ -16,7 +15,7 @@ describe("Transactions", () => { let response; beforeAll(async () => { - const customToken = await helper.readFile(bufferFile + Buffer.L2deposited); + const customToken = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited); await playbook.withdrawETHtoOtherAddress(); await playbook.withdrawERC20(customToken); await playbook.withdrawERC20toOtherAddress(customToken); @@ -37,7 +36,7 @@ describe("Transactions", () => { //@id1447 it("Verify transfer ETH L2-L2 via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txEthTransfer); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthTransfer); apiRoute = `/transactions/${txHash}/transfers`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -78,7 +77,7 @@ describe("Transactions", () => { //@id1459 it("Verify the ETH withdrawal via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txEthWithdraw); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdraw); apiRoute = `/transactions/${txHash}/transfers`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -128,7 +127,7 @@ describe("Transactions", () => { //@id1461 it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txEthWithdrawOtherAddress); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdrawOtherAddress); apiRoute = `/transactions/${txHash}/transfers`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -178,11 +177,9 @@ describe("Transactions", () => { //@id1463 it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - const l1Token = bufferFile + "/" + Buffer.L1; - const customTokenL1 = await helper.readFile(l1Token); - const l2Token = bufferFile + "/" + Buffer.L2deposited; - const customTokenL2 = await helper.readFile(l2Token); - txHash = await helper.readFile(bufferFile + Buffer.txERC20WithdrawOtherAddress); + const customTokenL1 = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L1); + const customTokenL2 = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txERC20WithdrawOtherAddress); apiRoute = `/transactions/${txHash}/transfers`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -310,14 +307,14 @@ describe("Transactions", () => { describe("/transactions/{transactionHash}", () => { beforeAll(async () => { - const customToken = await helper.readFile(bufferFile + Buffer.L2deposited); + const customToken = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited); await playbook.transferFailedState(customToken); }); //@id1460 it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txEthWithdrawOtherAddress); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdrawOtherAddress); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -363,7 +360,7 @@ describe("Transactions", () => { //@id1462 it("Verify the custom token withdrawal via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txERC20Withdraw); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txERC20Withdraw); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -409,7 +406,7 @@ describe("Transactions", () => { //@id1458 it("Verify the ETH withdrawal via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txEthWithdraw); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdraw); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -455,8 +452,8 @@ describe("Transactions", () => { //@id1478 it("Verify transaction for the ETH via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferETH); - contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -502,8 +499,8 @@ describe("Transactions", () => { //@id1479 it("Verify transaction for the Custom Token I via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.L2); - txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferCustomTokenI); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenI); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -549,8 +546,8 @@ describe("Transactions", () => { //@id1480 it("Verify transaction for the Custom Token II via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.L2deposited); - txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferCustomTokenII); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenII); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -596,8 +593,8 @@ describe("Transactions", () => { //@id1454 it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.greeterL2); - txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.greeterL2); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.executeGreeterTx); apiRoute = `/transactions/${txHash}?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -644,7 +641,7 @@ describe("Transactions", () => { //@id1464:I --> @id1468 it("Verify transaction for the Root contract via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallRoot); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallRoot); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -692,7 +689,7 @@ describe("Transactions", () => { //@id1465:I --> @id1469 it("Verify transaction for the Middle contract via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallMiddle); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallMiddle); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -740,7 +737,7 @@ describe("Transactions", () => { //@id1466:I --> @id1470 it("Verify transaction for the Caller contract via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallCaller); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallCaller); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -788,7 +785,7 @@ describe("Transactions", () => { //@id1471 it("Verify transaction for the use multicall contract via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txUseMultiCallContracts); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txUseMultiCallContracts); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -834,8 +831,8 @@ describe("Transactions", () => { //@id645 it("Verify the transactions with failed state via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - token = await helper.readFile(bufferFile + Buffer.L2deposited); - txHash = await helper.readFile(bufferFile + Buffer.failedState); + token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.failedState); apiRoute = `/transactions/${txHash}?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -890,8 +887,8 @@ describe("Transactions", () => { //@id1481 it("Verify transaction for the ETH via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); - txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferETH); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -967,9 +964,9 @@ describe("Transactions", () => { //@id1482 it("Verify transaction for the Custom tokenI via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - token = await helper.readFile(bufferFile + Buffer.L2); - contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); - txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferCustomTokenI); + token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenI); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1045,10 +1042,10 @@ describe("Transactions", () => { //@id1483 it("Verify transaction for the Custom tokenII via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - const tokenL1 = await helper.readFile(bufferFile + Buffer.L1); - token = await helper.readFile(bufferFile + Buffer.L2deposited); - contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); - txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferCustomTokenII); + const tokenL1 = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L1); + token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenII); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1124,10 +1121,10 @@ describe("Transactions", () => { //@id1452 it("Verify transaction through Paymaster via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - const paymasterAddress = await helper.readFile(bufferFile + Buffer.paymaster); - const emptyWallet = await helper.readFile(bufferFile + Buffer.emptyWalletAddress); - token = await helper.readFile(bufferFile + Buffer.customToken); - txHash = await helper.readFile(bufferFile + Buffer.paymasterTx); + const paymasterAddress = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymaster); + const emptyWallet = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.emptyWalletAddress); + token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.customToken); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymasterTx); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1204,7 +1201,7 @@ describe("Transactions", () => { //@id1455 it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.executeGreeterTx); apiRoute = `/transactions/${txHash}/transfers`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1280,8 +1277,8 @@ describe("Transactions", () => { //@id1472 it("Verify transaction for the Root contract via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.addressMultiCallRoot); - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallRoot); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallRoot); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1337,8 +1334,8 @@ describe("Transactions", () => { //@id1473 it("Verify transaction for the Middle contract via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.addressMultiCallRoot); - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallMiddle); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallMiddle); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1394,8 +1391,8 @@ describe("Transactions", () => { //@id1474 it("Verify transaction for the Caller contract via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.addressMultiCallRoot); - txHash = await helper.readFile(bufferFile + Buffer.txMultiCallCaller); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallCaller); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1451,7 +1448,7 @@ describe("Transactions", () => { //@id1475 it("Verify transaction for the use multicall contract via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txUseMultiCallContracts); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txUseMultiCallContracts); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1509,8 +1506,8 @@ describe("Transactions", () => { //@id1507 it("Verify the transaction via /transactions/{transactionHash}/logs", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.readFile(bufferFile + Buffer.greeterL2); - txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.greeterL2); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.executeGreeterTx); apiRoute = `/transactions/${txHash}/logs`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1625,7 +1622,7 @@ describe("Transactions", () => { //@id1697 it("Verify /api?module=transaction&action=getstatus response", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txEthTransfer); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthTransfer); apiRoute = `/api?module=transaction&action=getstatus&txhash=${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1639,7 +1636,7 @@ describe("Transactions", () => { //@id1698 it("Verify /api?module=transaction&action=gettxreceiptstatus response", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.readFile(bufferFile + Buffer.txEthTransfer); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthTransfer); apiRoute = `/api?module=transaction&action=gettxreceiptstatus&txhash=${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); diff --git a/packages/integration-tests/tests/hooks/global.ts b/packages/integration-tests/tests/hooks/global.ts index 5eaaf5e9c6..3c4541d0aa 100644 --- a/packages/integration-tests/tests/hooks/global.ts +++ b/packages/integration-tests/tests/hooks/global.ts @@ -1,16 +1,14 @@ -import { Buffer } from "../../src/constants"; +import { Buffer, Path } from "../../src/constants"; import { Helper } from "../../src/helper"; import { Playbook } from "../../src/playbook/playbook"; export default async () => { const playbook = new Playbook(); const helper = new Helper(); - const bufferRoute = "src/playbook/"; await playbook.deployERC20toL2(); await playbook.deployERC20toL1(); await playbook.depositETH("0.0000001"); - const bufferFile = bufferRoute + Buffer.L1; - const token = await helper.readFile(bufferFile); + const token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L1); await playbook.depositERC20("100", token, 18); }; diff --git a/packages/integration-tests/tests/ui/deposit.spec.ts b/packages/integration-tests/tests/ui/deposit.spec.ts index 1caa6bd4e6..c2a3faf847 100644 --- a/packages/integration-tests/tests/ui/deposit.spec.ts +++ b/packages/integration-tests/tests/ui/deposit.spec.ts @@ -1,23 +1,20 @@ import { expect, test } from "@playwright/test"; import { config } from "./config"; -import { BlockExplorer, Buffer, Wallets } from "../../src/constants"; +import { BlockExplorer, Buffer, Path, Wallets } from "../../src/constants"; 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.readFile(bufferFile); + depositTxHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txEthDeposit); url = BlockExplorer.baseUrl + `/tx/${depositTxHash}` + BlockExplorer.localNetwork; initiatorAddress = Wallets.richWalletAddress; @@ -34,8 +31,7 @@ test("Check Deposit ETH transaction on BE", async ({ page }) => { //@id1681 test("Check on BE Deposit the custom ERC-20 token", async ({ page }) => { - bufferFile = bufferRoute + Buffer.txERC20Deposit; - depositTxHash = await helper.readFile(bufferFile); + depositTxHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txERC20Deposit); url = BlockExplorer.baseUrl + `/tx/${depositTxHash}` + BlockExplorer.localNetwork; initiatorAddress = Wallets.richWalletAddress; diff --git a/packages/integration-tests/tests/ui/multiCall.spec.ts b/packages/integration-tests/tests/ui/multiCall.spec.ts index b72bc8e09d..e97a9c871f 100644 --- a/packages/integration-tests/tests/ui/multiCall.spec.ts +++ b/packages/integration-tests/tests/ui/multiCall.spec.ts @@ -1,23 +1,20 @@ import { expect, test } from "@playwright/test"; import { config } from "./config"; -import { BlockExplorer, Buffer } from "../../src/constants"; +import { BlockExplorer, Buffer, Path } from "../../src/constants"; 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 contract: string; let element: Locator; let selector: string; //@id1684 test("Check Multicall - Caller contract address", async ({ page }) => { - bufferFile = bufferRoute + Buffer.addressMultiCallCaller; - contract = await helper.readFile(bufferFile); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallCaller); url = BlockExplorer.baseUrl + BlockExplorer.localNetwork; const targetUrl = BlockExplorer.baseUrl + `/address/${contract}`; @@ -32,8 +29,7 @@ test("Check Multicall - Caller contract address", async ({ page }) => { //@id1690 test("Check Multicall - Middle contract address", async ({ page }) => { - bufferFile = bufferRoute + Buffer.addressMultiCallMiddle; - contract = await helper.readFile(bufferFile); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallCaller); url = BlockExplorer.baseUrl + BlockExplorer.localNetwork; const targetUrl = BlockExplorer.baseUrl + `/address/${contract}`; @@ -48,8 +44,7 @@ test("Check Multicall - Middle contract address", async ({ page }) => { //@id1691 test("Check Multicall - Root contract address", async ({ page }) => { - bufferFile = bufferRoute + Buffer.addressMultiCallRoot; - contract = await helper.readFile(bufferFile); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot); url = BlockExplorer.baseUrl + BlockExplorer.localNetwork; const targetUrl = BlockExplorer.baseUrl + `/address/${contract}`; diff --git a/packages/integration-tests/tests/ui/nft.spec.ts b/packages/integration-tests/tests/ui/nft.spec.ts index 2fc6a2a365..7ca4ee2763 100644 --- a/packages/integration-tests/tests/ui/nft.spec.ts +++ b/packages/integration-tests/tests/ui/nft.spec.ts @@ -1,22 +1,19 @@ import { expect, test } from "@playwright/test"; import { config } from "./config"; -import { BlockExplorer, Buffer } from "../../src/constants"; +import { BlockExplorer, Buffer, Path } from "../../src/constants"; 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 contract: string; let element: Locator; //@id1658 test("Check the L2 NFT contract address", async ({ page }) => { - bufferFile = bufferRoute + Buffer.NFTtoL2; - contract = await helper.readFile(bufferFile); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL2); url = BlockExplorer.baseUrl + BlockExplorer.localNetwork; const targetUrl = BlockExplorer.baseUrl + `/address/${contract}`; @@ -30,8 +27,7 @@ test("Check the L2 NFT contract address", async ({ page }) => { //@id1657 test("Check the L1 NFT contract address", async ({ page }) => { - bufferFile = bufferRoute + Buffer.NFTtoL1; - contract = await helper.readFile(bufferFile); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL1); url = BlockExplorer.baseUrl + BlockExplorer.localNetwork; const targetUrl = BlockExplorer.baseUrl + `/address/${contract}`; diff --git a/packages/integration-tests/tests/ui/transactions.spec.ts b/packages/integration-tests/tests/ui/transactions.spec.ts index 8da7301f97..6369fd3b82 100644 --- a/packages/integration-tests/tests/ui/transactions.spec.ts +++ b/packages/integration-tests/tests/ui/transactions.spec.ts @@ -1,15 +1,13 @@ import { expect, test } from "@playwright/test"; import { config } from "./config"; -import { BlockExplorer, Buffer } from "../../src/constants"; +import { BlockExplorer, Buffer, Path } from "../../src/constants"; 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 failedTxHash: string; let contract: string; let element: Locator; @@ -17,8 +15,7 @@ let selector: string; //@id1656 test("Verify failed tx", async ({ page }) => { - bufferFile = bufferRoute + Buffer.failedState; - failedTxHash = await helper.readFile(bufferFile); + failedTxHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.failedState); url = BlockExplorer.baseUrl + `/tx/${failedTxHash}` + BlockExplorer.localNetwork; await page.goto(url); @@ -31,8 +28,7 @@ test("Verify failed tx", async ({ page }) => { //@id1655 test("Verify deployed the own ERC20 token contract", async ({ page }) => { - bufferFile = bufferRoute + Buffer.L2; - contract = await helper.readFile(bufferFile); + contract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2); url = BlockExplorer.baseUrl + `/address/${contract}` + BlockExplorer.localNetwork; await page.goto(url);