StarknetByExample
StarknetByExample copied to clipboard
feat: add tests
Most of the current listings do not have tests. Adding tests would ensure that we have not left any logic errors that could confuse readers later on.
We need to add atleast simple integration tests for all contracts. Unit tests can be added for more complex contracts.
-
Integration tests are tests that deploy the contract and interact with it's provided interface. They should be placed on a separate file/module
tests.cairo
. -
Unit tests do not have to deploy the contract and use the interface. Unit tests can use mocked implementation or state to test only one specific feature. They should be placed on the same file as the example (and hidden in the book using
ANCHOR
).
You do not have to add tests to all missing listings at once.
See this as a reference.
Please open a PR per example.
I will be working on this
@ebbieaden is working on storing_arrays
, simple_vault
and upgradeable_contract
.
hi @julio4 can I add more test?
hi @julio4 can i jump on this ?
hi @julio4 I will love to work on this
@petersdt @NueloSE @CollinsC1O Thank you for your interest. Currently, all chapter0 examples are tested. You can pick any listings without tests and list it here to be assigned to it. You can take a look at #179 #181 #182 as examples.
Hey @julio4 can i work on components_dependencies
i can work on this
i can work on this
You need to specify the 1-3 tests you want to work on it. Only complete tests will be accepted!
@petersdt @NueloSE @CollinsC1O Thank you for your interest. Currently, all chapter0 examples are tested. You can pick any listings without tests and list it here to be assigned to it. You can take a look at #179 #181 #182 as examples.
@julio4 can i work on components
@julio4 can i work on smart Vault
i can work on this
You need to specify the 1-3 tests you want to work on it. Only complete tests will be accepted!
i can work on switchable and token
@NueloSE , @petersdt OK! @the-first-elder ok for token. Switchable is part of components assigned to @NueloSE currently.
Hi @julio4 I will love to work on cairo_cheatsheet
Hi @julio4 I would like to work on simple_vault.cairo kindly assign it to me.
I can work on upgradeable contracts
@julio4 I've gone through the upgradable contract and I can work on it. Please can you kindly assign it to me. Thank you
Hi @julio4 I will love to work on cairo_cheatsheet
Exceptionally, we will not add tests for the cairo cheatsheet section
@julio4 I've gone through the upgradable contract and I can work on it. Please can you kindly assign it to me. Thank you
Ok! @the-first-elder, let's finish token
tests and you can work on another one just after!
@julio4 I've gone through the upgradable contract and I can work on it. Please can you kindly assign it to me. Thank you
@julio4 I don't know if it's fine for me to work on it since @the-first-elder is working on something else.
As I mention in my previous message here, I've gone through the upgradable contract and I know I can work on it. Please can you kindly assign it to me. I will make sure to complete the task on time. Thank you
Hi @julio4 I would like to work on simple_vault.cairo kindly assign it to me.
hi @julio4 @LamsyA i have already been assigned smart Vault and am making a PR soon
Hey @julio4 is there any tests left I can work on? Maybe Constant Product AMM since OZ#953 has been fixed now. https://github.com/NethermindEth/StarknetByExample/blob/main/listings/applications/constant_product_amm/src/tests.cairo#L41
Hello @julio4 I have added test to simple_vault contract this is the PR
I am applying to this issue via OnlyDust platform.
My background and how it can be leveraged
Hi, I'm Nemesis Alfaro from Costa Rica, i'm a system engineer. I love to learn and practice about different tecnologies. I'm hard-working, constant and curious person This would be my first contribution on the platform, in order to gain more knowledge and improve in the area.
How I plan on tackling this issue
First, i would like carefully read the request and be in contact with you for more infomation. Then i would to further investigate about the options to solve the issue
Hi, I'm Nemesis Alfaro from Costa Rica, i'm a system engineer. ...
Thank you for your interest! Please take a look at the contributing guide to get started.
Thank you for the opportunity, I will review it and if I have any questions, I will contact you
New missing tests: simple_account
I am applying to this issue via OnlyDust platform.
My background and how it can be leveraged
My recent focus in Ethereum-Solidity and Starknet-Cairo has significantly deepened my understanding of web3 technologies, positioning me well to contribute to innovative projects in the blockchain space. As an alumnus of Web3Bridge, where I received training in Solidity and Cairo, I have developed a solid foundation in these technologies. I am eager to contribute to open-source projects within the Starknet ecosystem, and I am particularly excited about the opportunity to make meaningful contributions to this project. Given the chance, I am committed to delivering my best work and leveraging my skills to drive success.
How I plan on tackling this issue
To approach the task of adding integration and unit tests to the Starknet by Example collection, we need a structured plan.
First, set up the testing environment by ensuring that all necessary tools and libraries are installed. This includes Cairo, Starknet CLI, and the Starknet testing framework, such as pytest. Organize your repository to accommodate both the contract examples and their respective tests, perhaps by creating separate directories for contracts and tests.
Next, thoroughly review each contract example to understand its functionality. Identify the key features that need testing and determine the main scenarios to be tested, which includes both integration tests and unit tests.
For integration tests, create a tests.cairo file in a dedicated tests directory for each example. Write test cases that deploy the contract and assert successful deployment. Additionally, write tests that interact with the contract's methods to verify the expected outcomes, simulating real-world use cases. An example of such a test involves deploying the contract and calling its methods, then asserting that the responses are as expected.
For unit tests, add them within the same file as the example for more complex contracts. These tests can be hidden in the book using anchors if necessary. Use mocked implementations or states to isolate and test specific features of the contract. An example unit test involves mocking a specific function or state and asserting the expected behavior.
Once the tests are written, create a new branch for each example you're adding tests to. Add and commit the changes with a descriptive message, then push the branch to your repository and open a PR with a clear description of the changes made.
Ensure that each PR undergoes a thorough code review to confirm that the tests are comprehensive and accurate. Make any necessary changes based on feedback received during the review process, and merge the PRs once they are approved.
To maintain quality, set up a CI pipeline, such as GitHub Actions or GitLab CI, to automatically run tests on every push or PR. This ensures that all tests pass before any changes are merged into the main branch.
By following this structured approach, you can systematically add integration and unit tests to the Starknet by Example collection, ensuring each contract is well-tested and reliable.
I am applying to this issue via OnlyDust platform.
My background and how it can be leveraged
I am a solidity developer and migrating to being a cairo developer
How I plan on tackling this issue
First find the logic to solving the problem and then one by one implement things by reading the documentation for the language.
heyyyy @julio4 is this still available? any function to test? let me know