-
Notifications
You must be signed in to change notification settings - Fork 9
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
SYS-334 - Testing and Coverage Report Generation #47
Open
paulgs9988
wants to merge
53
commits into
dev
Choose a base branch
from
localtest
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 48 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
11e5a63
add unit test
kenny-io 5314535
update testing logic, leverage json rpc server, test counts and count…
kenny-io 559b336
added test cases for api/health and api/subscribe
soniasingla 189394a
Add new integration tests
kenny-io 88ad534
increse test timeout, organize test files
kenny-io b0399c1
use global config port
kenny-io 2a4b3bf
added new integration test cases for eth_blockNumber, eth_chainId and…
soniasingla 01cd262
added script to initialize localtestnet
soniasingla d505ae7
set up local test env with local shardeum network
kenny-io 48e73f9
modify the script
soniasingla ea24455
add new test cases (#33)
kenny-io 2f0f1bc
add remaining test cases
soniasingla b6f899e
SYS-254 fixes race condition in clearing stats collection (#32)
asyed94 9d68944
'Refactor test cases, improve test coverage, and better error handling
kenny-io 0b769d1
update params
soniasingla ffad851
Add new transaction test cases (#35)
kenny-io 6bafed3
updated parameters and added new test cases
soniasingla 5b6ff9e
Add new test cases (#36)
kenny-io e5e930a
update the failing tests
soniasingla 13ca845
update the failing tests part 2
soniasingla a65bb7f
use env for txn tests (#37)
kenny-io 6f77097
rename test files for consistency
soniasingla 7e9ce31
update setup script
kenny-io 4746c8b
update txn tests
kenny-io b784980
add readme, update script and test
soniasingla 76ee177
Update testing instructions
kenny-io df11ba3
fine-tune test script to execute gracefully
kenny-io 55164b4
start jrpc server in the background so tests can run
kenny-io 1cd0f75
update readme for testing instructions
kenny-io ec32f93
update testing instructions
kenny-io 598099a
remove the unsupported methods
soniasingla 0bef7ff
optimize test script
kenny-io 9309a55
optimize test script
kenny-io f204805
update testing instructions
kenny-io cfdb15e
mod: change URL to PATH
kenny-io 1ce3fcb
Merge branch 'dev' into localtest
soniasingla 35bbba9
Remove gitlab instances from readme (#38)
soniasingla e8621dc
Merge branch 'dev' into localtest
chrischabot 2487e9a
optimize tests and formatting
kenny-io 7c89191
Merge remote-tracking branch 'origin/localtest' into localtest
kenny-io f5aab0c
remove unused deps
kenny-io 0c2a3e9
reauthorize gated apis
kenny-io 3abed89
shutdown script gracefully
kenny-io 4fe7188
reformat to the original version
soniasingla b420c5d
update test script
kenny-io 3448cff
add test docs
kenny-io c6c26f3
update README.md - add Shardeum branding
kenny-io f289260
updating configs for coverage report generation
paulgs9988 273e07a
update test docs - document test account
kenny-io 4c58e21
remove carrots, use strict versions
kenny-io da6c2b6
fix identation
kenny-io 38a3dc7
rmv test script
kenny-io 121cc46
exec test script with npm test
kenny-io 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,7 @@ | ||
{ | ||
"presets": [ | ||
["@babel/preset-env", { "targets": { "node": "current" } }], | ||
"@babel/preset-typescript" | ||
] | ||
} | ||
|
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 |
---|---|---|
|
@@ -13,3 +13,4 @@ config.js | |
dist/ | ||
.idea/ | ||
.DS_Store | ||
.test/ |
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
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,53 @@ | ||
# Shardeum Automated Testing Documentation | ||
|
||
## Overview | ||
|
||
This documentation covers the setup and execution of automated tests for JSON-RPC methods in the Shardeum JSON RPC Server. The goal is to ensure that Shardeum's implementation adheres to expected behaviors in handling blockchain transactions via JSON-RPC. | ||
|
||
## Goals | ||
|
||
- Test all JSON-RPC functions to ensure that they perform as expected. | ||
- Verify the Shardus network connectivity and functionality. | ||
- Ensure proper transaction handling and balance updates. | ||
|
||
## Test Script Overview | ||
|
||
The test script is designed to prepare an environment that is suitable for running the JSON RPC tests. Here is a breakdown of its functionality: | ||
|
||
1. **Environment Preparation**: | ||
|
||
- Checks for and uses NVM (Node Version Manager). | ||
- Installs Node.js v18.16.1 if not present. | ||
- Installs Rust if missing (version 1.74.1). | ||
- Installs necessary build tools (build-essential on Linux, gcc on macOS). | ||
|
||
2. **Repository Management**: | ||
|
||
- Uses an existing Shardeum project if specified, otherwise it clones a fresh copy from the Shardeum repository. | ||
- Applies a debug patch for 10-node setup. | ||
|
||
3. **Dependency Installation**: | ||
|
||
- Runs `npm ci` to install all project dependencies. | ||
- Installs the Shardus CLI tool and the Shardus Archiver if not found. | ||
|
||
4. **Network Initialization**: | ||
- Starts a Shardus network with 10 nodes. | ||
- Waits for 4 minutes to allow network stabilization. | ||
- Runs the tests | ||
|
||
### Test Execution | ||
|
||
Once the environment is set up, the tests are executed using Jest. These tests primarily interact with the `extendedServer` instance defined in the `server.ts` file. It handles JSON-RPC requests and performs the blockchain operations in the tests. Each test file imports its own instance of the RPC server and executes against it. | ||
|
||
Each RPC call has its own test file in the `src/__tests__` directory. Each file contains multiple test cases covering different aspects and edge cases for each RPC method. | ||
|
||
### Run Tests | ||
|
||
The tests typically run automatically through the test script, however, you can run the tests manually by executing the `npm test` command in the JSON RPC Server project. [More on how to run tests here ](https://github.com/shardeum/json-rpc-server/blob/localtest/README.md#running-tests). | ||
|
||
## Expand the Test Suite | ||
|
||
- **Add New Tests**: New tests can be added by creating new test files under the `src/__tests__` directory. Each new file should mimic the structure of existing tests, initializing its setup, defining the RPC calls, and tearing down after tests. | ||
- **Modifying Existing Tests**: To modify existing tests, locate the relevant test file and add or adjust test cases as needed. Be mindful of potential side effects on other tests due to shared state or network conditions. | ||
- **Enhancing Test Coverage**: Increase coverage by adding more scenarios and edge cases, particularly focusing on error handling and failure modes. |
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,21 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testMatch: ['**/__tests__/**/*.test.ts'], | ||
moduleNameMapper: { | ||
'^@/(.*)$': '<rootDir>/src/$1' | ||
}, | ||
testTimeout: 20000, | ||
collectCoverage: true, | ||
coverageDirectory: 'coverage', | ||
coverageReporters: ['text', 'lcov'], | ||
coveragePathIgnorePatterns: [ | ||
"/node_modules/", | ||
"/dist/", | ||
"/src/server.js" | ||
], | ||
transform: { | ||
"^.+\\.(ts|tsx)$": "ts-jest", | ||
}, | ||
}; | ||
|
Oops, something went wrong.
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.
What was the source for this?
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.
@paulgs9988 added the file with this commit f289260