From a82496aaba35e7276afdb1c14b3e8431ab163aa8 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 7 Mar 2024 18:21:44 +0100 Subject: [PATCH] test: refactoring path and variables --- packages/integration-tests/src/helper.ts | 12 +++++++++++- .../src/playbook/deploy/deploy-greeter.ts | 6 ++++-- .../src/playbook/deploy/deploy-paymaster.ts | 15 ++++++++------- .../src/playbook/deploy/erc20toL1.ts | 7 ++++--- .../src/playbook/deploy/erc20toL2.ts | 7 ++++--- .../src/playbook/deploy/multiTransferETH.ts | 7 ++++--- .../src/playbook/deploy/multicallCaller.ts | 5 ++--- .../src/playbook/deploy/multicallMiddle.ts | 4 ++-- .../src/playbook/deploy/multicallRoot.ts | 9 +++++---- .../src/playbook/deploy/nftToL1.ts | 7 ++++--- .../src/playbook/deploy/nftToL2.ts | 7 ++++--- .../src/playbook/deploy/use-greeter.ts | 2 +- .../src/playbook/deploy/use-multiCall.ts | 2 +- .../src/playbook/deploy/use-multitransferETH.ts | 7 +++---- .../src/playbook/deploy/use-paymaster.ts | 3 +-- .../playbook/scenarios/deposit/depositERC20.ts | 8 ++------ .../src/playbook/scenarios/deposit/depositETH.ts | 5 +---- .../playbook/scenarios/transfers/transferERC20.ts | 5 +---- .../playbook/scenarios/transfers/transferETH.ts | 3 +-- .../scenarios/transfers/transferFailedState.ts | 5 +---- .../scenarios/withdrawal/withdrawERC20.ts | 5 +---- .../withdrawal/withdrawERC20toOtherAddress.ts | 3 +-- .../playbook/scenarios/withdrawal/withdrawETH.ts | 5 +---- .../withdrawal/withdrawETHtoOtherAddress.ts | 5 +---- 24 files changed, 68 insertions(+), 76 deletions(-) diff --git a/packages/integration-tests/src/helper.ts b/packages/integration-tests/src/helper.ts index 8b26397289..9b599171ae 100644 --- a/packages/integration-tests/src/helper.ts +++ b/packages/integration-tests/src/helper.ts @@ -26,6 +26,7 @@ export class Helper { exec(script, { encoding: "utf-8" }, (error, stdout, stderr) => { if (error) { console.error(`Error executing script "${script}":`, error); + console.error(`stderr executing script "${script}":`, stderr); reject(error); } else { console.log(`> Run NPM Script "${script}":\n`, stdout); @@ -35,8 +36,17 @@ export class Helper { }); } + async writeFile(filePath: string, fileName: string, data: string) { + const absoluteRoute = path.join(filePath, fileName); + try { + await fs.writeFile(absoluteRoute, data); + } catch { + console.log(`Cannot write: ${fileName} to ${filePath}`); + } + } + async readFile(filePath: string, fileName: string) { - const absoluteRoute = path.join(filePath + fileName); + const absoluteRoute = path.join(filePath, fileName); try { return await fs.readFile(absoluteRoute, { encoding: "utf-8" }); diff --git a/packages/integration-tests/src/playbook/deploy/deploy-greeter.ts b/packages/integration-tests/src/playbook/deploy/deploy-greeter.ts index c9291e7c6e..a773568e35 100644 --- a/packages/integration-tests/src/playbook/deploy/deploy-greeter.ts +++ b/packages/integration-tests/src/playbook/deploy/deploy-greeter.ts @@ -2,10 +2,12 @@ import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; import { promises as fs } from "fs"; import { localConfig } from "../../config"; -import { Buffer } from "../../constants"; +import { Buffer, Path } from "../../constants"; +import { Helper } from "../../helper"; import getWallet from "../utils/getWallet"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; +const helper = new Helper(); export default async function (hre: HardhatRuntimeEnvironment) { const wallet = await getWallet(hre); @@ -15,5 +17,5 @@ export default async function (hre: HardhatRuntimeEnvironment) { const contract = await deployer.deploy(artifact, [], localConfig.gasLimit); const contractAddress = contract.address; console.log(`${artifact.contractName} was deployed to ${contractAddress}`); - await fs.writeFile(Buffer.greeterL2, contractAddress); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.greeterL2, contractAddress); } diff --git a/packages/integration-tests/src/playbook/deploy/deploy-paymaster.ts b/packages/integration-tests/src/playbook/deploy/deploy-paymaster.ts index 7c82c1f8b3..b68dc35c82 100644 --- a/packages/integration-tests/src/playbook/deploy/deploy-paymaster.ts +++ b/packages/integration-tests/src/playbook/deploy/deploy-paymaster.ts @@ -1,20 +1,21 @@ import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; import * as ethers from "ethers"; -import { promises as fs } from "fs"; import { Wallet } from "zksync-web3"; -import { Buffer, Wallets } from "../../constants"; +import { Buffer, Path, Wallets } from "../../constants"; +import { Helper } from "../../helper"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; +const helper = new Helper(); export default async function (hre: HardhatRuntimeEnvironment) { const wallet = new Wallet(Wallets.richWalletPrivateKey); // The wallet that will receive ERC20 tokens const emptyWallet = Wallet.createRandom(); console.log(`Empty wallet's address: ${emptyWallet.address}`); - await fs.writeFile(Buffer.emptyWalletAddress, emptyWallet.address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.emptyWalletAddress, emptyWallet.address); console.log(`Empty wallet's private key: ${emptyWallet.privateKey}`); - await fs.writeFile(Buffer.emptyWalletPrivateKey, emptyWallet.privateKey); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.emptyWalletPrivateKey, emptyWallet.privateKey); const deployer = new Deployer(hre, wallet); @@ -22,16 +23,16 @@ export default async function (hre: HardhatRuntimeEnvironment) { const erc20Artifact = await deployer.loadArtifact("MyERC20"); const erc20 = await deployer.deploy(erc20Artifact, ["MyToken", "MyToken", 18]); console.log(`ERC20 address: ${erc20.address}`); - await fs.writeFile(Buffer.customToken, erc20.address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.customToken, erc20.address); const paymasterArtifact = await deployer.loadArtifact("MyPaymaster"); const paymaster = await deployer.deploy(paymasterArtifact, [erc20.address]); console.log(`Paymaster address: ${paymaster.address}`); - await fs.writeFile(Buffer.paymaster, paymaster.address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.paymaster, paymaster.address); const deployTransaction = await paymaster.deployTransaction; console.log(`Paymaster deploy transaction: ${deployTransaction.hash}`); - await fs.writeFile(Buffer.paymasterDeployTx, deployTransaction.hash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.paymasterDeployTx, deployTransaction.hash); await ( await deployer.zkWallet.sendTransaction({ diff --git a/packages/integration-tests/src/playbook/deploy/erc20toL1.ts b/packages/integration-tests/src/playbook/deploy/erc20toL1.ts index b675e55207..49d8bf006c 100644 --- a/packages/integration-tests/src/playbook/deploy/erc20toL1.ts +++ b/packages/integration-tests/src/playbook/deploy/erc20toL1.ts @@ -1,9 +1,10 @@ -import { promises as fs } from "fs"; import { ethers } from "hardhat"; import { localConfig } from "../../config"; -import { Buffer, Wallets } from "../../constants"; +import { Buffer, Path, Wallets } from "../../constants"; +import { Helper } from "../../helper"; +const helper = new Helper(); async function main() { const [deployer] = await ethers.getSigners(); @@ -16,7 +17,7 @@ async function main() { const contract = await ethers.getContractFactory("L1"); const token = await contract.deploy(Wallets.richWalletAddress, localConfig.gasLimit); - await fs.writeFile(Buffer.L1, token.address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.L1, token.address); } main() diff --git a/packages/integration-tests/src/playbook/deploy/erc20toL2.ts b/packages/integration-tests/src/playbook/deploy/erc20toL2.ts index 13964be03f..51b7d2a86a 100644 --- a/packages/integration-tests/src/playbook/deploy/erc20toL2.ts +++ b/packages/integration-tests/src/playbook/deploy/erc20toL2.ts @@ -1,11 +1,12 @@ import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; -import { promises as fs } from "fs"; import { localConfig } from "../../config"; -import { Buffer } from "../../constants"; +import { Buffer, Path } from "../../constants"; +import { Helper } from "../../helper"; import getWallet from "../utils/getWallet"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; +const helper = new Helper(); export default async function (hre: HardhatRuntimeEnvironment) { const wallet = await getWallet(hre); @@ -15,5 +16,5 @@ export default async function (hre: HardhatRuntimeEnvironment) { const contract = await deployer.deploy(artifact, [], localConfig.gasLimit); const contractAddress = contract.address; console.log(`${artifact.contractName} was deployed to ${contractAddress}`); - await fs.writeFile(Buffer.L2, contractAddress); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.L2, contractAddress); } diff --git a/packages/integration-tests/src/playbook/deploy/multiTransferETH.ts b/packages/integration-tests/src/playbook/deploy/multiTransferETH.ts index 6a8dd60492..e5444f7c04 100644 --- a/packages/integration-tests/src/playbook/deploy/multiTransferETH.ts +++ b/packages/integration-tests/src/playbook/deploy/multiTransferETH.ts @@ -1,11 +1,12 @@ import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; -import { promises as fs } from "fs"; -import { Buffer, Wallets } from "../../constants"; +import { Buffer, Path, Wallets } from "../../constants"; +import { Helper } from "../../helper"; import verify from "../utils/displayVerificationInfo"; import getWallet from "../utils/getWallet"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; +const helper = new Helper(); const contract_name = "TokenF2L2"; // insert the name of the contract you want to deploy const constructor_arguments = [Wallets.richWalletAddress]; // insert the constructor arguments of the contract you want to deploy @@ -27,7 +28,7 @@ export default async function (hre: HardhatRuntimeEnvironment) { // Show the contract info. console.log(`Contract "${artifact.contractName}" was deployed to ${deployedContract.address}`); - await fs.writeFile(Buffer.addressMultiTransferETH, deployedContract.address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH, deployedContract.address); await verify({ hre, contract: deployedContract, contractConstructorArguments: constructor_arguments, artifact }); diff --git a/packages/integration-tests/src/playbook/deploy/multicallCaller.ts b/packages/integration-tests/src/playbook/deploy/multicallCaller.ts index 537e7abb37..ed1f3452b5 100644 --- a/packages/integration-tests/src/playbook/deploy/multicallCaller.ts +++ b/packages/integration-tests/src/playbook/deploy/multicallCaller.ts @@ -1,5 +1,4 @@ import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; -import { promises as fs } from "fs"; import { Buffer, Path } from "../../constants"; import { Helper } from "../../helper"; @@ -33,8 +32,8 @@ export default async function (hre: HardhatRuntimeEnvironment) { const address = deployedContract.address; const txHash = deployedContract.deployTransaction.hash; - await fs.writeFile(Buffer.addressMultiCallCaller, address); - await fs.writeFile(Buffer.txMultiCallCaller, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallCaller, address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallCaller, txHash); return [address, txHash]; } diff --git a/packages/integration-tests/src/playbook/deploy/multicallMiddle.ts b/packages/integration-tests/src/playbook/deploy/multicallMiddle.ts index c694f3407a..bbe775b7db 100644 --- a/packages/integration-tests/src/playbook/deploy/multicallMiddle.ts +++ b/packages/integration-tests/src/playbook/deploy/multicallMiddle.ts @@ -34,8 +34,8 @@ export default async function (hre: HardhatRuntimeEnvironment) { const address = deployedContract.address; const txHash = deployedContract.deployTransaction.hash; - await fs.writeFile(Buffer.addressMultiCallMiddle, address); - await fs.writeFile(Buffer.txMultiCallMiddle, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallMiddle, address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallMiddle, txHash); return [address, txHash]; } diff --git a/packages/integration-tests/src/playbook/deploy/multicallRoot.ts b/packages/integration-tests/src/playbook/deploy/multicallRoot.ts index d06b991af9..67efa20891 100644 --- a/packages/integration-tests/src/playbook/deploy/multicallRoot.ts +++ b/packages/integration-tests/src/playbook/deploy/multicallRoot.ts @@ -1,12 +1,13 @@ 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"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; export default async function (hre: HardhatRuntimeEnvironment) { + const helper = new Helper(); console.log(`Running deploy script for the Greeter contract`); const wallet = await getWallet(hre); @@ -48,8 +49,8 @@ export default async function (hre: HardhatRuntimeEnvironment) { const address = deployedContract.address; const txHash = deployedContract.deployTransaction.hash; - await fs.writeFile(Buffer.addressMultiCallRoot, address); - await fs.writeFile(Buffer.txMultiCallRoot, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot, address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallRoot, txHash); return [address, txHash]; } diff --git a/packages/integration-tests/src/playbook/deploy/nftToL1.ts b/packages/integration-tests/src/playbook/deploy/nftToL1.ts index c08f68dfb8..8dfa5242fd 100644 --- a/packages/integration-tests/src/playbook/deploy/nftToL1.ts +++ b/packages/integration-tests/src/playbook/deploy/nftToL1.ts @@ -1,10 +1,11 @@ -import { promises as fs } from "fs"; import { ethers } from "hardhat"; import * as hardhatConfig from "hardhat"; -import { Buffer, Wallets } from "../../constants"; +import { Buffer, Path, Wallets } from "../../constants"; +import { Helper } from "../../helper"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; +const helper = new Helper(); async function main() { const hre: HardhatRuntimeEnvironment = hardhatConfig; @@ -22,7 +23,7 @@ async function main() { console.error(`The NFT minting has been unsuccessful: ${mintNFT}`); } - await fs.writeFile(Buffer.NFTtoL1, myNFT.address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL1, myNFT.address); } main() diff --git a/packages/integration-tests/src/playbook/deploy/nftToL2.ts b/packages/integration-tests/src/playbook/deploy/nftToL2.ts index 4b90bc5073..bf22be1a42 100644 --- a/packages/integration-tests/src/playbook/deploy/nftToL2.ts +++ b/packages/integration-tests/src/playbook/deploy/nftToL2.ts @@ -1,13 +1,14 @@ import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; -import { promises as fs } from "fs"; -import { Buffer, Wallets } from "../../constants"; +import { Buffer, Path, Wallets } from "../../constants"; +import { Helper } from "../../helper"; import displayVerificationInfo from "../utils/displayVerificationInfo"; import getWallet from "../utils/getWallet"; import type { HardhatRuntimeEnvironment } from "hardhat/types"; export default async function (hre: HardhatRuntimeEnvironment) { + const helper = new Helper(); console.log(`Running deploy script for the Greeter contract`); const wallet = await getWallet(hre); @@ -30,5 +31,5 @@ export default async function (hre: HardhatRuntimeEnvironment) { displayVerificationInfo({ hre, contract: myNFT, contractConstructorArguments, artifact }); - await fs.writeFile(Buffer.NFTtoL2, myNFT.address); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL2, myNFT.address); } diff --git a/packages/integration-tests/src/playbook/deploy/use-greeter.ts b/packages/integration-tests/src/playbook/deploy/use-greeter.ts index a1e232b7b1..c15a7d91dc 100644 --- a/packages/integration-tests/src/playbook/deploy/use-greeter.ts +++ b/packages/integration-tests/src/playbook/deploy/use-greeter.ts @@ -32,7 +32,7 @@ export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Transaction hash: ${transactionReceipt.transactionHash}`); - await fs.writeFile(Buffer.executeGreeterTx, transactionReceipt.transactionHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.executeGreeterTx, transactionReceipt.transactionHash); return transactionReceipt.transactionHash; } diff --git a/packages/integration-tests/src/playbook/deploy/use-multiCall.ts b/packages/integration-tests/src/playbook/deploy/use-multiCall.ts index cf72140aae..b420bef4a3 100644 --- a/packages/integration-tests/src/playbook/deploy/use-multiCall.ts +++ b/packages/integration-tests/src/playbook/deploy/use-multiCall.ts @@ -33,7 +33,7 @@ export default async function (hre: HardhatRuntimeEnvironment) { console.log("Multicall contract caller: ", txHash); console.log(`Contract said after new greeting: ${await attachedContract.newCallGreeter()}`); - await fs.writeFile(Buffer.txUseMultiCallContracts, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txUseMultiCallContracts, txHash); return txHash; } diff --git a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts index 0cf2f076fd..9f72911068 100644 --- a/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts +++ b/packages/integration-tests/src/playbook/deploy/use-multitransferETH.ts @@ -1,5 +1,4 @@ import * as ethers from "ethers"; -import { promises as fs } from "fs"; import { Provider, Wallet } from "zksync-web3"; import { localConfig } from "../../config"; @@ -91,7 +90,7 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen )}" Custom token II` ); - await fs.writeFile(Buffer.txMultiTransferETH, ethTransfer); - await fs.writeFile(Buffer.txMultiTransferCustomTokenI, customToken1Transfer); - await fs.writeFile(Buffer.txMultiTransferCustomTokenII, customToken2Transfer); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH, ethTransfer); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenI, customToken1Transfer); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenII, customToken2Transfer); } diff --git a/packages/integration-tests/src/playbook/deploy/use-paymaster.ts b/packages/integration-tests/src/playbook/deploy/use-paymaster.ts index 807af7172c..963d978ef0 100644 --- a/packages/integration-tests/src/playbook/deploy/use-paymaster.ts +++ b/packages/integration-tests/src/playbook/deploy/use-paymaster.ts @@ -1,5 +1,4 @@ import * as ethers from "ethers"; -import { promises as fs } from "fs"; import { Provider, utils, Wallet } from "zksync-web3"; import { localConfig } from "../../config"; @@ -62,7 +61,7 @@ export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Balance of the user after mint: ${await emptyWallet.getBalance(TOKEN_ADDRESS)}`); - await fs.writeFile(Buffer.paymasterTx, receipt.transactionHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.paymasterTx, receipt.transactionHash); console.log(`Transaction hash: ${receipt.transactionHash}`); return receipt.transactionHash; diff --git a/packages/integration-tests/src/playbook/scenarios/deposit/depositERC20.ts b/packages/integration-tests/src/playbook/scenarios/deposit/depositERC20.ts index e62a1fe700..ac4154631d 100644 --- a/packages/integration-tests/src/playbook/scenarios/deposit/depositERC20.ts +++ b/packages/integration-tests/src/playbook/scenarios/deposit/depositERC20.ts @@ -1,6 +1,4 @@ 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"; @@ -11,8 +9,6 @@ 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 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({ @@ -30,8 +26,8 @@ export const depositERC20 = async function (sum = "0.5", tokenAddress: string, u console.log("L2 token address ", l2TokenAddress); const txHash = await deposit.waitFinalize(); await helper.logTransaction(Logger.deposit, txHash.transactionHash, "ERC20 token"); - await fs.writeFile(bufferAddressL2DepositedFile, l2TokenAddress); - await fs.writeFile(bufferTxErc20DepositFile, txHash.transactionHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.L2deposited, l2TokenAddress); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txERC20Deposit, txHash.transactionHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts b/packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts index 294ec402f8..d19297b314 100644 --- a/packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/deposit/depositETH.ts @@ -1,6 +1,4 @@ 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"; @@ -12,7 +10,6 @@ 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 bufferFile = path.join(Path.playbookRoot, Buffer.txEthDeposit); const deposit = await syncWallet.deposit({ token: zksync.utils.ETH_ADDRESS, @@ -22,7 +19,7 @@ export const depositEth = async function (sum = "0.000009") { await deposit.wait(1); const txHash = await deposit.waitFinalize(); await helper.logTransaction(Logger.deposit, txHash.transactionHash, "ETH"); - await fs.writeFile(bufferFile, txHash.transactionHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txEthDeposit, txHash.transactionHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts index 7a6053a5df..3d82d75ead 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts @@ -1,6 +1,4 @@ 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"; @@ -13,7 +11,6 @@ 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 bufferFile = path.join(Path.playbookRoot, Buffer.txEthTransfer); const transfer = await syncWallet.transfer({ to: syncWallet2.address, @@ -24,7 +21,7 @@ export const transferERC20 = async function (sum: string, tokenAddress: string, const txHash = transfer.hash; await helper.logTransaction(Logger.transfer, txHash, tokenName); - await fs.writeFile(bufferFile, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txEthTransfer, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts index da98e9b0b1..64d5de8e9f 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts @@ -13,7 +13,6 @@ 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 bufferFile = path.join(Path.playbookRoot + Buffer.txEthTransfer); const transfer = await syncWallet.transfer({ to: syncWallet2.address, @@ -23,7 +22,7 @@ export const transferEth = async function (sum = "0.000009", address: string = W const txHash = transfer.hash; await helper.logTransaction(Logger.transfer, txHash, "ETH"); - await fs.writeFile(bufferFile, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txEthTransfer, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts index e085fbe8a6..b618b38626 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts @@ -1,6 +1,4 @@ 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"; @@ -13,7 +11,6 @@ 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 bufferFile = path.join(Path.playbookRoot + Buffer.failedState); const transfer = await syncWallet.transfer({ to: "0x0000000000000000000000000000000000000000", @@ -24,7 +21,7 @@ export const transferFailedState = async function (tokenAddress: string, tokenNa const txHash = transfer.hash; await helper.logTransaction(Logger.txFailedState, txHash, tokenName); - await fs.writeFile(bufferFile, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.failedState, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts index cc7e38795b..39897516f4 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts @@ -1,6 +1,4 @@ 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"; @@ -13,7 +11,6 @@ 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 bufferFile = path.join(Path.playbookRoot, Buffer.txERC20Withdraw); const balance = await syncWallet.getBalance(tokenAddress); @@ -37,7 +34,7 @@ export const withdrawERC20 = async function (tokenAddress: string, sum = "0.2") console.log(`Your balance is ${balanceAfter.toString()}`); await helper.logTransaction(Logger.withdraw, txHash, "Custom token"); - await fs.writeFile(bufferFile, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txERC20Withdraw, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts index f5bcf605b2..5a86cbb8be 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts @@ -13,7 +13,6 @@ 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 bufferFile = path.join(Path.playbookRoot, Buffer.txERC20WithdrawOtherAddress); const balance = await syncWallet.getBalance(tokenAddress); @@ -37,7 +36,7 @@ export const withdrawERC20toOtherAddress = async function (tokenAddress: string, console.log(`Your balance is ${balanceAfter.toString()}`); await helper.logTransaction(Logger.withdraw, txHash, "Custom token"); - await fs.writeFile(bufferFile, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txERC20WithdrawOtherAddress, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts index d57f1806a8..8355f7bc1e 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts @@ -1,6 +1,4 @@ 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"; @@ -12,7 +10,6 @@ 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 bufferFile = path.join(Path.playbookRoot, Buffer.txEthWithdraw); const withdrawL2 = await syncWallet.withdraw({ token: zksync.utils.ETH_ADDRESS, @@ -23,7 +20,7 @@ export const withdrawETH = async function (sum = "0.000009") { await withdrawL2.waitFinalize(); await helper.logTransaction(Logger.withdraw, txHash, "ETH"); - await fs.writeFile(bufferFile, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdraw, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts index 7d62429711..e946974c44 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts @@ -1,6 +1,4 @@ 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"; @@ -12,7 +10,6 @@ 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 bufferFile = path.join(Path.playbookRoot + Buffer.txEthWithdrawOtherAddress); const withdrawL2 = await syncWallet.withdraw({ token: zksync.utils.ETH_ADDRESS, @@ -24,7 +21,7 @@ export const withdrawETHtoOtherAddress = async function (sum = "0.000009") { await withdrawL2.waitFinalize(); await helper.logTransaction(Logger.withdraw, txHash, "ETH"); - await fs.writeFile(bufferFile, txHash); + await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txEthWithdrawOtherAddress, txHash); return txHash; };