Skip to content

Commit

Permalink
test: add docker run (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu authored Mar 14, 2024
1 parent cc39561 commit 4feb99e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 27 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/test-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@ name: Tests

on: pull_request


jobs:
preparation_and_running_tests:
tests:
permissions:
contents: read
strategy:
matrix:
os: [
ubuntu-latest,
windows-latest,
macos-latest
]
node-version: ['18.17.1', '20.11.0'] # or 18.17.1
tags: [
"common.test.ts"
]
os: [macos-latest, ubuntu-latest, windows-latest]
node-version: ['18.17.1', '20.11.0'] # lts/* for lts node
runs-on: ${{ matrix.os }}
name: 'Node ${{ matrix.node-version }} / ${{ matrix.os }}'

name: '${{ matrix.os }} / Node ${{ matrix.node-version }}'
steps:
- uses: actions/checkout@v4

Expand All @@ -41,5 +33,12 @@ jobs:
CI: true
E2E_TESTNET_PK: ${{ secrets.E2E_TESTNET_PK }}
run: |
npx jest --verbose --testPathPattern=${{ matrix.tags }}
echo "Run tests"
if [ $RUNNER_OS != 'Linux' ]; then
echo "Run without docker tests"
npx jest --verbose --testPathIgnorePatterns=dev.test.ts
else
echo "Run all tests"
npx jest --verbose --testPathPattern=
fi
shell: bash
16 changes: 3 additions & 13 deletions test/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { adresses, contracts, wallet } from "./src/entities";
import { executeCommand } from "./src/helper";
import { setTimeout } from "timers/promises";


describe("Common tests", () => {

Expand Down Expand Up @@ -130,19 +132,6 @@ describe("Common tests", () => {
});
});

//id1718 - excluded
xdescribe("Specific package can be updated using zksync-cli dev update module name", () => {
// need to find out the way how to make "npx zksync-cli dev start"

it("npx zksync-cli dev update module", () => {
const command = "npx zksync-cli dev update zkcli-portal";
const result = executeCommand(command);
expect(result.output).toMatch(/(Updating module)/i);
expect(result.output).not.toMatch(/([Ee]rror|[Ww]arning|[Ff]ail)/i);
expect(result.exitCode).toBe(0);
});
});

//id1874
describe("User can call read method from deployed contract on network", () => {
it("npx zksync-cli contract read", () => {
Expand All @@ -169,6 +158,7 @@ describe("Common tests", () => {
--contract ${contracts.sepoliaTestnet} --method "setGreeting(string _greeting) "\
--args "New Test ARG" --private-key ${wallet.testnetPK} ${optionalRedirection}`;
const result = executeCommand(command);
setTimeout(3000)
expect(result.output).toMatch(/(Transaction submitted.)/i);
expect(result.output).toMatch(/(Transaction processed successfully.)/i);
expect(result.output).not.toMatch(/([Ee]rror|[Ww]arning|[Ff]ail)/i);
Expand Down
39 changes: 39 additions & 0 deletions test/dev.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { executeCommand } from "./src/helper";


describe("Check zksync-cli dev", () => {

it("npx zksync-cli dev config", () => {
const command = "yes | npx zksync-cli dev config";
const result = executeCommand(command);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev start", () => {
const command = "npx zksync-cli dev start";
const result = executeCommand(command);
expect(result.exitCode).toBe(0);
});

//id1718
it("npx zksync-cli dev update module", () => {
const command = "npx zksync-cli dev update zkcli-portal";
const result = executeCommand(command);
expect(result.output).toMatch(/(Updating module)/i);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev restart", () => {
const command = "npx zksync-cli dev restart";
const result = executeCommand(command);
// console.log(result.output);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev stop", () => {
const command = "npx zksync-cli dev stop";
const result = executeCommand(command);
// console.log(result.output);
expect(result.exitCode).toBe(0);
});
});

0 comments on commit 4feb99e

Please sign in to comment.