From ff33e37e5ee88393a6160fda1a6a27c27646b73c Mon Sep 17 00:00:00 2001 From: pcheremu Date: Mon, 29 Jan 2024 15:22:57 +0100 Subject: [PATCH] test: refactoring --- README.md | 4 ++-- test/common.test.ts | 29 +++++++++++------------------ test/{ => src}/entities.ts | 1 - test/{ => src}/helper.ts | 0 tsconfig.json | 3 +-- 5 files changed, 14 insertions(+), 23 deletions(-) rename test/{ => src}/entities.ts (88%) rename test/{ => src}/helper.ts (100%) diff --git a/README.md b/README.md index 92cd639d..e6899546 100644 --- a/README.md +++ b/README.md @@ -88,10 +88,10 @@ In the meantime, you can test the code manually by running the code in [developm ### CLI tests To run CLI tests for zksync-cli do the following: -1. Go to [cli-tests](`./src/tests/cli-tests`) folder +1. Go to [test](`./test`) folder 2. Run `npm i` and install zksync-cli `npm i zksync-cli` 3. Make sure you have [Docker](https://docs.docker.com/engine/install/) on your system. -4. Make sure you have `.env` file with your wallet private key in `src\tests\cli-tests\src\` dir. Key is `E2E_TESTNET_PK`. It may looks like `E2E_TESTNET_PK=012345...abcdef` +4. Make sure you have `.env` file with your wallet private key in `./tests/src/` dir. Key is `E2E_TESTNET_PK`. It may looks like `E2E_TESTNET_PK=012345...abcdef` 5. Run `npm test` ## 🌍 Official Links diff --git a/test/common.test.ts b/test/common.test.ts index 76dcd32a..569bf35f 100644 --- a/test/common.test.ts +++ b/test/common.test.ts @@ -1,5 +1,5 @@ -import { adresses, contracts, wallet } from "./entities"; -import { executeCommand } from "./helper"; +import { adresses, contracts, wallet } from "./src/entities"; +import { executeCommand } from "./src/helper"; //id1717 describe("Check version of package", () => { @@ -104,32 +104,25 @@ describe("User can check installed modules", () => { }); //id1869 -xdescribe("Check wallet balance of specified address", () => { +describe("Check wallet balance of specified address", () => { const partialCommand = "npx zksync-cli wallet balance"; - it(`${partialCommand} | on Sepolia Testnet`, () => { - const command = `${partialCommand} --chain zksync-sepolia --address ${adresses.sepoliaTestnet}`; + it(`${partialCommand} | on Era Testnet`, () => { + const command = `${partialCommand} --chain era-testnet --address ${adresses.sepoliaTestnet}`; const result = executeCommand(command); - expect(result.output).toMatch(/(zkSync Sepolia Testnet Balance:)/i); + expect(result.output).toMatch(/(Testnet Balance:)/i); expect(result.exitCode).toBe(0); }); it(`${partialCommand} | on zkSync Mainnet`, () => { - const command = `${partialCommand} --chain zksync-mainnet --address ${adresses.zksyncMainnet}`; + const command = `${partialCommand} --chain era-mainnet --address ${adresses.zksyncMainnet}`; const result = executeCommand(command); - expect(result.output).toMatch(/(zkSync Mainnet Balance:)/i); - expect(result.exitCode).toBe(0); - }); - - it(`${partialCommand} | on Goerli Testnet`, () => { - const command = `${partialCommand} --chain zksync-goerli --address ${adresses.goerliTestnet}`; - const result = executeCommand(command); - expect(result.output).toMatch(/(zkSync Goerli Testnet Balance:)/i); + expect(result.output).toMatch(/(Mainnet Balance:)/i); expect(result.exitCode).toBe(0); }); }); //id1718 -xdescribe("Specific package can be updated using zksync-cli dev update ", () => { +describe("Specific package can be updated using zksync-cli dev update ", () => { // need to find out the way how to make "npx zksync-cli dev start" it("npx zksync-cli dev update ", () => { @@ -144,7 +137,7 @@ xdescribe("Specific package can be updated using zksync-cli dev update { it("npx zksync-cli contract read", () => { - const command = `npx zksync-cli contract read --chain zksync-sepolia\ + const command = `npx zksync-cli contract read --chain era-testnet\ --contract ${contracts.sepoliaTestnet} --method "greet() view returns (string)"\ --output string`; const result = executeCommand(command); @@ -162,7 +155,7 @@ xdescribe("User can call write method from deployed contract on network", () => if (process.platform === "win32") { optionalRedirection = " > nul "; } - const command = `npx zksync-cli contract write --chain zksync-sepolia\ + const command = `npx zksync-cli contract write --chain era-testnet\ --contract ${contracts.sepoliaTestnet} --method "setGreeting(string _greeting) "\ --args "New Test ARG" --private-key ${wallet.testnetPK} ${optionalRedirection}`; // potential issue. on windows without the redirection we catching a wrong stdout. const result = executeCommand(command); diff --git a/test/entities.ts b/test/src/entities.ts similarity index 88% rename from test/entities.ts rename to test/src/entities.ts index ad6b2fca..4e3bcde1 100644 --- a/test/entities.ts +++ b/test/src/entities.ts @@ -6,7 +6,6 @@ dotenv.config(); // { path: path.resolve(__dirname, ".env") } export const adresses = { sepoliaTestnet: "0x52B6d10d7d865B3d4103f8809AA3521288568f46", zksyncMainnet: "0x52B6d10d7d865B3d4103f8809AA3521288568f46", - goerliTestnet: "0x52B6d10d7d865B3d4103f8809AA3521288568f46", }; export const contracts = { diff --git a/test/helper.ts b/test/src/helper.ts similarity index 100% rename from test/helper.ts rename to test/src/helper.ts diff --git a/tsconfig.json b/tsconfig.json index 89ac735d..c76306d8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,5 @@ "strict": true, "resolveJsonModule": true }, - "include": ["./src"], - "exclude": ["**/cli-tests/**"] + "include": ["./src"] }