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

[TODO] Cheatcodes TODOs #567

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/EVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,9 @@ cheat (inOffset, inSize) (outOffset, outSize) = do

type CheatAction t s = Expr EWord -> Expr EWord -> Expr Buf -> EVM t s ()

-- TODO add: assertTrue etc. from: https:/foundry-rs/forge-std/blob/master/src/StdAssertions.sol
-- implement: assertTrue.. see list: https:/foundry-rs/foundry/blob/master/crates/cheatcodes/spec/src/vm.rs#L843
-- TODO: make this a separate file like CheatCodes.hs
cheatActions :: VMOps t => Map FunctionSelector (CheatAction t s)
cheatActions = Map.fromList
[ action "ffi(string[])" $
Expand Down
9 changes: 9 additions & 0 deletions src/EVM/UnitTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ symRun opts@UnitTestOptions{..} vm (Sig testName types) = do
False -> \(_, post) -> case post of
Success _ _ _ store -> PNeg (failed store)
Failure _ _ (Revert msg) -> case msg of
-- TODO: add line here with "asssert failed" as a prefix, see
-- https:/foundry-rs/foundry/blob/master/crates/cheatcodes/src/test/assert.rs#L183C50-L183C66
ConcreteBuf b -> PBool $ b /= panicMsg 0x01
b -> b ./= ConcreteBuf (panicMsg 0x01)
Failure _ _ _ -> PBool True
Expand Down Expand Up @@ -284,6 +286,13 @@ execSymTest UnitTestOptions{ .. } method cd = do
-- Try running the test method
runExpr

-- TODO see: https:/foundry-rs/foundry/blob/master/crates/cheatcodes/src/test/assert.rs#L189
-- see: https:/foundry-rs/foundry/blob/master/crates/cheatcodes/src/inspector.rs#L757
-- Seems like all failures contain a "assertion failed", see line:
-- https:/foundry-rs/foundry/blob/master/crates/cheatcodes/src/test/assert.rs#L183C50-L183C66
-- We'll need to initially at least:
-- - check "assertion failed" in the revert message (we check for Panic currently NH...)
-- -
checkSymFailures :: VMOps t => UnitTestOptions RealWorld -> Stepper t RealWorld (VM t RealWorld)
checkSymFailures UnitTestOptions { .. } = do
-- Ask whether any assertions failed
Expand Down
Loading