Skip to content

Commit

Permalink
test: added some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Jun 14, 2024
1 parent 3dd0c6c commit 8923587
Show file tree
Hide file tree
Showing 19 changed files with 5,878 additions and 2,920 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ tests/e2e/reports/
**/playbook/buffer/
**/playbook/cache-zk/
**/playbook/cache/
**/playbook/typechain-types

# Logs
logs
Expand Down
1,525 changes: 616 additions & 909 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
"@semantic-release/npm": "^9.0.0",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/node": "18.17.18",
"dotenv": "^16.4.5",
"enquirer": "2.3.6",
"eslint": "8.48.0",
"husky": "8.0.1",
"lerna": "^7.2.0",
"pg-connection-string": "2.6.2",
"prettier": "2.8.4",
"semantic-release": "^21.1.1",
"typescript": "4.7.4",
"enquirer": "2.3.6",
"dotenv": "16.1.4",
"pg-connection-string": "2.6.2"
"typescript": "^5.4.5"
},
"engines": {
"npm": ">=9.0.0",
Expand Down
26 changes: 6 additions & 20 deletions packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,15 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-pattern 'repos' --ignore-pattern 'git add .'"
},
"devDependencies": {
"@matterlabs/eslint-config-vue": "^1.1.4",
"@matterlabs/hardhat-zksync-deploy": "^1.4.0",
"@matterlabs/hardhat-zksync-solc": "^1.1.4",
"@matterlabs/prettier-config": "^1.0.2",
"@matterlabs/zksync-contracts": "^0.6.1",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@openzeppelin/contracts": "^4.6.0",
"@openzeppelin/contracts-upgradeable": "^4.6.0",
"@playwright/test": "^1.37.1",
"@types/jest": "^29.2.4",
"@types/node": "^18.15.0",
"dotenv": "^16.0.3",
"eslint": "^8.31.0",
"ethers": "5.7.2",
"hardhat": "^2.12.0",
"jest": "^29.6.2",
"lint-staged": "^13.1.0",
"prettier": "^2.8.2",
"supertest": "^6.3.3",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"zksync-web3": "^0.17.1"
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
"@openzeppelin/contracts": "^4.9.6",
"@openzeppelin/contracts-upgradeable": "^4.9.6",
"ethers": "^6.13.0",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2"
},
"dependencies": {
"ts-jest-resolver": "^2.0.0"
Expand Down
8 changes: 3 additions & 5 deletions packages/integration-tests/src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exec } from "child_process";
import { ethers } from "ethers";
import { AbstractProvider, ethers } from "ethers";
import { promises as fs } from "fs";
import * as path from "path";
import * as request from "supertest";
Expand All @@ -9,8 +9,6 @@ import { environment, localConfig } from "./config";
import { Logger } from "./constants";
import { getProviderForL1, getProviderForL2 } from "./provider";

import type { BaseProvider } from "@ethersproject/providers/src.ts/base-provider";

export class Helper {
async logTransaction(txType: string, txValue: string, tokenName?: string) {
const logMessage = `TxHash for ${txType} ${Logger.textSeparator} ${txValue}`;
Expand Down Expand Up @@ -49,7 +47,7 @@ export class Helper {

async getBalanceETH(walletAddress: string, layer: string) {
let network: string;
let provider: BaseProvider;
let provider: any;
if (layer == "L1") {
network = localConfig.L1Network;
provider = getProviderForL1(network);
Expand All @@ -59,7 +57,7 @@ export class Helper {
} else {
console.log(`Wrong layer: ${layer}`);
}
return ethers.utils.formatUnits(await provider.getBalance(walletAddress), "wei");
return ethers.formatUnits(await provider.getBalance(walletAddress), "wei");
}

async delay(ms: number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default async function (hre: HardhatRuntimeEnvironment) {

const deployer = new Deployer(hre, wallet);
const artifact = await deployer.loadArtifact("Greeter");
const contract = await deployer.deploy(artifact, [], localConfig.l1GasLimit);
const contractAddress = contract.address;
const contract = await deployer.deploy(artifact, [""]);
const contractAddress = await contract.getAddress();
console.log(`${artifact.contractName} was deployed to ${contractAddress}`);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.greeterL2, contractAddress);
}
41 changes: 22 additions & 19 deletions packages/integration-tests/src/playbook/deploy/deploy-paymaster.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
import * as ethers from "ethers";
import { Wallet } from "zksync-web3";
import { parseEther } from "ethers";
import { Wallet } from "zksync-ethers";

import { Buffer, Path, Wallets } from "../../constants";
import { Helper } from "../../helper";
Expand All @@ -22,30 +22,33 @@ export default async function (hre: HardhatRuntimeEnvironment) {
// Deploying the ERC20 token
const erc20Artifact = await deployer.loadArtifact("MyERC20");
const erc20 = await deployer.deploy(erc20Artifact, ["MyToken", "MyToken", 18]);
console.log(`ERC20 address: ${erc20.address}`);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.customToken, erc20.address);
const erc20Address = await erc20.getAddress();
console.log(`ERC20 address: ${erc20Address}`);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.customToken, erc20Address);

const paymasterArtifact = await deployer.loadArtifact("MyPaymaster");
const paymaster = await deployer.deploy(paymasterArtifact, [erc20.address]);
console.log(`Paymaster address: ${paymaster.address}`);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.paymaster, paymaster.address);
const paymaster = await deployer.deploy(paymasterArtifact, [erc20Address]);
const paymasterAddress = await paymaster.getAddress();
console.log(`Paymaster address: ${paymasterAddress}`);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.paymaster, paymasterAddress);

const deployTransaction = await paymaster.deployTransaction;
const deployTransaction = await paymaster.deploymentTransaction();
console.log(`Paymaster deploy transaction: ${deployTransaction.hash}`);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.paymasterDeployTx, deployTransaction.hash);

