Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automation test coverage addition #112

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/test-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on: pull_request


jobs:
preparation_and_running_tests:
permissions:
contents: read
strategy:
matrix:
os: [
ubuntu-latest,
windows-latest,
macos-latest
]
node-version: ['lts/*', '18.17.1'] # or 18.17.1
tags: [
"default"
]
runs-on: ${{matrix.os}}

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

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Install dependencies
run: |
npm i zksync-cli

- name: Run tests
run: |
./src/tests/test_zksync_cli.sh
shell: bash

155 changes: 155 additions & 0 deletions src/tests/test_zksync_cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/bin/bash

declare -i counter_failed=0
declare -i counter_total=0
declare -i RESULT=0

verify_result () {
RESULT=$?
counter_total+=1
if [ $RESULT -eq 0 ]; then
echo ""
echo "-----------> SUCCESS <-----------"
echo " "
else
echo ""
echo "-----------> FAILED <-----------"
echo " "
counter_failed+=1
fi
}

echo "INFO"

echo "node:"
node --version
echo "npm:"
npm --version
echo "docker:"
docker --version

#BASIC

echo "Test #1717"
echo "---------------------------------"

echo "> npx zksync-cli -V"
npx zksync-cli -V
verify_result

echo "> npx zksync-cli --version"
npx zksync-cli --version
verify_result

###

echo "Test #1734"
echo "---------------------------------"

echo "> npx zksync-cli --help"
npx zksync-cli --help
verify_result

echo "---------------------------------"
echo "> npx zksync-cli --help deposit"
npx zksync-cli --help deposit
verify_result

###

echo "Test #1714"
echo "---------------------------------"

echo "> npx zksync-cli -h"
npx zksync-cli -h
verify_result

echo "---------------------------------"
echo "> npx zksync-cli --help"
npx zksync-cli --help
verify_result

###

echo "Test #1715"
echo "---------------------------------"

echo "npx zksync-cli dev -h"
npx zksync-cli dev -h
verify_result

echo "---------------------------------"
echo "npx zksync-cli dev --help"
npx zksync-cli dev --help
verify_result

echo "---------------------------------"
echo "npx zksync-cli dev --help start"
npx zksync-cli dev --help start
verify_result

###

echo "Test #1719"
echo "---------------------------------"

echo "> zksync-cli dev modules"
npx zksync-cli dev modules
verify_result

###

echo "Test #1869"
echo "---------------------------------"

echo "> zksync-cli wallet balance on Sepolia Testnet"
npx zksync-cli wallet balance --chain zksync-sepolia --address 0x52B6d10d7d865B3d4103f8809AA3521288568f46

echo "> zksync-cli wallet balance on Zksync Mainnet"
npx zksync-cli wallet balance --chain zksync-mainnet --address 0x52B6d10d7d865B3d4103f8809AA3521288568f46

echo "> zksync-cli wallet balance on Goerli Testnet"
npx zksync-cli wallet balance --chain zksync-goerli --address 0x52B6d10d7d865B3d4103f8809AA3521288568f46


verify_result

###

echo "Test #1718"
echo "---------------------------------"

echo "> zksync-cli dev update <module>"
npx zksync-cli dev update zkcli-portal

verify_result

###

echo "Test #1874"
echo "---------------------------------"

echo "> zksync-cli contract read"
npx zksync-cli contract read --chain zksync-sepolia --contract 0xE6c391927f0B42d82229fd3CFe3426F209D16b48 --method "greet() view returns (string)" --output string

verify_result

###

echo "Test #1875"
echo "---------------------------------"

echo "> zksync-cli contract write"
npx zksync-cli contract write --chain zksync-sepolia --contract 0xE6c391927f0B42d82229fd3CFe3426F209D16b48 --method "setGreeting(string _greeting) " --args "New Test ARG" --private-key 32e2e997e1a2d91cee03f77f903103ce6f50301e125307cc4bcaa87313f1a13e

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we must not store --private-key in direct access even if it belongs to a testnet.
I will replace it to the test solution with a fix: testnet_private_key: process.env.E2E_TESTNET_PK

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.env. --> means that it will be in git actions env. this is also not really secure but may be possible for a testnet

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Of course make sense from security side.


verify_result

###


if [ $counter_failed == 0 ]; then
echo "$counter_total tests Passed"
else
echo "Fail. $counter_failed failed test(s)"
exit 1 # terminate and indicate error
fi