-
Notifications
You must be signed in to change notification settings - Fork 96
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
olehbairak
wants to merge
3
commits into
implement-tests
from
create-automation-tests-for-zksync-cli-project
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.