-
Notifications
You must be signed in to change notification settings - Fork 396
/
Copy pathSeed.hs
44 lines (41 loc) · 1.4 KB
/
Seed.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module Tests.Seed (seedTests) where
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase, assertBool)
import Common (runContract, overrideQuiet)
import Data.Function ((&))
import Data.IORef (readIORef)
import Echidna.Config (defaultConfig)
import Echidna.Mutator.Corpus (defaultMutationConsts)
import Echidna.Types.Campaign
import Echidna.Types.Config (Env(..), EConfig(..))
import Echidna.Types.Coverage (CoverageFileType(..))
import Echidna.Types.Test
seedTests :: TestTree
seedTests =
testGroup "Seed reproducibility testing"
[ testCase "different seeds" $ assertBool "results are the same" . not =<< same 0 2
, testCase "same seeds" $ assertBool "results differ" =<< same 0 0
]
where
cfg s = defaultConfig
{ campaignConf = CampaignConf
{ testLimit = Just 600
, stopOnFail = False
, estimateGas = False
, seqLen = 20
, shrinkLimit = 0
, knownCoverage = Nothing
, seed = Just s
, dictFreq = 0.15
, corpusDir = Nothing
, mutConsts = defaultMutationConsts
, coverageFormats = [Txt,Html,Lcov]
, workers = Nothing
, serverPort = Nothing
}
}
& overrideQuiet
gen s = do
(env, _) <- runContract "basic/flags.sol" Nothing (cfg s)
readIORef env.testsRef
same s t = (\x y -> ((.reproducer) <$> x) == ((.reproducer) <$> y)) <$> gen s <*> gen t