-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathGolden.hs
40 lines (34 loc) · 1.82 KB
/
Golden.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
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Test.Consensus.Cardano.Golden (tests) where
import Ouroboros.Consensus.Cardano.Block
import Ouroboros.Consensus.Cardano.Node
import Ouroboros.Consensus.HardFork.Combinator.Serialisation
import Ouroboros.Consensus.Ledger.Query (QueryVersion)
import Ouroboros.Consensus.Shelley.HFEras ()
import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol ()
import System.FilePath ((</>))
import Test.Consensus.Cardano.Examples
import Test.Tasty
import Test.Util.Paths
import Test.Util.Serialisation.Golden
tests :: TestTree
tests = goldenTest_all codecConfig ($(getGoldenDir) </> "cardano") examples
instance CardanoHardForkConstraints c
=> ToGoldenDirectory (HardForkNodeToNodeVersion (CardanoEras c)) where
toGoldenDirectory v = case v of
CardanoNodeToNodeVersion1 -> "CardanoNodeToNodeVersion1"
CardanoNodeToNodeVersion2 -> "CardanoNodeToNodeVersion2"
_ -> error $ "Unknown version: " <> show v
instance CardanoHardForkConstraints c
=> ToGoldenDirectory (QueryVersion, HardForkNodeToClientVersion (CardanoEras c)) where
toGoldenDirectory (queryVersion, blockVersion) = show queryVersion </> case blockVersion of
CardanoNodeToClientVersion12 -> "CardanoNodeToClientVersion12"
CardanoNodeToClientVersion13 -> "CardanoNodeToClientVersion13"
CardanoNodeToClientVersion14 -> "CardanoNodeToClientVersion14"
CardanoNodeToClientVersion15 -> "CardanoNodeToClientVersion15"
CardanoNodeToClientVersion16 -> "CardanoNodeToClientVersion16"
_ -> error $ "Unknown version: " <> show blockVersion