-
Notifications
You must be signed in to change notification settings - Fork 335
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
feat: implement boundInt #253
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.
This is awesome, thanks a lot! Pinging @PaulRBerg since I know he was interesting in this method.
Just a few nits for you 🙂
@@ -4,12 +4,12 @@ pragma solidity >=0.6.2 <0.9.0; | |||
import "./console2.sol"; | |||
|
|||
abstract contract StdUtils { | |||
uint256 private constant INT256_MIN_ABS = |
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.
(arbitrary comment location to start a thread)
One problem is that
log(string,int256)
does not exist so I usedlog(string,uint256)
instead of it.
If you want to add support for this:
- Add the required method to
console2.sol
in forge-std - Update the ABI file in foundry
I think that should be all that's needed, but I may be missing something. Also related is #129 if you wanted to add that overload at the same time
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.
Okay, I'll check this out.
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.
What will be the better one, log(string,int256)
or logInt(string,int256)
?
At the related thread of #129, they decided to name logInt(int256...)
rather than log(int256...)
because of the ambiguity.
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.
I'm ok with log(string,int256)
because in practice you'll be doing console.log(myVar)
(unambiguous since myVar
has a type) instead of console.log(3)
(ambiguous because we don't know 3's type)
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.
Applied at here!
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.
Thanks! Note that the logs won't actually be shown until we upstream the corresponding change to forge. I can do that soon though
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.
LGTM, thanks @JhChoy!
@ZeroEkkusu mind taking a look before we merge?
@JhChoy just a heads up I pushed two small commits to this branch and opened foundry-rs/foundry#3884 |
@mds1 Thanks for the review! 🙌 |
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.
Thanks.
Pushed changes for After foundry-rs/foundry#3884 is resolved, we will remove the workaround. Note: |
Thanks, @JhChoy - good work. |
Implementing
boundInt(int256,int256,int256)
at StdUtils.sol to help fuzzing test with integer arguments.One problem is that
log(string,int256)
does not exist so I usedlog(string,uint256)
instead of it.