No test suite
Description
There is currently no test suite for this codebase.
Impact
When building a project with multiple moving parts and dependencies, comprehensive testing is essential. This includes testing for both positive and negative scenarios. Positive tests should verify that each function's side effect is as expected, while negative tests should cover every revert, preferably in every logical branch. For example, Finding ref↗ could have been discovered by a test.
The test suite for this project should be implemented with a large coverage to include all contract code, not just surface-level functions. It is important to test the invariants required for ensuring security. Testing the findings reported during this audit should be implemented to avoid regression in the future. Additionally, testing cross-contract function calls and transfers is recommended to ensure the desired functionality.
Recommendations
We recommend building a rigorous test suite to ensure that the system operates securely and as intended.
Good test coverage has multiple effects.
It finds bugs and design flaws early (preaudit or prerelease).
It gives insight into areas for optimization (e.g., gas cost).
It displays code maturity.
It bolsters customer trust in your product.
It improves understanding of how the code functions, integrates, and operates — for developers and auditors alike.
It increases development velocity long-term.
The last point seems contradictory, given the time investment to create and maintain tests. To expand upon that, tests help developers trust their own changes. It is difficult to know if a code refactor — or even just a small one-line fix — breaks something if there are no tests. This is especially true for new developers or those returning to the code after a prolonged absence. Tests have your back here. They are an indicator that the existing functionality most likely was not broken by your change to the code.
Remediation
After the audit, Level added a test suite for the LevelStakingPool
contract in commit 90a5753↗.