diff --git a/packages/integration-tests/src/constants.ts b/packages/integration-tests/src/constants.ts index 33a89704a7..1ad300052c 100644 --- a/packages/integration-tests/src/constants.ts +++ b/packages/integration-tests/src/constants.ts @@ -1,39 +1,46 @@ +import * as path from "path"; + export enum Buffer { - greeterL2 = "./buffer/greeterL2.txt", - executeGreeterTx = "./buffer/executeGreeterTx.txt", - NFTtoL1 = "./buffer/NFTtoL1.txt", - NFTtoL2 = "./buffer/NFTtoL2.txt", - L1 = "./buffer/L1.txt", - L2 = "./buffer/L2.txt", - L2deposited = "./buffer/L2deposited.txt", - paymaster = "./buffer/paymaster.txt", - paymasterDeployTx = "./buffer/paymasterDeployTx.txt", - paymasterTx = "./buffer/paymasterTx.txt", - addressMultiTransferETH = "./buffer/multiTransferETH.txt", - txMultiTransferETH = "./buffer/txMultiTransferETH.txt", - txMultiTransferCustomTokenI = "./buffer/txMultiTransferCustomTokenI.txt", - txMultiTransferCustomTokenII = "./buffer/txMultiTransferCustomTokenII.txt", - addressMultiCallMiddle = "./buffer/multiCallMiddle.txt", - addressMultiCallCaller = "./buffer/multiCallCaller.txt", - addressMultiCallRoot = "./buffer/multiCallRoot.txt", - txMultiCallMiddle = "./buffer/txMultiCallMiddle.txt", - txMultiCallCaller = "./buffer/txMultiCallCaller.txt", - txMultiCallRoot = "./buffer/txmultiCallRoot.txt", - txUseMultiCallContracts = "./buffer/txUseMultiCallContracts.txt", - txEthTransfer = "./buffer/txEthTransfer.txt", - txERC20Withdraw = "./buffer/txERC20Withdraw.txt", - txERC20WithdrawOtherAddress = "./buffer/txERC20WithdrawOtherAddress.txt", - txEthWithdraw = "./buffer/txEthWithdraw.txt", - txEthWithdrawOtherAddress = "./buffer/txEthWithdrawOtherAddress.txt", - txERC20Transfer = "./buffer/txERC20Transfer.txt", - emptyWalletPrivateKey = "./buffer/emptyWalletPrivateKey.txt", - emptyWalletAddress = "./buffer/emptyWalletAddress.txt", - failedState = "./buffer/failedState.txt", - customToken = "./buffer/customToken.txt", - txEthDeposit = "./buffer/txEthDeposit.txt", - txERC20Deposit = "./buffer/txERC20Deposit.txt", + greeterL2 = "greeterL2.txt", + executeGreeterTx = "executeGreeterTx.txt", + NFTtoL1 = "NFTtoL1.txt", + NFTtoL2 = "NFTtoL2.txt", + L1 = "L1.txt", + L2 = "L2.txt", + L2deposited = "L2deposited.txt", + paymaster = "paymaster.txt", + paymasterDeployTx = "paymasterDeployTx.txt", + paymasterTx = "paymasterTx.txt", + addressMultiTransferETH = "multiTransferETH.txt", + txMultiTransferETH = "txMultiTransferETH.txt", + txMultiTransferCustomTokenI = "txMultiTransferCustomTokenI.txt", + txMultiTransferCustomTokenII = "txMultiTransferCustomTokenII.txt", + addressMultiCallMiddle = "multiCallMiddle.txt", + addressMultiCallCaller = "multiCallCaller.txt", + addressMultiCallRoot = "multiCallRoot.txt", + txMultiCallMiddle = "txMultiCallMiddle.txt", + txMultiCallCaller = "txMultiCallCaller.txt", + txMultiCallRoot = "txmultiCallRoot.txt", + txUseMultiCallContracts = "txUseMultiCallContracts.txt", + txEthTransfer = "txEthTransfer.txt", + txERC20Withdraw = "txERC20Withdraw.txt", + txERC20WithdrawOtherAddress = "txERC20WithdrawOtherAddress.txt", + txEthWithdraw = "txEthWithdraw.txt", + txEthWithdrawOtherAddress = "txEthWithdrawOtherAddress.txt", + txERC20Transfer = "txERC20Transfer.txt", + emptyWalletPrivateKey = "emptyWalletPrivateKey.txt", + emptyWalletAddress = "emptyWalletAddress.txt", + failedState = "failedState.txt", + customToken = "customToken.txt", + txEthDeposit = "txEthDeposit.txt", + txERC20Deposit = "txERC20Deposit.txt", } +export const Path = { + playbookRoot: path.join("src", "playbook"), + absolutePathToBufferFiles: path.join(__dirname, "..", "src", "playbook", "buffer"), +}; + export enum Logger { deposit = "DEPOSIT", withdraw = "WITHDRAW", diff --git a/packages/integration-tests/src/helper.ts b/packages/integration-tests/src/helper.ts index d18ad051ff..8b26397289 100644 --- a/packages/integration-tests/src/helper.ts +++ b/packages/integration-tests/src/helper.ts @@ -33,24 +33,15 @@ export class Helper { } }); }); - - // const output = execSync(script, { encoding: "utf-8" }); - - // try { - // console.log(`> Run NPM Script "${script}":\n`, output); - // return output; - // } catch (e) { - // console.log(e); - // } } - async getStringFromFile(fileName: string) { - const absoluteRoute = path.join(__dirname, "..", fileName); + async readFile(filePath: string, fileName: string) { + const absoluteRoute = path.join(filePath + fileName); try { return await fs.readFile(absoluteRoute, { encoding: "utf-8" }); } catch { - console.log(`There is no the expected file: ${fileName}`); + console.log(`There is no the expected file: ${fileName} in ${filePath}`); } } diff --git a/packages/integration-tests/src/playbook/deploy/multicallCaller.ts b/packages/integration-tests/src/playbook/deploy/multicallCaller.ts index d88d228e6d..537e7abb37 100644 --- a/packages/integration-tests/src/playbook/deploy/multicallCaller.ts +++ b/packages/integration-tests/src/playbook/deploy/multicallCaller.ts @@ -1,7 +1,7 @@ import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; import { promises as fs } from "fs"; -import { Buffer } from "../../constants"; +import { Buffer, Path } from "../../constants"; import { Helper } from "../../helper"; import getWallet from "../utils/getWallet"; @@ -10,7 +10,6 @@ import type { HardhatRuntimeEnvironment } from "hardhat/types"; export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the contract`); const helper = new Helper(); - const playbookRoot = "src/playbook/"; const wallet = await getWallet(hre); // Create deployer object and load the artifact of the contract we want to deploy. @@ -18,7 +17,7 @@ export default async function (hre: HardhatRuntimeEnvironment) { const artifact = await deployer.loadArtifact("GCaller"); // Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. - const addressContractMiddle = await helper.getStringFromFile(playbookRoot + Buffer.addressMultiCallMiddle); + const addressContractMiddle = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallMiddle); const contractConstructorArguments = [addressContractMiddle]; console.log(`Arguments for the contract constructor: ${JSON.stringify(contractConstructorArguments)}`); const deployedContract = await deployer.deploy(artifact, contractConstructorArguments); diff --git a/packages/integration-tests/src/playbook/deploy/multicallMiddle.ts b/packages/integration-tests/src/playbook/deploy/multicallMiddle.ts index 7eb8e9ad99..c694f3407a 100644 --- a/packages/integration-tests/src/playbook/deploy/multicallMiddle.ts +++ b/packages/integration-tests/src/playbook/deploy/multicallMiddle.ts @@ -1,7 +1,7 @@ import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; import { promises as fs } from "fs"; -import { Buffer } from "../../constants"; +import { Buffer, Path } from "../../constants"; import { Helper } from "../../helper"; import getWallet from "../utils/getWallet"; @@ -11,7 +11,6 @@ export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the contract`); const helper = new Helper(); - const playbookRoot = "src/playbook/"; const wallet = await getWallet(hre); // Create deployer object and load the artifact of the contract we want to deploy. @@ -19,7 +18,7 @@ export default async function (hre: HardhatRuntimeEnvironment) { const artifact = await deployer.loadArtifact("Middle"); // Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. - const addressContractRoot = await helper.getStringFromFile(playbookRoot + Buffer.addressMultiCallRoot); + const addressContractRoot = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot); const contractConstructorArguments = [addressContractRoot]; console.log(`Arguments for the contract constructor: ${JSON.stringify(contractConstructorArguments)}`); const deployedContract = await deployer.deploy(artifact, contractConstructorArguments); diff --git a/packages/integration-tests/src/playbook/deploy/use-greeter.ts b/packages/integration-tests/src/playbook/deploy/use-greeter.ts index 3b07fcbe85..38a91fb9f7 100644 --- a/packages/integration-tests/src/playbook/deploy/use-greeter.ts +++ b/packages/integration-tests/src/playbook/deploy/use-greeter.ts @@ -14,7 +14,7 @@ export default async function (hre: HardhatRuntimeEnvironment) { const helper = new Helper(); let contract: any; // eslint-disable-line - const greeterContractAddress = await helper.getStringFromFile(bufferRoute + Buffer.greeterL2); + const greeterContractAddress = await helper.readFile(bufferRoute + 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-multiCall.ts b/packages/integration-tests/src/playbook/deploy/use-multiCall.ts index 9df21e5fb6..cf72140aae 100644 --- a/packages/integration-tests/src/playbook/deploy/use-multiCall.ts +++ b/packages/integration-tests/src/playbook/deploy/use-multiCall.ts @@ -3,7 +3,7 @@ import { promises as fs } from "fs"; import { Provider } from "zksync-web3"; import { localConfig } from "../../config"; -import { Buffer } from "../../constants"; +import { Buffer, Path } from "../../constants"; import { Helper } from "../../helper"; import getWallet from "../utils/getWallet"; @@ -11,8 +11,10 @@ import type { HardhatRuntimeEnvironment } from "hardhat/types"; export default async function (hre: HardhatRuntimeEnvironment) { const helper = new Helper(); - const playbookRoot = "src/playbook/"; - const TRANSFER_CONTRACT_ADDRESS = await helper.getStringFromFile(playbookRoot + Buffer.addressMultiCallCaller); + const TRANSFER_CONTRACT_ADDRESS = await helper.readFile( + Path.absolutePathToBufferFiles, + Buffer.addressMultiCallCaller + ); const CONTRACT_NAME = "GCaller"; console.log(`Running deploy script for the contract`); diff --git a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts index 752426a319..0cf2f076fd 100644 --- a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts +++ b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts @@ -3,19 +3,15 @@ import { promises as fs } from "fs"; import { Provider, Wallet } from "zksync-web3"; import { localConfig } from "../../config"; -import { Buffer, Token, Wallets } from "../../constants"; +import { Buffer, Path, Token, Wallets } from "../../constants"; import { Helper } from "../../helper"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironment) { const helper = new Helper(); - const playbookRoot = "src/playbook/"; - const firstToken = playbookRoot + Buffer.L2; - const secondToken = playbookRoot + Buffer.L2deposited; - const buffer = playbookRoot + Buffer.addressMultiTransferETH; const contractName = "TokenF2L2"; // insert the name of the contract you want to deploy - const contractAddress = await helper.getStringFromFile(buffer); + const contractAddress = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH); //wallets, To const richWalletAddress = Wallets.richWalletAddress; @@ -23,8 +19,8 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen const secondaryWalletAddress = Wallets.secondaryWalletAddress; // type of coin, contract const etherAddress = Token.addressETH; //ETH - const customTokenI = await helper.getStringFromFile(firstToken); - const customTokenII = await helper.getStringFromFile(secondToken); + const customTokenI = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2); + const customTokenII = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited); // amount of funds const ethAmount = ethers.utils.parseEther("0.0001"); const customTokenIAmount = ethers.utils.parseUnits("0.01", 18); diff --git a/packages/integration-tests/src/playbook/deploy/use-paymaster.ts b/packages/integration-tests/src/playbook/deploy/use-paymaster.ts index 64a760f322..0315bcb78b 100644 --- a/packages/integration-tests/src/playbook/deploy/use-paymaster.ts +++ b/packages/integration-tests/src/playbook/deploy/use-paymaster.ts @@ -12,9 +12,9 @@ const helper = new Helper(); export default async function (hre: HardhatRuntimeEnvironment) { const bufferRoute = "src/playbook/"; - const PAYMASTER_ADDRESS = await helper.getStringFromFile(bufferRoute + Buffer.paymaster); - const TOKEN_ADDRESS = await helper.getStringFromFile(bufferRoute + Buffer.customToken); - const EMPTY_WALLET_PRIVATE_KEY = await helper.getStringFromFile(bufferRoute + Buffer.emptyWalletPrivateKey); + 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 provider = new Provider(localConfig.L2Network); const emptyWallet = new Wallet(EMPTY_WALLET_PRIVATE_KEY, provider); diff --git a/packages/integration-tests/src/playbook/scenarios/deploy/deployERC20toL1.ts b/packages/integration-tests/src/playbook/scenarios/deploy/deployERC20toL1.ts index bea9cab022..e93e06f5a6 100644 --- a/packages/integration-tests/src/playbook/scenarios/deploy/deployERC20toL1.ts +++ b/packages/integration-tests/src/playbook/scenarios/deploy/deployERC20toL1.ts @@ -1,15 +1,13 @@ -import { Buffer, Logger } from "../../../constants"; +import { Buffer, Logger, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const deployERC20toL1 = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook"; - const bufferFile = playbookRoot + "/" + Buffer.L1; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deployToL1`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deployToL1`); - const deployedToken = await helper.getStringFromFile(bufferFile); + const deployedToken = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L1); console.log("The custom ERC20 token has been deployed to L1: ", Logger.textSeparator, deployedToken); return deployedToken; diff --git a/packages/integration-tests/src/playbook/scenarios/deploy/deployERC20toL2.ts b/packages/integration-tests/src/playbook/scenarios/deploy/deployERC20toL2.ts index d893ce7e2a..1a6a837493 100644 --- a/packages/integration-tests/src/playbook/scenarios/deploy/deployERC20toL2.ts +++ b/packages/integration-tests/src/playbook/scenarios/deploy/deployERC20toL2.ts @@ -1,15 +1,13 @@ -import { Buffer, Logger } from "../../../constants"; +import { Buffer, Logger, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const deployERC20toL2 = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook"; - const bufferFile = playbookRoot + "/" + Buffer.L2; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deployToL2`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deployToL2`); - const deployedToken = await helper.getStringFromFile(bufferFile); + const deployedToken = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2); console.log("The custom ERC20 token has been deployed to L2: ", Logger.textSeparator, deployedToken); return deployedToken; diff --git a/packages/integration-tests/src/playbook/scenarios/deploy/deployGreeterToL2.ts b/packages/integration-tests/src/playbook/scenarios/deploy/deployGreeterToL2.ts index 85ee571822..071cc1c88a 100644 --- a/packages/integration-tests/src/playbook/scenarios/deploy/deployGreeterToL2.ts +++ b/packages/integration-tests/src/playbook/scenarios/deploy/deployGreeterToL2.ts @@ -1,17 +1,15 @@ -import { Buffer, Logger } from "../../../constants"; +import { Buffer, Logger, Path } from "../../../constants"; import { Helper } from "../../../helper"; let deployedContract: string; export const deployGreeterToL2 = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook"; - const bufferFile = playbookRoot + "/" + Buffer.greeterL2; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:greeter`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:greeter`); - deployedContract = await helper.getStringFromFile(bufferFile); + deployedContract = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.greeterL2); console.log("The Greeter contract has been deployed to L2: ", Logger.textSeparator, deployedContract); return deployedContract; diff --git a/packages/integration-tests/src/playbook/scenarios/deploy/deployMulticallContracts.ts b/packages/integration-tests/src/playbook/scenarios/deploy/deployMulticallContracts.ts index 5414e0a948..9f3b7ca499 100644 --- a/packages/integration-tests/src/playbook/scenarios/deploy/deployMulticallContracts.ts +++ b/packages/integration-tests/src/playbook/scenarios/deploy/deployMulticallContracts.ts @@ -1,21 +1,17 @@ -import { Buffer } from "../../../constants"; +import { Buffer, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const deployMulticallContracts = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook"; - const bufferFileRoot = playbookRoot + "/" + Buffer.addressMultiCallRoot; - const bufferFileMiddle = playbookRoot + "/" + Buffer.addressMultiCallMiddle; - const bufferFileCaller = playbookRoot + "/" + Buffer.addressMultiCallCaller; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:multicall:root`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:multicall:middle`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:multicall:caller`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:multicall:root`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:multicall:middle`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:multicall:caller`); - const multiCallRoot = await helper.getStringFromFile(bufferFileRoot); - const multiCallMiddle = await helper.getStringFromFile(bufferFileMiddle); - const multiCallCaller = await helper.getStringFromFile(bufferFileCaller); + const multiCallRoot = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot); + const multiCallMiddle = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallMiddle); + const multiCallCaller = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallCaller); console.log( "Multicall contracts (Root, Middle and Caller) have been deployed to the address: ", diff --git a/packages/integration-tests/src/playbook/scenarios/deploy/deployMultitransferETH.ts b/packages/integration-tests/src/playbook/scenarios/deploy/deployMultitransferETH.ts index 2a5112cd6b..63c8145a42 100644 --- a/packages/integration-tests/src/playbook/scenarios/deploy/deployMultitransferETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/deploy/deployMultitransferETH.ts @@ -1,15 +1,16 @@ -import { Buffer } from "../../../constants"; +import { Buffer, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const deployMultitransferETH = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook"; - const bufferFile = playbookRoot + "/" + Buffer.addressMultiTransferETH; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:multitransfer`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:multitransfer`); - const multiTransferContractETH = await helper.getStringFromFile(bufferFile); + const multiTransferContractETH = await helper.readFile( + Path.absolutePathToBufferFiles, + Buffer.addressMultiTransferETH + ); console.log("The custom multitransfer contract ETH has been deployed to the address: ", multiTransferContractETH); diff --git a/packages/integration-tests/src/playbook/scenarios/deploy/deployNFTtoL1.ts b/packages/integration-tests/src/playbook/scenarios/deploy/deployNFTtoL1.ts index 25ab4f3756..cefbe8752e 100644 --- a/packages/integration-tests/src/playbook/scenarios/deploy/deployNFTtoL1.ts +++ b/packages/integration-tests/src/playbook/scenarios/deploy/deployNFTtoL1.ts @@ -1,15 +1,13 @@ -import { Buffer, Logger } from "../../../constants"; +import { Buffer, Logger, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const deployNFTtoL1 = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook"; - const bufferFile = playbookRoot + "/" + Buffer.NFTtoL1; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deployNFTtoL1`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deployNFTtoL1`); - const deployedNFT = await helper.getStringFromFile(bufferFile); + const deployedNFT = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL1); console.log("The NFT has been deployed to L1: ", Logger.textSeparator, deployedNFT); return deployedNFT; diff --git a/packages/integration-tests/src/playbook/scenarios/deploy/deployNFTtoL2.ts b/packages/integration-tests/src/playbook/scenarios/deploy/deployNFTtoL2.ts index 856e2f48df..b3c8419c91 100644 --- a/packages/integration-tests/src/playbook/scenarios/deploy/deployNFTtoL2.ts +++ b/packages/integration-tests/src/playbook/scenarios/deploy/deployNFTtoL2.ts @@ -1,15 +1,13 @@ -import { Buffer, Logger } from "../../../constants"; +import { Buffer, Logger, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const deployNFTtoL2 = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook"; - const bufferFile = playbookRoot + "/" + Buffer.NFTtoL2; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deployNFTtoL2`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deployNFTtoL2`); - const deployedNFT = await helper.getStringFromFile(bufferFile); + const deployedNFT = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL2); console.log("The NFT has been deployed to L2: ", Logger.textSeparator, deployedNFT); return deployedNFT; diff --git a/packages/integration-tests/src/playbook/scenarios/deploy/deployViaPaymaster.ts b/packages/integration-tests/src/playbook/scenarios/deploy/deployViaPaymaster.ts index 71a1807344..e8587a12c3 100644 --- a/packages/integration-tests/src/playbook/scenarios/deploy/deployViaPaymaster.ts +++ b/packages/integration-tests/src/playbook/scenarios/deploy/deployViaPaymaster.ts @@ -1,17 +1,14 @@ -import { Buffer } from "../../../constants"; +import { Buffer, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const deployViaPaymaster = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook/"; - const bufferPaymaster = playbookRoot + Buffer.paymaster; - const bufferCustomToken = playbookRoot + Buffer.paymaster; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:paymaster`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:paymaster`); - const paymasterAddress = await helper.getStringFromFile(bufferPaymaster); - const deployedToken = await helper.getStringFromFile(bufferCustomToken); + const paymasterAddress = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymaster); + const deployedToken = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.customToken); console.log("The custom token has been deployed via Paymaster: ", deployedToken); console.log("The Paymaster transaction: ", paymasterAddress); diff --git a/packages/integration-tests/src/playbook/scenarios/deposit/depositERC20.ts b/packages/integration-tests/src/playbook/scenarios/deposit/depositERC20.ts index 98d1f1701d..e62a1fe700 100644 --- a/packages/integration-tests/src/playbook/scenarios/deposit/depositERC20.ts +++ b/packages/integration-tests/src/playbook/scenarios/deposit/depositERC20.ts @@ -1,18 +1,18 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger, Wallets } from "../../../constants"; +import { Buffer, Logger, Path, Wallets } from "../../../constants"; import { Helper } from "../../../helper"; 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 bufferAddressL2DepositedFile = playbookRoot + "/" + Buffer.L2deposited; -const bufferTxErc20DepositFile = playbookRoot + "/" + Buffer.txERC20Deposit; +const bufferAddressL2DepositedFile = path.join(Path.absolutePathToBufferFiles, Buffer.L2deposited); +const bufferTxErc20DepositFile = path.join(Path.absolutePathToBufferFiles, Buffer.txERC20Deposit); export const depositERC20 = async function (sum = "0.5", tokenAddress: string, units = 18) { const deposit = await syncWallet.deposit({ diff --git a/packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts b/packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts index 98d99f8aa1..294ec402f8 100644 --- a/packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts @@ -1,9 +1,10 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger } from "../../../constants"; +import { Buffer, Logger, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const depositEth = async function (sum = "0.000009") { @@ -11,8 +12,7 @@ export const depositEth = async function (sum = "0.000009") { 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 bufferFile = path.join(Path.playbookRoot, Buffer.txEthDeposit); const deposit = await syncWallet.deposit({ token: zksync.utils.ETH_ADDRESS, diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts index 3ab4e41e36..7a6053a5df 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts @@ -1,9 +1,10 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger, Wallets } from "../../../constants"; +import { Buffer, Logger, Path, Wallets } from "../../../constants"; import { Helper } from "../../../helper"; export const transferERC20 = async function (sum: string, tokenAddress: string, tokenName?: string /*, units = 18*/) { @@ -12,8 +13,7 @@ export const transferERC20 = async function (sum: string, tokenAddress: string, const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const syncWallet2 = new zksync.Wallet(Wallets.secondaryWalletPrivateKey, syncProvider, ethProvider); - const playbookRoot = "src/playbook/"; - const bufferFile = playbookRoot + Buffer.txEthTransfer; + const bufferFile = path.join(Path.playbookRoot, Buffer.txEthTransfer); const transfer = await syncWallet.transfer({ to: syncWallet2.address, diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts index e616a84c44..da98e9b0b1 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts @@ -1,9 +1,10 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger, Wallets } from "../../../constants"; +import { Buffer, Logger, Path, Wallets } from "../../../constants"; import { Helper } from "../../../helper"; export const transferEth = async function (sum = "0.000009", address: string = Wallets.mainWalletPrivateKey) { @@ -12,8 +13,7 @@ export const transferEth = async function (sum = "0.000009", address: string = W const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const syncWallet2 = new zksync.Wallet(address, syncProvider, ethProvider); - const playbookRoot = "src/playbook/"; - const bufferFile = playbookRoot + Buffer.txEthTransfer; + const bufferFile = path.join(Path.playbookRoot + Buffer.txEthTransfer); const transfer = await syncWallet.transfer({ to: syncWallet2.address, diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts index 6a90a2241e..e085fbe8a6 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts @@ -1,9 +1,10 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger } from "../../../constants"; +import { Buffer, Logger, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const transferFailedState = async function (tokenAddress: string, tokenName?: string) { @@ -12,8 +13,7 @@ export const transferFailedState = async function (tokenAddress: string, tokenNa const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const amount = ethers.utils.parseEther("1.0"); - const playbookRoot = "src/playbook/"; - const bufferFile = playbookRoot + Buffer.failedState; + const bufferFile = path.join(Path.playbookRoot + Buffer.failedState); const transfer = await syncWallet.transfer({ to: "0x0000000000000000000000000000000000000000", diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/useGreeter.ts b/packages/integration-tests/src/playbook/scenarios/transfers/useGreeter.ts index 03f05fb217..e58757066f 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/useGreeter.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/useGreeter.ts @@ -1,15 +1,13 @@ -import { Buffer } from "../../../constants"; +import { Buffer, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const useGreeter = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook/"; - const txBuffer = playbookRoot + Buffer.executeGreeterTx; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:use:greeter`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:use:greeter`); - const txGreeting = await helper.getStringFromFile(txBuffer); + const txGreeting = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.executeGreeterTx); console.log("Execute the SetGreeting transaction: ", txGreeting); diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/useMultiCall.ts b/packages/integration-tests/src/playbook/scenarios/transfers/useMultiCall.ts index c17807d568..2a70065122 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/useMultiCall.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/useMultiCall.ts @@ -1,15 +1,13 @@ -import { Buffer } from "../../../constants"; +import { Buffer, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const useMultiCallContracts = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook/"; - const txBufferUseMultiCall = playbookRoot + Buffer.txUseMultiCallContracts; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:use:multicall`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:use:multicall`); - const txUseMultiCallContracts = await helper.getStringFromFile(txBufferUseMultiCall); + const txUseMultiCallContracts = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txUseMultiCallContracts); return txUseMultiCallContracts; }; diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/useMultitransferETH.ts b/packages/integration-tests/src/playbook/scenarios/transfers/useMultitransferETH.ts index 31b2917654..34143923fd 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/useMultitransferETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/useMultitransferETH.ts @@ -1,19 +1,21 @@ -import { Buffer } from "../../../constants"; +import { Buffer, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const useMultitransferETH = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook/"; - const txBufferETH = playbookRoot + Buffer.txMultiTransferETH; - const txBufferCustomTokenI = playbookRoot + Buffer.txMultiTransferCustomTokenI; - const txBufferCustomTokenII = playbookRoot + Buffer.txMultiTransferCustomTokenII; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:use:multitransfer`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:use:multitransfer`); - const txMultiTransferETH = await helper.getStringFromFile(txBufferETH); - const txMultiTransferCustomTokenI = await helper.getStringFromFile(txBufferCustomTokenI); - const txMultiTransferCustomTokenII = await helper.getStringFromFile(txBufferCustomTokenII); + const txMultiTransferETH = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH); + const txMultiTransferCustomTokenI = await helper.readFile( + Path.absolutePathToBufferFiles, + Buffer.txMultiTransferCustomTokenI + ); + const txMultiTransferCustomTokenII = await helper.readFile( + Path.absolutePathToBufferFiles, + Buffer.txMultiTransferCustomTokenII + ); console.log("The multi transfer transaction for ETH: ", txMultiTransferETH); console.log("The multi transfer transaction for the Custom token I: ", txMultiTransferCustomTokenI); diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/usePaymaster.ts b/packages/integration-tests/src/playbook/scenarios/transfers/usePaymaster.ts index cce46c4bc1..3cf2da7c6f 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/usePaymaster.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/usePaymaster.ts @@ -1,15 +1,13 @@ -import { Buffer } from "../../../constants"; +import { Buffer, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const usePaymaster = async function () { const helper = new Helper(); - const playbookRoot = "src/playbook/"; - const txBuffer = playbookRoot + Buffer.paymasterTx; - await helper.executeScript(`cd ${playbookRoot} && npm run compile`); - await helper.executeScript(`cd ${playbookRoot} && npm run deploy:use:paymaster`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run compile`); + await helper.executeScript(`cd ${Path.playbookRoot} && npm run deploy:use:paymaster`); - const txPaymaster = await helper.getStringFromFile(txBuffer); + const txPaymaster = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymasterTx); console.log("The Paymaster transaction: ", txPaymaster); diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts index 08be5788a9..cc7e38795b 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts @@ -1,9 +1,10 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger, Wallets } from "../../../constants"; +import { Buffer, Logger, Path, Wallets } from "../../../constants"; import { Helper } from "../../../helper"; export const withdrawERC20 = async function (tokenAddress: string, sum = "0.2") { @@ -12,8 +13,7 @@ export const withdrawERC20 = async function (tokenAddress: string, sum = "0.2") const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const bridges = await syncProvider.getDefaultBridgeAddresses(); - const playbookRoot = "src/playbook/"; - const bufferFile = playbookRoot + Buffer.txERC20Withdraw; + const bufferFile = path.join(Path.playbookRoot, Buffer.txERC20Withdraw); const balance = await syncWallet.getBalance(tokenAddress); diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts index 9d93e74dc1..f5bcf605b2 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts @@ -1,9 +1,10 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger, Wallets } from "../../../constants"; +import { Buffer, Logger, Path, Wallets } from "../../../constants"; import { Helper } from "../../../helper"; export const withdrawERC20toOtherAddress = async function (tokenAddress: string, sum = "0.2") { @@ -12,8 +13,7 @@ export const withdrawERC20toOtherAddress = async function (tokenAddress: string, const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const bridges = await syncProvider.getDefaultBridgeAddresses(); - const playbookRoot = "src/playbook/"; - const bufferFile = playbookRoot + Buffer.txERC20WithdrawOtherAddress; + const bufferFile = path.join(Path.playbookRoot, Buffer.txERC20WithdrawOtherAddress); const balance = await syncWallet.getBalance(tokenAddress); diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts index d2faa8ffab..d57f1806a8 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts @@ -1,9 +1,10 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger } from "../../../constants"; +import { Buffer, Logger, Path } from "../../../constants"; import { Helper } from "../../../helper"; export const withdrawETH = async function (sum = "0.000009") { @@ -11,8 +12,7 @@ export const withdrawETH = async function (sum = "0.000009") { 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.txEthWithdraw; + const bufferFile = path.join(Path.playbookRoot, Buffer.txEthWithdraw); const withdrawL2 = await syncWallet.withdraw({ token: zksync.utils.ETH_ADDRESS, diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts index 847ebafd87..7d62429711 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts @@ -1,9 +1,10 @@ import * as ethers from "ethers"; import { promises as fs } from "fs"; +import * as path from "path"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Buffer, Logger, Wallets } from "../../../constants"; +import { Buffer, Logger, Path, Wallets } from "../../../constants"; import { Helper } from "../../../helper"; export const withdrawETHtoOtherAddress = async function (sum = "0.000009") { @@ -11,8 +12,7 @@ export const withdrawETHtoOtherAddress = async function (sum = "0.000009") { 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.txEthWithdrawOtherAddress; + const bufferFile = path.join(Path.playbookRoot + Buffer.txEthWithdrawOtherAddress); const withdrawL2 = await syncWallet.withdraw({ token: zksync.utils.ETH_ADDRESS, diff --git a/packages/integration-tests/tests/api/accounts.test.ts b/packages/integration-tests/tests/api/accounts.test.ts index 6d6a3da7ad..e75aab0ae8 100644 --- a/packages/integration-tests/tests/api/accounts.test.ts +++ b/packages/integration-tests/tests/api/accounts.test.ts @@ -215,7 +215,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.getStringFromFile(bufferFile + Buffer.NFTtoL2); + const nftAddress = await helper.readFile(bufferFile + 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 6ebf5a9533..4fb9a73a94 100644 --- a/packages/integration-tests/tests/api/addresses.test.ts +++ b/packages/integration-tests/tests/api/addresses.test.ts @@ -29,7 +29,7 @@ describe("Address", () => { //@id1457 it("Verify deployed to L2 NFT via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - token = await helper.getStringFromFile(bufferFile + Buffer.NFTtoL2); + token = await helper.readFile(bufferFile + Buffer.NFTtoL2); apiRoute = `/address/${token}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -52,8 +52,8 @@ describe("Address", () => { //@id1464 it("Verify the deployed Root contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); + contract = await helper.readFile(bufferFile + Buffer.addressMultiCallRoot); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallRoot); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -69,8 +69,8 @@ describe("Address", () => { //@id1465 it("Verify the deployed Middle contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallMiddle); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + contract = await helper.readFile(bufferFile + Buffer.addressMultiCallMiddle); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallMiddle); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -86,8 +86,8 @@ describe("Address", () => { //@id1466 it("Verify the deployed Caller contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallCaller); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); + contract = await helper.readFile(bufferFile + Buffer.addressMultiCallCaller); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallCaller); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -103,7 +103,7 @@ describe("Address", () => { //@id1476 it("Verify the deployed multitransfer contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); + contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -116,7 +116,7 @@ describe("Address", () => { //@id1449 it("Verify the deployed Greeter contract via /address/{address}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); + contract = await helper.readFile(bufferFile + Buffer.greeterL2); apiRoute = `/address/${contract}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -135,8 +135,8 @@ describe("Address", () => { //@id1510 it("Verify the transaction via /address/{address}/logs", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); - txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); + contract = await helper.readFile(bufferFile + Buffer.greeterL2); + txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); apiRoute = `/address/${contract}/logs`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -176,10 +176,10 @@ describe("Address", () => { //@id1509 it("Verify the transaction via /address/{address}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.paymaster); - const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); - txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); - const customTokenAddress = await helper.getStringFromFile(bufferFile + Buffer.customToken); + 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); 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 09169f6db4..9c17f8c0ac 100644 --- a/packages/integration-tests/tests/api/contracts.test.ts +++ b/packages/integration-tests/tests/api/contracts.test.ts @@ -25,10 +25,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.getStringFromFile(bufferFile + Buffer.paymaster); - paymasterTx = await helper.getStringFromFile(bufferFile + Buffer.paymasterDeployTx); - multicallCallerContract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallCaller); - multicallCallerTx = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); + 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); 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 ff881c81ec..e7348f48e2 100644 --- a/packages/integration-tests/tests/api/logs.test.ts +++ b/packages/integration-tests/tests/api/logs.test.ts @@ -23,8 +23,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.getStringFromFile(bufferFile + Buffer.greeterL2); - txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); + contractAddress = await helper.readFile(bufferFile + Buffer.greeterL2); + txHash = await helper.readFile(bufferFile + 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/tokens.test.ts b/packages/integration-tests/tests/api/tokens.test.ts index cea4b6a50e..b7d4b33cfa 100644 --- a/packages/integration-tests/tests/api/tokens.test.ts +++ b/packages/integration-tests/tests/api/tokens.test.ts @@ -1,5 +1,5 @@ import { localConfig } from "../../src/config"; -import { Buffer, Token, TransactionsType, Wallets } from "../../src/constants"; +import { Buffer, Path, Token, TransactionsType, Wallets } from "../../src/constants"; import { Helper } from "../../src/helper"; import { Playbook } from "../../src/playbook/playbook"; @@ -8,22 +8,21 @@ describe("Tokens", () => { const helper = new Helper(); const playbook = new Playbook(); - const bufferFile = "src/playbook/"; let apiRoute: string; let l2Token: string; let txHash: string; let response; beforeAll(async () => { - l2Token = await helper.getStringFromFile(bufferFile + Buffer.L2); + l2Token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2); }); describe("/tokens", () => { //@id1508 it("Verify the response via /tokens", async () => { await helper.runRetriableTestAction(async () => { - const l2DepositedToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); - const l1Token = await helper.getStringFromFile(bufferFile + Buffer.L1); + const l2DepositedToken = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited); + const l1Token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L1); apiRoute = `/tokens`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -97,10 +96,10 @@ describe("Tokens", () => { //@id1451 it("Verify the custom token includes paymaster transaction via /tokens/{address}/transfers", async () => { await helper.runRetriableTestAction(async () => { - l2Token = await helper.getStringFromFile(bufferFile + Buffer.customToken); - const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); - const paymaster = await helper.getStringFromFile(bufferFile + Buffer.paymaster); - txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); + l2Token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.customToken); + const emptyWallet = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.emptyWalletAddress); + const paymaster = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymaster); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymasterTx); apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -116,10 +115,10 @@ describe("Tokens", () => { //id1803 it("Verify the response via /tokens/{address}/transfers", async () => { await helper.runRetriableTestAction(async () => { - l2Token = await helper.getStringFromFile(bufferFile + Buffer.customToken); - const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); - const paymaster = await helper.getStringFromFile(bufferFile + Buffer.paymaster); - txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); + l2Token = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.customToken); + const emptyWallet = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.emptyWalletAddress); + const paymaster = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymaster); + txHash = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.paymasterTx); const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; const decapitalizedTokenAddress = l2Token.toLowerCase(); 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 f5875cf311..eb39d4ab4f 100644 --- a/packages/integration-tests/tests/api/transactions.test.ts +++ b/packages/integration-tests/tests/api/transactions.test.ts @@ -16,7 +16,7 @@ describe("Transactions", () => { let response; beforeAll(async () => { - const customToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + const customToken = await helper.readFile(bufferFile + Buffer.L2deposited); await playbook.withdrawETHtoOtherAddress(); await playbook.withdrawERC20(customToken); await playbook.withdrawERC20toOtherAddress(customToken); @@ -37,7 +37,7 @@ describe("Transactions", () => { //@id1447 it("Verify transfer ETH L2-L2 via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthTransfer); + txHash = await helper.readFile(bufferFile + Buffer.txEthTransfer); apiRoute = `/transactions/${txHash}/transfers`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -78,7 +78,7 @@ describe("Transactions", () => { //@id1459 it("Verify the ETH withdrawal via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthWithdraw); + txHash = await helper.readFile(bufferFile + Buffer.txEthWithdraw); apiRoute = `/transactions/${txHash}/transfers`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -128,7 +128,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.getStringFromFile(bufferFile + Buffer.txEthWithdrawOtherAddress); + txHash = await helper.readFile(bufferFile + Buffer.txEthWithdrawOtherAddress); apiRoute = `/transactions/${txHash}/transfers`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -179,10 +179,10 @@ describe("Transactions", () => { it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { const l1Token = bufferFile + "/" + Buffer.L1; - const customTokenL1 = await helper.getStringFromFile(l1Token); + const customTokenL1 = await helper.readFile(l1Token); const l2Token = bufferFile + "/" + Buffer.L2deposited; - const customTokenL2 = await helper.getStringFromFile(l2Token); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txERC20WithdrawOtherAddress); + const customTokenL2 = await helper.readFile(l2Token); + txHash = await helper.readFile(bufferFile + Buffer.txERC20WithdrawOtherAddress); apiRoute = `/transactions/${txHash}/transfers`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -310,14 +310,14 @@ describe("Transactions", () => { describe("/transactions/{transactionHash}", () => { beforeAll(async () => { - const customToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + const customToken = await helper.readFile(bufferFile + 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.getStringFromFile(bufferFile + Buffer.txEthWithdrawOtherAddress); + txHash = await helper.readFile(bufferFile + Buffer.txEthWithdrawOtherAddress); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -363,7 +363,7 @@ describe("Transactions", () => { //@id1462 it("Verify the custom token withdrawal via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txERC20Withdraw); + txHash = await helper.readFile(bufferFile + Buffer.txERC20Withdraw); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -409,7 +409,7 @@ describe("Transactions", () => { //@id1458 it("Verify the ETH withdrawal via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthWithdraw); + txHash = await helper.readFile(bufferFile + Buffer.txEthWithdraw); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -455,8 +455,8 @@ describe("Transactions", () => { //@id1478 it("Verify transaction for the ETH via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); + txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferETH); + contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -502,8 +502,8 @@ describe("Transactions", () => { //@id1479 it("Verify transaction for the Custom Token I via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.L2); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCustomTokenI); + contract = await helper.readFile(bufferFile + Buffer.L2); + txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferCustomTokenI); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -549,8 +549,8 @@ describe("Transactions", () => { //@id1480 it("Verify transaction for the Custom Token II via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCustomTokenII); + contract = await helper.readFile(bufferFile + Buffer.L2deposited); + txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferCustomTokenII); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -596,8 +596,8 @@ describe("Transactions", () => { //@id1454 it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); - txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); + contract = await helper.readFile(bufferFile + Buffer.greeterL2); + txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); apiRoute = `/transactions/${txHash}?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -644,7 +644,7 @@ describe("Transactions", () => { //@id1464:I --> @id1468 it("Verify transaction for the Root contract via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallRoot); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -692,7 +692,7 @@ describe("Transactions", () => { //@id1465:I --> @id1469 it("Verify transaction for the Middle contract via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallMiddle); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -740,7 +740,7 @@ describe("Transactions", () => { //@id1466:I --> @id1470 it("Verify transaction for the Caller contract via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallCaller); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -788,7 +788,7 @@ describe("Transactions", () => { //@id1471 it("Verify transaction for the use multicall contract via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); + txHash = await helper.readFile(bufferFile + Buffer.txUseMultiCallContracts); apiRoute = `/transactions/${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -834,8 +834,8 @@ describe("Transactions", () => { //@id645 it("Verify the transactions with failed state via /transactions/{transactionHash}", async () => { await helper.runRetriableTestAction(async () => { - token = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); - txHash = await helper.getStringFromFile(bufferFile + Buffer.failedState); + token = await helper.readFile(bufferFile + Buffer.L2deposited); + txHash = await helper.readFile(bufferFile + Buffer.failedState); apiRoute = `/transactions/${txHash}?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -890,8 +890,8 @@ describe("Transactions", () => { //@id1481 it("Verify transaction for the ETH via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); + contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); + txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferETH); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -967,9 +967,9 @@ describe("Transactions", () => { //@id1482 it("Verify transaction for the Custom tokenI via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - token = await helper.getStringFromFile(bufferFile + Buffer.L2); - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCustomTokenI); + token = await helper.readFile(bufferFile + Buffer.L2); + contract = await helper.readFile(bufferFile + Buffer.addressMultiTransferETH); + txHash = await helper.readFile(bufferFile + Buffer.txMultiTransferCustomTokenI); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1045,10 +1045,10 @@ describe("Transactions", () => { //@id1483 it("Verify transaction for the Custom tokenII via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - const tokenL1 = await helper.getStringFromFile(bufferFile + Buffer.L1); - token = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCustomTokenII); + 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); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1124,10 +1124,10 @@ describe("Transactions", () => { //@id1452 it("Verify transaction through Paymaster via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); - const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); - token = await helper.getStringFromFile(bufferFile + Buffer.customToken); - txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); + 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); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1204,7 +1204,7 @@ describe("Transactions", () => { //@id1455 it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); + txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); apiRoute = `/transactions/${txHash}/transfers`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1280,8 +1280,8 @@ describe("Transactions", () => { //@id1472 it("Verify transaction for the Root contract via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); + contract = await helper.readFile(bufferFile + Buffer.addressMultiCallRoot); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallRoot); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1337,8 +1337,8 @@ describe("Transactions", () => { //@id1473 it("Verify transaction for the Middle contract via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + contract = await helper.readFile(bufferFile + Buffer.addressMultiCallRoot); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallMiddle); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1394,8 +1394,8 @@ describe("Transactions", () => { //@id1474 it("Verify transaction for the Caller contract via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); + contract = await helper.readFile(bufferFile + Buffer.addressMultiCallRoot); + txHash = await helper.readFile(bufferFile + Buffer.txMultiCallCaller); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1451,7 +1451,7 @@ describe("Transactions", () => { //@id1475 it("Verify transaction for the use multicall contract via /transactions/{transactionHash}/transfers", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); + txHash = await helper.readFile(bufferFile + Buffer.txUseMultiCallContracts); apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1509,8 +1509,8 @@ describe("Transactions", () => { //@id1507 it("Verify the transaction via /transactions/{transactionHash}/logs", async () => { await helper.runRetriableTestAction(async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); - txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); + contract = await helper.readFile(bufferFile + Buffer.greeterL2); + txHash = await helper.readFile(bufferFile + Buffer.executeGreeterTx); apiRoute = `/transactions/${txHash}/logs`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1625,7 +1625,7 @@ describe("Transactions", () => { //@id1697 it("Verify /api?module=transaction&action=getstatus response", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthTransfer); + txHash = await helper.readFile(bufferFile + Buffer.txEthTransfer); apiRoute = `/api?module=transaction&action=getstatus&txhash=${txHash}`; response = await helper.performBlockExplorerApiGetRequest(apiRoute); @@ -1639,7 +1639,7 @@ describe("Transactions", () => { //@id1698 it("Verify /api?module=transaction&action=gettxreceiptstatus response", async () => { await helper.runRetriableTestAction(async () => { - txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthTransfer); + txHash = await helper.readFile(bufferFile + 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 0ec0903f5c..5eaaf5e9c6 100644 --- a/packages/integration-tests/tests/hooks/global.ts +++ b/packages/integration-tests/tests/hooks/global.ts @@ -11,6 +11,6 @@ export default async () => { await playbook.deployERC20toL1(); await playbook.depositETH("0.0000001"); const bufferFile = bufferRoute + Buffer.L1; - const token = await helper.getStringFromFile(bufferFile); + const token = await helper.readFile(bufferFile); 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 57aac180cf..1caa6bd4e6 100644 --- a/packages/integration-tests/tests/ui/deposit.spec.ts +++ b/packages/integration-tests/tests/ui/deposit.spec.ts @@ -17,7 +17,7 @@ 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); + depositTxHash = await helper.readFile(bufferFile); url = BlockExplorer.baseUrl + `/tx/${depositTxHash}` + BlockExplorer.localNetwork; initiatorAddress = Wallets.richWalletAddress; @@ -35,7 +35,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.getStringFromFile(bufferFile); + depositTxHash = await helper.readFile(bufferFile); 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 bd7607943f..b72bc8e09d 100644 --- a/packages/integration-tests/tests/ui/multiCall.spec.ts +++ b/packages/integration-tests/tests/ui/multiCall.spec.ts @@ -17,7 +17,7 @@ let selector: string; //@id1684 test("Check Multicall - Caller contract address", async ({ page }) => { bufferFile = bufferRoute + Buffer.addressMultiCallCaller; - contract = await helper.getStringFromFile(bufferFile); + contract = await helper.readFile(bufferFile); url = BlockExplorer.baseUrl + BlockExplorer.localNetwork; const targetUrl = BlockExplorer.baseUrl + `/address/${contract}`; @@ -33,7 +33,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.getStringFromFile(bufferFile); + contract = await helper.readFile(bufferFile); url = BlockExplorer.baseUrl + BlockExplorer.localNetwork; const targetUrl = BlockExplorer.baseUrl + `/address/${contract}`; @@ -49,7 +49,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.getStringFromFile(bufferFile); + contract = await helper.readFile(bufferFile); 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 ea24620a62..2fc6a2a365 100644 --- a/packages/integration-tests/tests/ui/nft.spec.ts +++ b/packages/integration-tests/tests/ui/nft.spec.ts @@ -16,7 +16,7 @@ let element: Locator; //@id1658 test("Check the L2 NFT contract address", async ({ page }) => { bufferFile = bufferRoute + Buffer.NFTtoL2; - contract = await helper.getStringFromFile(bufferFile); + contract = await helper.readFile(bufferFile); url = BlockExplorer.baseUrl + BlockExplorer.localNetwork; const targetUrl = BlockExplorer.baseUrl + `/address/${contract}`; @@ -31,7 +31,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.getStringFromFile(bufferFile); + contract = await helper.readFile(bufferFile); 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 8ac394b2ff..8da7301f97 100644 --- a/packages/integration-tests/tests/ui/transactions.spec.ts +++ b/packages/integration-tests/tests/ui/transactions.spec.ts @@ -18,7 +18,7 @@ let selector: string; //@id1656 test("Verify failed tx", async ({ page }) => { bufferFile = bufferRoute + Buffer.failedState; - failedTxHash = await helper.getStringFromFile(bufferFile); + failedTxHash = await helper.readFile(bufferFile); url = BlockExplorer.baseUrl + `/tx/${failedTxHash}` + BlockExplorer.localNetwork; await page.goto(url); @@ -32,7 +32,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.getStringFromFile(bufferFile); + contract = await helper.readFile(bufferFile); url = BlockExplorer.baseUrl + `/address/${contract}` + BlockExplorer.localNetwork; await page.goto(url);