-
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
[DRAFT] Cheatcodes as per new std-forge library #567
base: main
Are you sure you want to change the base?
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
") parameter decoding failed. Error: " <> show abivals | ||
revertErr a b comp = frameRevert $ "assertion failed: " <> | ||
BS8.pack (show a) <> " " <> comp <> " " <> BS8.pack (show b) | ||
assertEq abitype sig input = do |
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 not super bothered by the duplication but if you wanted to cut some lines you could probably merge the implementations into one function that is parametrised on the comparison function and string used in the revert error?
src/EVM.hs
Outdated
revertContracts | ||
revertSubstate | ||
assign (#state % #returndata) mempty | ||
assign (#state % #returndata) (ConcreteBuf (BS8.pack $ show e)) |
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.
why do we need to do this for non reverting errors?
@@ -224,6 +227,12 @@ symRun opts@UnitTestOptions{..} vm (Sig testName types) = do | |||
-- check postconditions against vm | |||
(e, results) <- verify solvers (makeVeriOpts opts) (symbolify vm') (Just postcondition) | |||
let allReverts = not . (any Expr.isSuccess) . flattenExpr $ e | |||
let fails = filter (Expr.isFailure) $ flattenExpr e | |||
unless (null fails) $ liftIO $ do | |||
putStrLn $ " \x1b[33mWARNING\x1b[0m: hevm was only able to partially explore the test " <> Text.unpack testName <> " due to: "; |
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.
Are failures the same as partial executions?
2cee6f1
to
48215cc
Compare
48215cc
to
b00abc9
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:
Implementation
Emilio has changed things around already in
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.Future work
I haven't added:
assertEq(T[], T[])
type assertsassertNotEq(T[], T[])
type assertsassertXXDecimal
I need to cut the cheatcodes into a separate file. I'll do these in the next PR, this was it's a bit easier to review this PR.
Checklist