-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Roundtrip tests to Conway, added JSON and CBOR instances to Con…
…wayGenesis Signed-off-by: Joosep Jääger <joosep.jaager@gmail.com> Signed-off-by: Joosep Jääger <joosep.jaager@iohk.io>
- Loading branch information
Showing
7 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 12 additions & 3 deletions
15
eras/conway/test-suite/src/Test/Cardano/Ledger/Conway/Serialisation/Generators.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
|
||
module Test.Cardano.Ledger.Conway.Serialisation.Generators () where | ||
|
||
import Test.Cardano.Ledger.Babbage.Serialisation.Generators () | ||
import Test.QuickCheck (Arbitrary (..), Gen, generate) | ||
import Cardano.Ledger.Conway.Genesis (ConwayGenesis(..)) | ||
import Cardano.Ledger.Crypto (Crypto) | ||
import Test.Cardano.Ledger.Shelley.ConcreteCryptoTypes (C_Crypto) | ||
import Data.Aeson (ToJSON(..), fromEncoding) | ||
import Cardano.Binary (ToCBOR(..)) | ||
import Data.ByteString.Builder (toLazyByteString) | ||
|
||
-- Currently Conway does not define any types that require serialization, | ||
-- therefore we simply re-export ones from Babbage. This could change in the | ||
-- future, thus is this placeholder module. | ||
deriving instance Crypto c => Arbitrary (ConwayGenesis c) |
28 changes: 28 additions & 0 deletions
28
eras/conway/test-suite/src/Test/Cardano/Ledger/Conway/Serialisation/Roundtrip.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
module Test.Cardano.Ledger.Conway.Serialisation.Roundtrip (allprops) where | ||
|
||
import Cardano.Ledger.Conway.Genesis (ConwayGenesis (..)) | ||
import Cardano.Ledger.Core (Era (..)) | ||
import Cardano.Ledger.Crypto (Crypto) | ||
import Data.Data (Proxy (..), Typeable, typeRep) | ||
import Test.Cardano.Ledger.Conway.Serialisation.Generators () | ||
import Test.QuickCheck (Property) | ||
import Test.Tasty (TestTree, testGroup) | ||
import Test.Tasty.QuickCheck (testProperty) | ||
import Test.Cardano.Ledger.ShelleyMA.Serialisation.Roundtrip (property) | ||
|
||
allprops :: | ||
forall e. | ||
( Era e | ||
) => | ||
TestTree | ||
allprops = | ||
testGroup | ||
(show $ typeRep (Proxy @e)) | ||
[ testProperty "ConwayGenesis" $ property @(ConwayGenesis (EraCrypto e)) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
module Main where | ||
|
||
import Test.Tasty (TestTree, askOption, testGroup) | ||
import Test.TestScenario (mainWithTestScenario, TestScenario (..)) | ||
import qualified Test.Cardano.Ledger.Conway.Serialisation.Roundtrip as Roundtrip | ||
import Cardano.Ledger.Conway (Conway) | ||
|
||
tests :: TestTree | ||
tests = askOption @TestScenario $ \case | ||
_ -> mainTests | ||
|
||
mainTests :: TestTree | ||
mainTests = testGroup | ||
"Conway tests" | ||
[ Roundtrip.allprops @Conway | ||
] | ||
|
||
main :: IO () | ||
main = mainWithTestScenario tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters