This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
/
Json.hs
70 lines (55 loc) · 2.41 KB
/
Json.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Test.Pos.Chain.Txp.Json
( tests
) where
import Universum
import qualified Data.Set as S
import Hedgehog (Property)
import qualified Hedgehog as H
import Pos.Chain.Txp (TxpConfiguration (..))
import Test.Pos.Chain.Txp.Gen (genTxpConfiguration)
import Test.Pos.Core.ExampleHelpers (exampleAddress, exampleAddress1,
exampleAddress2, exampleAddress3, exampleAddress4)
import Test.Pos.Util.Golden (discoverGolden, eachOf, goldenTestJSON)
import Test.Pos.Util.Tripping (discoverRoundTrip, roundTripsAesonShow)
-------------------------------------------------------------------------------
-- TxpConfiguration
-------------------------------------------------------------------------------
golden_TxpConfiguration0 :: Property
golden_TxpConfiguration0 =
goldenTestJSON exampleTxpConfiguration0
"test/golden/json/TxpConfiguration0"
golden_TxpConfiguration1 :: Property
golden_TxpConfiguration1 =
goldenTestJSON exampleTxpConfiguration1
"test/golden/json/TxpConfiguration1"
golden_TxpConfiguration2 :: Property
golden_TxpConfiguration2 =
goldenTestJSON exampleTxpConfiguration2
"test/golden/json/TxpConfiguration2"
roundTripTxpConfiguration :: Property
roundTripTxpConfiguration =
eachOf 200 genTxpConfiguration roundTripsAesonShow
-------------------------------------------------------------------------------
-- Main test export
-------------------------------------------------------------------------------
exampleTxpConfiguration0 :: TxpConfiguration
exampleTxpConfiguration0 = TxpConfiguration 99 talsa
where
talsa = S.fromList [exampleAddress]
exampleTxpConfiguration1 :: TxpConfiguration
exampleTxpConfiguration1 = TxpConfiguration 9 talsa
where
talsa = S.fromList [exampleAddress1, exampleAddress2, exampleAddress3]
exampleTxpConfiguration2 :: TxpConfiguration
exampleTxpConfiguration2 = TxpConfiguration 700 talsa
where
talsa = S.fromList [exampleAddress4, exampleAddress]
-------------------------------------------------------------------------------
-- Main test export
-------------------------------------------------------------------------------
tests :: IO Bool
tests = (&&) <$> H.checkSequential $$discoverGolden
<*> H.checkParallel $$discoverRoundTrip