await (
await deployer.zkWallet.sendTransaction({
to: paymaster.address,
value: ethers.utils.parseEther("0.03"),
})
).wait();
// TODO: fix
// await (
// await deployer.zkWallet.sendTransaction({
// to: paymaster.address,
// value: parseEther("0.03"),
// })
// ).wait();

await // We will give the empty wallet 3 units of the token:
(await erc20.mint(emptyWallet.address, 3)).wait();
// await // We will give the empty wallet 3 units of the token:
// (await erc20.mint(emptyWallet.address, 3)).wait();

console.log("Minted 3 tokens for the empty wallet");
console.log(`Done!`);
// console.log("Minted 3 tokens for the empty wallet");
// console.log(`Done!`);

return deployTransaction.hash;
// return deployTransaction.hash;
}
21 changes: 9 additions & 12 deletions packages/integration-tests/src/playbook/deploy/erc20toL1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ import { Helper } from "../../helper";

const helper = new Helper();
async function main() {
const [deployer] = await ethers.getSigners();

console.log("Deploying contracts with the account:", deployer.address);

const weiAmount = (await deployer.getBalance()).toString();

console.log("Account balance:", await ethers.utils.formatEther(weiAmount));

const contract = await ethers.getContractFactory("L1");
const token = await contract.deploy(Wallets.richWalletAddress, localConfig.l1GasLimit);

await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.L1, token.address);
// TODO: fix
// const [deployer] = await ethers.getSigners();
// console.log("Deploying contracts with the account:", deployer.address);
// const weiAmount = (await deployer.getBalance()).toString();
// console.log("Account balance:", await ethers.utils.formatEther(weiAmount));
// const contract = await ethers.getContractFactory("L1");
// const token = await contract.deploy(Wallets.richWalletAddress, localConfig.l1GasLimit);
// const contractAddress = await token.getAddress();
// await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.L1, contractAddress);
}

main()
Expand Down
6 changes: 3 additions & 3 deletions packages/integration-tests/src/playbook/deploy/erc20toL2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";

import { localConfig } from "../../config";
// import { localConfig } from "../../config";
import { Buffer, Path } from "../../constants";
import { Helper } from "../../helper";
import getWallet from "../utils/getWallet";
Expand All @@ -13,8 +13,8 @@ export default async function (hre: HardhatRuntimeEnvironment) {

const deployer = new Deployer(hre, wallet);
const artifact = await deployer.loadArtifact("L2");
const contract = await deployer.deploy(artifact, [], localConfig.l1GasLimit);
const contractAddress = contract.address;
const contract = await deployer.deploy(artifact, []); // depricated? localConfig.l1GasLimit
const contractAddress = await contract.getAddress();
console.log(`${artifact.contractName} was deployed to ${contractAddress}`);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.L2, contractAddress);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export default async function (hre: HardhatRuntimeEnvironment) {

console.log(`Contract said something like this: ${greetingFromContract}`);

const address = deployedContract.address;
const txHash = deployedContract.deployTransaction.hash;
const address = await deployedContract.getAddress();
const txHash = deployedContract.deploymentTransaction().hash;

await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallCaller, address);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallCaller, txHash);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x10e
Loading

0 comments on commit 8923587

Please sign in to comment.