Skip to content

Commit

Permalink
Merge branch 'QA-615-test-solution' into restructure-cli-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vasyl-ivanchuk committed Jan 29, 2024
2 parents 8627e09 + 5228b80 commit 1255b27
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
windows-latest,
macos-latest
]
node-version: ['lts/*', '18.17.1'] # or 18.17.1
node-version: ['19.9.0', '18.17.1'] # or 18.17.1
tags: [
"common.test.ts"
]
Expand All @@ -37,8 +37,10 @@ jobs:
npm i zksync-cli
- name: Run tests
env:
CI: true
E2E_TESTNET_PK: ${{ secrets.E2E_TESTNET_PK }}
run: |
cd src/tests/cli-tests
npx jest --verbose --testPathPattern=${{ matrix.tags }}
shell: bash

11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,18 @@ If you're using [local setup (dockerized testing node)](https://github.com/matte

### Testing

At the moment, we don't have any tests, but we are working on it.
At the moment, we are working on CLI tests.
In the meantime, you can test the code manually by running the code in [development mode](#run-in-development-mode).

### CLI tests

To run CLI tests for zksync-cli do the following:
1. Go to [cli-tests](`./src/tests/cli-tests`) 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`
5. Run `npm test`

## 🌍 Official Links

- [Website](https://zksync.io/)
Expand Down
6 changes: 5 additions & 1 deletion test/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,13 @@ describe("User can call read method from deployed contract on network", () => {
//id1875
describe("User can call write method from deployed contract on network", () => {
it("npx zksync-cli contract write", () => {
let optionalRedirection = "> /dev/null";
if (process.platform === "win32") {
optionalRedirection = " > nul ";
}
const command = `npx zksync-cli contract write --chain zksync-sepolia\
--contract ${contracts.sepoliaTestnet} --method "setGreeting(string _greeting) "\
--args "New Test ARG" --private-key ${wallet.testnetPK} > nul`; // potential issue. on windows without the redirection we catching a wrong stdout.
--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);
expect(result.output).toMatch(/(Transaction submitted.)/i);
expect(result.output).toMatch(/(Transaction processed successfully.)/i);
Expand Down
4 changes: 2 additions & 2 deletions test/entities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as dotenv from "dotenv";
import * as path from "path";
// import * as path from 'path';

dotenv.config({ path: path.resolve(__dirname, ".env") });
dotenv.config(); // { path: path.resolve(__dirname, ".env") }

export const adresses = {
sepoliaTestnet: "0x52B6d10d7d865B3d4103f8809AA3521288568f46",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"strict": true,
"resolveJsonModule": true
},
"include": ["./src"]
"include": ["./src"],
"exclude": ["**/cli-tests/**"]
}

0 comments on commit 1255b27

Please sign in to comment.