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

Implement Unit Tests for Validator-CLI Commands #31

Open
kenny-io opened this issue Oct 9, 2024 · 6 comments
Open

Implement Unit Tests for Validator-CLI Commands #31

kenny-io opened this issue Oct 9, 2024 · 6 comments
Labels
good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed

Comments

@kenny-io
Copy link
Contributor

kenny-io commented Oct 9, 2024

The validator-cli contains several important commands in the src/node-commands.ts file, but currently lacks comprehensive unit tests. Adding tests for these commands will significantly improve the reliability and maintainability of the CLI.

Proposed Solution

Implement unit tests for all the commands in the src/node-commands.ts file, covering various scenarios and edge cases.

Expected Outcome

After implementing your solution:

  • All commands in src/node-commands.ts should have corresponding unit tests
  • Test coverage should be high (aim for >80%)
  • Tests should cover successful executions, error handling, and edge cases
  • The codebase will be more reliable and easier to maintain
  • Potential bugs will be caught before reaching production

Getting Started

  • Fork the repository
  • Clone your fork: git clone [your-fork-url]
  • Create a new branch: git checkout -b feature/add-unit-tests
  • Create a new test file: src/tests/node-commands.test.ts
  • Implement unit tests for each command in src/node-commands.ts, including but not limited to:
    start,stop,status,info,stake,unstake,version,update,gui,clean
  • Run tests and ensure they pass
  • Commit your changes: git commit -m "Add unit tests for operator-cli commands"
  • Push to your fork: git push origin feature/add-unit-tests
  • Create a pull request

Mentorship

If you need any help or have questions about implementing the tests, feel free to ask in the comments. You can also start a discussion here on GitHub, and our team will be happy to provide the necessary assistance.

@kenny-io kenny-io added good first issue Good for newcomers help wanted Extra attention is needed hacktoberfest labels Oct 9, 2024
@dev15Aditya
Copy link

Hello @kenny-io ,
I want to contribute.

@kenny-io
Copy link
Contributor Author

Hello @kenny-io , I want to contribute.

@dev15Aditya go for it, and let us know if you need help with anything

@phy-chain
Copy link

phy-chain commented Oct 14, 2024

👋 @kenny-io
You dont have any test runner in your package.json, should we pick anything we like or do you have a preference ?
I see a "defaultRpcConfig" at the beginning of the file, do we need to be running the test along side a running node or can it be run completely standalone (e.g real unit tests)
It's gonna be a tricky business mocking the dependencies and the API/Promise calls. Do you have a reference for those endpoints that can provide fake data to plug into the tests?

Last question:
Can I run those tests against my Atomium node running on the testnet or is there a risk of breaking it / overloading it ?

@kenny-io
Copy link
Contributor Author

👋 @kenny-io You dont have any test runner in your package.json, should we pick anything we like or do you have a preference ? I see a "defaultRpcConfig" at the beginning of the file, do we need to be running the test along side a running node or can it be run completely standalone (e.g real unit tests) It's gonna be a tricky business mocking the dependencies and the API/Promise calls. Do you have a reference for those endpoints that can provide fake data to plug into the tests?

Last question: Can I run those tests against my Atomium node running on the testnet or is there a risk of breaking it / overloading it ?

@phy-chain I would recommend jest for the test as we are using it in other projects but its ultimately up to you as we are not currently enforcing particular one.

For the best outcome, I would recommend running the cli against a locally running shardeum node, not the live testnet. If you haven't set one up before, this documentation is very helpful

We don't yet have any endpoints that provides mock data (this could be a good issue/PR to come out of this one)

@kenny-io
Copy link
Contributor Author

kenny-io commented Nov 4, 2024

Hey @phy-chain @dev15Aditya how's it going? wanted to check in on your progress here, share any updates so far or questions if you're stuck somewhere

@kenny-io
Copy link
Contributor Author

@phy-chain @dev15Aditya we haven't gotten an update in a long time, so we'll unassign you and open the issue to other contributors, looking forward to receiving your contributions in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants