Skip to content

Commit

Permalink
show transactions when test is falsified in text mode (#1271)
Browse files Browse the repository at this point in the history
  • Loading branch information
samalws-tob authored Jun 13, 2024
1 parent 8347ad9 commit 9f05340
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
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

0 comments on commit 9f05340

Please sign in to comment.