-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add unit tests to increase test coverage #118
base: main
Are you sure you want to change the base?
Conversation
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.
Hey @garyghayrat, have not done a full review, but just wanted to address your comment about the remaining untested blocks:
The uncovered lines and statements in StakerPermitAndStake.sol seems to be due to the try/catch block in which we already test with valid and invalid signatures.
This is not quite right! The point of the Try/Catch is to prevent a griefing attack where someone pulls out the signature and executes the permit directly ahead of the actual permitAnd
function call. This would cause the original transaction to fail, even though the allowance had been created, which is why we include the try/catch blocks—with them included, the transaction would proceed despite the fact the permit call was frontrun.
To test this, you should create a test that simulates this, i.e. generate the signature, the submit it directly on the token contract first before calling the permitAnd
function. The test actually wouldn't need an assert, since we're just ensure the call does not revert.
Coverage after merging chore/increase-coverage into main will be
Coverage Report
|
That's good to know, and I've added the test cases you mentioned in 2eaa2b5. But I meant the coverage report summary shows that there are 4 statements (I assume the 2 try catch blocks) are not covered in |
Hey @garyghayrat we have these same try/catch blocks in UniStaker and the lines are covered there. I'd suggest testing out the test suite there to see how it's done. |
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.
This looks good @garyghayrat. Given we have to wait for Foundry to fix foundry-rs/foundry#9921 before we can get up to 100, let's create an issue to track that work so we remember to come back to it. Otherwise, this is good to merge IMO!
closes #117
Before:

After:

The uncovered lines and statements in
StakerPermitAndStake.sol
seems to be due to the try/catch block inwhich we already test with valid and invalid signatures.