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

Skip assertions #269

Closed
nventuro opened this issue Aug 3, 2018 · 9 comments
Closed

Skip assertions #269

nventuro opened this issue Aug 3, 2018 · 9 comments

Comments

@nventuro
Copy link

nventuro commented Aug 3, 2018

In OpenZeppelin, we're considering dropping some of our asserts and changing them to require (see here for some relevant discussion), changing the semantics of assert to 'shouldn't ever fail unless the code is buggy'. Because of that, solidity-coverage will report a line with partial coverage on each assert.

Could the requirement of assert failure being covered be dropped, or an option added to disable it (maybe with a huge error flag if the assertion ended up failing)? We'd hate to have our coverage figure drop because of a semantics difference.

Thank you for your time and awesome work!

@cgewecke
Copy link
Member

cgewecke commented Aug 3, 2018

@nventuro Yes. This was raised in #149 earlier this year and looking through the comments there I feel like both sides are reasonable...

I think we could add this as an option fairly easily as well.

@nventuro
Copy link
Author

nventuro commented Aug 3, 2018

An option would be great, since there's not yet consensus on this topic. I look forward to it!

@PaulRBerg
Copy link
Contributor

PaulRBerg commented Oct 20, 2020

Should the label for this feature be updated to "0.8.0"?

I'm using solidity-coverage@0.7.10 and assert branches are market as not covered:

Capture d’écran 2020-10-20 à 17 00 22

@cgewecke
Copy link
Member

@PaulRBerg

Purely out of curiosity, why do you prefer using assert over require in this case?

@PaulRBerg
Copy link
Contributor

PaulRBerg commented Oct 20, 2020

Because of a require statement that's executed before:

require(vault.freeCollateral >= collateralAmount, "ERR_INSUFFICIENT_FREE_COLLATERAL");

Also because Solidity's SMTChecker needs both requires and assertions.

@cgewecke
Copy link
Member

@PaulRBerg

Ah ok.. I would lean towards making this change without a major version bump since no one thinks these should branch and it's more like a bug.

Thanks for the SMT link - I didn't realize these have a working application now.

@PaulRBerg
Copy link
Contributor

Happy to help.

And yes, SMTChecker is actually useful! Check out this presentation by Leonardo Alt. It uses assert statements to identify bugs in a contract.

@KholdStare
Copy link

@cgewecke Can probably close this issue since the fix has been merged?

@cgewecke
Copy link
Member

cgewecke commented Feb 3, 2024

Thanks @KholdStare ... sorry for the delay.

@cgewecke cgewecke closed this as completed Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants