@@ -4,7 +4,7 @@ import Control.Monad ((<=<))
44import Control.Monad.Catch (MonadThrow )
55import Control.Monad.Random.Strict (MonadRandom , getRandomR , uniform )
66import Control.Monad.Reader.Class (MonadReader (ask ), asks )
7- import Control.Monad.State.Strict (MonadIO , MonadState , modify' )
7+ import Control.Monad.State.Strict (MonadIO )
88import Control.Monad.ST (RealWorld )
99import Data.Set qualified as Set
1010import Data.List qualified as List
@@ -18,12 +18,12 @@ import Echidna.Types.Solidity (SolConf(..))
1818import Echidna.Types.Test (TestValue (.. ), EchidnaTest (.. ), TestState (.. ), isOptimizationTest )
1919import Echidna.Types.Tx (Tx (.. ), hasReverted , isUselessNoCall , catNoCalls , TxCall (.. ))
2020import Echidna.Types.Config
21- import Echidna.Types.Campaign (CampaignConf (.. ), WorkerState ( .. ) )
21+ import Echidna.Types.Campaign (CampaignConf (.. ))
2222import Echidna.Test (getResultFromVM , checkETest )
2323
2424 -- | Top level function to shrink the complexity of the sequence of transactions once
2525shrinkTest
26- :: (MonadIO m , MonadThrow m , MonadRandom m , MonadReader Env m , MonadState WorkerState m )
26+ :: (MonadIO m , MonadThrow m , MonadRandom m , MonadReader Env m )
2727 => VM Concrete RealWorld
2828 -> EchidnaTest
2929 -> m (Maybe EchidnaTest )
@@ -42,19 +42,17 @@ shrinkTest vm test = do
4242 if length rr > 1 || any canShrinkTx rr then do
4343 maybeShrunk <- shrinkSeq vm (checkETest test) test. value rr
4444 -- check if the shrunk sequence passes the test or not
45- case maybeShrunk of
45+ pure $ case maybeShrunk of
4646 -- the test still fails, let's create another test with the reduced sequence
4747 Just (txs, val, vm') -> do
48- let afterLen = length txs
49- modify' $ \ ws -> ws { lastShrinkP = Just afterLen }
50- pure $ Just test { state = Large (i + 1 )
48+ Just test { state = Large (i + 1 )
5149 , reproducer = txs
5250 , vm = Just vm'
5351 , result = getResultFromVM vm'
5452 , value = val }
5553 Nothing ->
5654 -- The test passed, so no success with shrinking this time, just bump number of tries to shrink
57- pure $ Just test { state = Large (i + 1 ), reproducer = rr}
55+ Just test { state = Large (i + 1 ), reproducer = rr}
5856 else
5957 pure $ Just test { state = if isOptimizationTest test
6058 then Large (i + 1 )
@@ -91,7 +89,7 @@ removeReverts' vm (t:txs) ftxs = do
9189-- | Given a call sequence that solves some Echidna test, try to randomly
9290-- generate a smaller one that still solves that test.
9391shrinkSeq
94- :: (MonadIO m , MonadRandom m , MonadReader Env m , MonadThrow m , MonadState WorkerState m )
92+ :: (MonadIO m , MonadRandom m , MonadReader Env m , MonadThrow m )
9593 => VM Concrete RealWorld
9694 -> (VM Concrete RealWorld -> m (TestValue , VM Concrete RealWorld ))
9795 -> TestValue
0 commit comments