-
Notifications
You must be signed in to change notification settings - Fork 48
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
Cheatcodes as per new std-forge library #567
Conversation
e78213a
to
c0cca47
Compare
fd7745f
to
527025f
Compare
527025f
to
a16d3c0
Compare
checkSymFailures :: VMOps t => UnitTestOptions RealWorld -> Stepper t RealWorld (VM t RealWorld) | ||
checkSymFailures UnitTestOptions { .. } = do | ||
-- Ask whether any assertions failed | ||
Stepper.evm $ do | ||
popTrace | ||
abiCall testParams (Left ("failed()", emptyAbi)) | ||
Stepper.runFully | ||
|
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 not used anywhere, so I'm removing it
6d87659
to
0905738
Compare
2cee6f1
to
48215cc
Compare
48215cc
to
b00abc9
Compare
865dee5
to
23328dc
Compare
7051638
to
3797dc0
Compare
e138b11
to
0edfa94
Compare
0edfa94
to
a6124bb
Compare
src/EVM/UnitTest.hs
Outdated
Just cheatContract -> readStorage' (Lit 0x6661696c65640000000000000000000000000000000000000000000000000000) cheatContract.storage .== Lit 1 | ||
Nothing -> And (readStorage' (Lit 0) (testContract store).storage) (Lit 2) .== Lit 2 | ||
postcondition = curry $ case shouldFail of |
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.
We don't store failures here any more in forge-std, so no need to check.
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.
we might wanna keep this around for a while as a compat mode? maybe with some cli flag --assertion-mode <ds-test|forge-std>
?
09dd926
to
dfcc0c1
Compare
dfcc0c1
to
88ccb41
Compare
fa9ef1d
to
f7219b9
Compare
Goal
The way forge-std is doing things has changed. It no longer sets a value in ds-test, but instead
Revert
-s with a specific message. So we have to match:Instead of the current:
The most prominent part of this change is the disappearance of line 202 from
UnitTest.hs
, where we'd check for failure bit being set in the cheat contract (i.e.0x7109709EC...
)Implementation
EVM.hs
to have a separate frame, which allows this to be coded in a relatively compact way. I have now added a number of required (but not all) cheatcodes.std-forge/Test.hs
and{Test}
fromds-test/test.hs
and{DSTest}
assert...
methods, though some are still missing. The ones still missing would require dynamic ABI handling, such asassertTrue(uint,string)
, wherestring
is dynamic.prove_tuple_fail1(uint256[5] memory amounts)
actually worksFuture work
I haven't added:
assertEq(T[], T[])
type assertsassertNotEq(T[], T[])
type assertsassertXXDecimal
Mostly due to the above mentioned issue with dynamic ABI type issue.
TODO in a future PR
Checklist