-
Notifications
You must be signed in to change notification settings - Fork 155
/
Json.hs
80 lines (65 loc) · 2.88 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
71
72
73
74
75
76
77
78
79
80
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
module Test.Cardano.Chain.Genesis.Json (
tests,
)
where
import Cardano.Prelude
import GetDataFileName ((<:<))
import Hedgehog (Property)
import Test.Cardano.Chain.Delegation.Gen (genCanonicalCertificate)
import Test.Cardano.Chain.Genesis.Example (exampleGenesisData0)
import Test.Cardano.Chain.Genesis.Gen (
genCanonicalGenesisData,
genCanonicalGenesisDelegation,
genGenesisAvvmBalances,
genGenesisKeyHashes,
genGenesisNonAvvmBalances,
)
import Test.Cardano.Chain.Update.Gen (
genCanonicalProtocolParameters,
)
import Test.Cardano.Crypto.Gen (feedPM)
import Test.Cardano.Prelude
import Test.Options (TSGroup, TSProperty, concatTSGroups, eachOfTS)
--------------------------------------------------------------------------------
-- JSON Canonical Tests
--------------------------------------------------------------------------------
ts_roundTripCanonicalCertificate :: TSProperty
ts_roundTripCanonicalCertificate =
eachOfTS 100 (feedPM genCanonicalCertificate) roundTripsCanonicalJsonPretty
ts_roundTripCanonicalGenesisAvvmBalances :: TSProperty
ts_roundTripCanonicalGenesisAvvmBalances =
eachOfTS 100 genGenesisAvvmBalances roundTripsCanonicalJsonPretty
ts_roundTripCanonicalGenesisData :: TSProperty
ts_roundTripCanonicalGenesisData =
eachOfTS 100 (feedPM genCanonicalGenesisData) roundTripsCanonicalJsonPretty
ts_roundTripCanonicalGenesisDelegation :: TSProperty
ts_roundTripCanonicalGenesisDelegation =
eachOfTS 100 (feedPM genCanonicalGenesisDelegation) roundTripsCanonicalJsonPretty
ts_roundTripCanonicalGenesisNonAvvmBalances :: TSProperty
ts_roundTripCanonicalGenesisNonAvvmBalances =
eachOfTS 100 genGenesisNonAvvmBalances roundTripsCanonicalJsonPretty
ts_roundTripCanonicalGenesisKeyHashes :: TSProperty
ts_roundTripCanonicalGenesisKeyHashes =
eachOfTS 100 genGenesisKeyHashes roundTripsCanonicalJsonPretty
ts_roundTripCanonicalProtocolParameters :: TSProperty
ts_roundTripCanonicalProtocolParameters =
eachOfTS 100 genCanonicalProtocolParameters roundTripsCanonicalJsonPretty
--------------------------------------------------------------------------------
-- GenesisData (Canonical JSON)
--------------------------------------------------------------------------------
-- Decode-only golden tests for ensuring that, when decoding the legacy
-- `GenesisData` canonical JSON format, the `RequiresNetworkMagic` field
-- defaults to `RequiresMagic`.
golden_GenesisData0Dec :: Property
golden_GenesisData0Dec =
goldenTestCanonicalJSONDec
exampleGenesisData0
<:< "golden/json/genesis/GenesisData0_Legacy_HasNetworkMagic"
-------------------------------------------------------------------------------
-- Main test export
-------------------------------------------------------------------------------
tests :: TSGroup
tests = concatTSGroups [const $$discoverGolden, $$discoverPropArg]