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

Display assertion failure immediately once falsified in text mode #1271

Merged
merged 1 commit into from
Jun 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion lib/Echidna/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ ui vm world dict initialCorpus cliSelectedContract cs = do
void $ tryPutMVar serverStopVar ()
in installHandler sig handler Nothing
#endif
let forwardEvent = putStrLn . ppLogLine
let forwardEvent ev = putStrLn =<< runReaderT (ppLogLine vm ev) env
uiEventsForwarderStopVar <- spawnListener forwardEvent

let printStatus = do
Expand Down
20 changes: 13 additions & 7 deletions lib/Echidna/UI/Report.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ import EVM.Format (showTraceTree, contractNamePart)
import EVM.Solidity (SolcContract(..))
import EVM.Types (W256, VM, VMType(Concrete), Addr, Expr (LitAddr))

ppLogLine :: (LocalTime, CampaignEvent) -> String
ppLogLine (time, event@(WorkerEvent workerId FuzzWorker _)) =
timePrefix time <> "[Worker " <> show workerId <> "] " <> ppCampaignEvent event
ppLogLine (time, event@(WorkerEvent workerId SymbolicWorker _)) =
timePrefix time <> "[Worker " <> show workerId <> ", symbolic] " <> ppCampaignEvent event
ppLogLine (time, event) =
timePrefix time <> " " <> ppCampaignEvent event
ppLogLine :: MonadReader Env m => VM Concrete RealWorld -> (LocalTime, CampaignEvent) -> m String
ppLogLine vm (time, event@(WorkerEvent workerId FuzzWorker _)) =
((timePrefix time <> "[Worker " <> show workerId <> "] ") <>) <$> ppCampaignEventLog vm event
ppLogLine vm (time, event@(WorkerEvent workerId SymbolicWorker _)) =
((timePrefix time <> "[Worker " <> show workerId <> ", symbolic] ") <>) <$> ppCampaignEventLog vm event
ppLogLine vm (time, event) =
((timePrefix time <> " ") <>) <$> ppCampaignEventLog vm event

ppCampaignEventLog :: MonadReader Env m => VM Concrete RealWorld -> CampaignEvent -> m String
ppCampaignEventLog vm ev = (ppCampaignEvent ev <>) <$> ppTxIfHas where
ppTxIfHas = case ev of
(WorkerEvent _ _ (TestFalsified test)) -> ("\n Call sequence:\n" <>) . unlines <$> mapM (ppTx vm $ length (nub $ (.src) <$> test.reproducer) /= 1) test.reproducer
_ -> pure ""

ppCampaign :: (MonadIO m, MonadReader Env m) => VM Concrete RealWorld -> [WorkerState] -> m String
ppCampaign vm workerStates = do
Expand Down
Loading