Get Foundry pilled (great presentation by Georgios at EthCC):
Slides: docs.google.com/presentation/d/1AuQojnFMkozOiR8kDu5LlWT7vv1EfPytmVEeq1XMtM0
✨ What's new in Forge Std ✨
A recap of the new features added in the last month!
Std Assertions
In addition to the assertions from DSTest, you can now use:
fail
with string
assertFalse
assertEq
for bool
and bytes
assertApproxEqAbs
, for uint
and int
assertApproxEqRel
, for uint
and int
The new assertApproxEqAbs
and assertApproxEqRel
functions let you assert that a value approximately equals another value. The tolerance can be either absolute (Abs
) or relative (Rel
).
Std Math
This is a new library with mathematical functions you'd need when testing, but not available in Solidity:
abs
, for int
delta
, for uint
and int
percentDelta
, for uint
and int
Std Cheats
There are two new std-cheats:
bound
changePrank
bound
is useful instead of vm.assume
for broad checks, because it does not slow down tests, and you won't hit the maximum number of rejects.
changePrank
let's you vm.startPrank
in the setUp
and change the address in certain tests.
You can learn more about the new features from 📖 Foundry Book:
book.getfoundry.sh/reference/forge-std/std-assertions.html
book.getfoundry.sh/reference/forge-std/std-math.html
book.getfoundry.sh/cheatcodes/assume.html
book.getfoundry.sh/reference/forge-std/change-prank.html
gm! are there any examples of writing more advanced scripts - hardhat task type stuff - with foundry?
Gm, frens!
I created this as an unofficial Foundry community, where we can discuss all things Foundry. I think it will be a great place to share details about new features and meet fellow builders!
Little info about me: Currently, I'm not a Foundry dev (have no experience with Rust); I'm contributing to Forge Std to make testing easier and sometimes writing Foundry Book.
Looking forward to meeting you!